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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 19 Mar 2012 17:15:40 +0530
From:	"Srivatsa S. Bhat" <srivatsa.bhat@...ux.vnet.ibm.com>
To:	Amit Daniel Kachhap <amit.kachhap@...aro.org>
CC:	linux-pm@...ts.linux-foundation.org,
	linux-samsung-soc@...r.kernel.org, linux-kernel@...r.kernel.org,
	mjg59@...f.ucam.org, linux-acpi@...r.kernel.org, lenb@...nel.org,
	linaro-dev@...ts.linaro.org, lm-sensors@...sensors.org,
	patches@...aro.org, eduardo.valentin@...com, durgadoss.r@...el.com,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
Subject: Re: [PATCH V2 3/6] thermal: Add generic cpuhotplug cooling implementation

On 03/19/2012 11:47 AM, Amit Daniel Kachhap wrote:

> This patch adds support for generic cpu thermal cooling low level
> implementations using cpuhotplug based on the thermal level requested
> from user. Different cpu related cooling devices can be registered by the
> user and the binding of these cooling devices to the corresponding
> trip points can be easily done as the registration APIs return the
> cooling device pointer. The user of these APIs are responsible for
> passing the cpumask.
> 


I am really not aware of the cpu thermal cooling stuff, but since this patch
deals with CPU Hotplug (which I am interested in), I have some questions
below..
 

> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@...aro.org>
> +
> +static int cpuhotplug_get_cur_state(struct thermal_cooling_device *cdev,
> +				 unsigned long *state)
> +{
> +	int ret = -EINVAL;
> +	struct hotplug_cooling_device *hotplug_dev;
> +
> +	mutex_lock(&cooling_cpuhotplug_lock);
> +	list_for_each_entry(hotplug_dev, &cooling_cpuhotplug_list, node) {
> +		if (hotplug_dev && hotplug_dev->cool_dev == cdev) {
> +			*state = hotplug_dev->hotplug_state;
> +			ret = 0;
> +			break;
> +		}
> +	}
> +	mutex_unlock(&cooling_cpuhotplug_lock);
> +	return ret;
> +}
> +
> +/*This cooling may be as ACTIVE type*/
> +static int cpuhotplug_set_cur_state(struct thermal_cooling_device *cdev,
> +				 unsigned long state)
> +{
> +	int cpuid, this_cpu = smp_processor_id();


What prevents this task from being migrated to another CPU?
IOW, what ensures that 'this_cpu' remains valid throughout this function?

I see that you are acquiring mutex locks below.. So this is definitely not
a preempt disabled section.. so I guess my question above is valid..

Or is this code bound to a particular cpu?

> +	struct hotplug_cooling_device *hotplug_dev;
> +
> +	mutex_lock(&cooling_cpuhotplug_lock);
> +	list_for_each_entry(hotplug_dev, &cooling_cpuhotplug_list, node)
> +		if (hotplug_dev && hotplug_dev->cool_dev == cdev)
> +			break;
> +
> +	mutex_unlock(&cooling_cpuhotplug_lock);
> +	if (!hotplug_dev || hotplug_dev->cool_dev != cdev)
> +		return -EINVAL;
> +
> +	if (hotplug_dev->hotplug_state == state)
> +		return 0;
> +
> +	/*
> +	* This cooling device may be of type ACTIVE, so state field can
> +	* be 0 or 1
> +	*/
> +	if (state == 1) {
> +		for_each_cpu(cpuid, hotplug_dev->allowed_cpus) {
> +			if (cpu_online(cpuid) && (cpuid != this_cpu))


What prevents the cpu numbered cpuid from being taken down right at this moment?
Don't you need explicit synchronization with CPU Hotplug using something like
get_online_cpus()/put_online_cpus() here?

> +				cpu_down(cpuid);
> +		}
> +	} else if (state == 0) {
> +		for_each_cpu(cpuid, hotplug_dev->allowed_cpus) {
> +			if (!cpu_online(cpuid) && (cpuid != this_cpu))


Same here.

> +				cpu_up(cpuid);
> +		}
> +	} else {
> +		return -EINVAL;
> +	}
> +
> +	hotplug_dev->hotplug_state = state;
> +
> +	return 0;
> +}
> +/* bind hotplug callbacks to cpu hotplug cooling device */
> +static struct thermal_cooling_device_ops cpuhotplug_cooling_ops = {
> +	.get_max_state = cpuhotplug_get_max_state,
> +	.get_cur_state = cpuhotplug_get_cur_state,
> +	.set_cur_state = cpuhotplug_set_cur_state,
> +};
> +

--
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