lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 31 Jul 2012 21:13:58 +0530
From:	"Srivatsa S. Bhat" <srivatsa.bhat@...ux.vnet.ibm.com>
To:	Colin Cross <ccross@...roid.com>
CC:	Len Brown <lenb@...nel.org>, Len Brown <len.brown@...el.com>,
	Kevin Hilman <khilman@...com>,
	Santosh Shilimkar <santosh.shilimkar@...com>,
	"Rafael J. Wysocki" <rjw@...k.pl>, linux-kernel@...r.kernel.org,
	Linux PM mailing list <linux-pm@...r.kernel.org>
Subject: Re: [PATCH] cpuidle: coupled: fix sleeping while atomic in cpu notifier

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@...roid.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;
	}

Regards,
Srivatsa S. Bhat

>  	mutex_lock(&cpuidle_lock);
> 
>  	dev = per_cpu(cpuidle_devices, cpu);
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ