Subject: Re: [PATCH v3] ARM: imx6q: cpuidle: fix bug that CPU might not wake up at expected time

From: Shawn Guo <[email-masked]>
Date: Mon, 4 Mar 2019 15:00:31 +0800

On Mon, Mar 04, 2019 at 10:28:14AM +0900, Kohji Okuno wrote:
> Hi Shawn,
> 
> I found this bug by delaying periodic communication. For example, it
> is the source codes as below.
> 
> 	while (1) {
> 		sleep(2);
> 		write(fd, "Hello", strlen("Hello"));
> 	}
> 
> Of course, it dows not occur frequently. However, in the worst case,
> it stopped for more than 1 minute.
> 
> If there are few running processes and few hrtimer events, this issue
> will occur.
> 
> For example:
> (*) time is abstracting.
>     WFI idle : the CPU will be waked up by local timer.
>     WAIT idle: the CPU will be waked up by broad cast(bc) timer.
>     
> [time]
> 	  CPU#0				  CPU#1
> ----------------------------------------------------------------------
> 	enter "WAIT" idle
> 	[next event=10]
> 					enter "WAIT" idle
> 					[next event=60]	
> 			all cpus are IDLE = > CPU#1 sets WAIT_UNCLOCKED
> 
> 10:	bc timer fires
> 	exit idle
> 	
> 	enter "WFI" idle
> 	[next event=12]
> 	
> 12:     ** local timer is not fired **
> 	CPU#0 will not be waked up
> 	until the next bc timer interrupt.
> 
> 			>> all processes stop <<
> 
> 60:	bc timer fires
> 	exit idle			exit idle
> 					CPU#1 sets WAIT_CLOCKED
> 	local timer fires
> 
> If CPU#0 sets WAIT_CLOCKED at time=10, this issue will not occur.
> 
> Does that make any sense?

Yes, makes sense, and thanks for the details.  So the fix should be
a material for stable kernel, even though the bug doesn't happen often.
Thanks for the patch.

Shawn

_______________________________________________
linux-arm-kernel mailing list
[email-masked]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel