lkml.org 
[lkml]   [2012]   [Jul]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] cpuidle: coupled: fix sleeping while atomic in cpu notifier
From
On Tue, Jul 31, 2012 at 8:43 AM, Srivatsa S. Bhat
<srivatsa.bhat@linux.vnet.ibm.com> wrote:
> On 07/26/2012 02:50 AM, Colin Cross wrote:
>> The cpu hotplug notifier gets called in both atomic and non-atomic
>> contexts, it is not always safe to lock a mutex. Filter out all events
>> except the six necessary ones, which are all sleepable, before taking
>> the mutex.
>>
>> Signed-off-by: Colin Cross <ccross@android.com>
>> ---
>> drivers/cpuidle/coupled.c | 12 ++++++++++++
>> 1 files changed, 12 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/cpuidle/coupled.c b/drivers/cpuidle/coupled.c
>> index 2c9bf26..c24dda0 100644
>> --- a/drivers/cpuidle/coupled.c
>> +++ b/drivers/cpuidle/coupled.c
>> @@ -678,6 +678,18 @@ static int cpuidle_coupled_cpu_notify(struct notifier_block *nb,
>> int cpu = (unsigned long)hcpu;
>> struct cpuidle_device *dev;
>>
>> + switch (action & ~CPU_TASKS_FROZEN) {
>> + case CPU_UP_PREPARE:
>> + case CPU_DOWN_PREPARE:
>> + case CPU_ONLINE:
>> + case CPU_DEAD:
>> + case CPU_UP_CANCELED:
>> + case CPU_DOWN_FAILED:
>> + break;
>> + default:
>> + return NOTIFY_OK;
>> + }
>> +
>
> Instead, wouldn't it be better to have case statements for the
> 2 cases that imply atomic context and return immediately?
>
> Something like:
> switch (action & ~CPU_TASKS_FROZEN) {
> case CPU_STARTING:
> case CPU_DYING:
> return NOTIFY_OK;
> }

No, because then it would need updating whenever a new notification
event was added.


\
 
 \ /
  Last update: 2012-07-31 21:21    [W:0.148 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site