All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: Amit Daniel Kachhap <amit.kachhap@linaro.org>
Cc: linux-samsung-soc@vger.kernel.org, linaro-dev@lists.linaro.org,
	patches@linaro.org, linux-kernel@vger.kernel.org,
	lm-sensors@lm-sensors.org, linux-acpi@vger.kernel.org,
	linux-pm@lists.linux-foundation.org,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [PATCH V2 3/6] thermal: Add generic cpuhotplug cooling implementation
Date: Mon, 19 Mar 2012 17:15:40 +0530	[thread overview]
Message-ID: <4F671C64.5020803@linux.vnet.ibm.com> (raw)
In-Reply-To: <1332137864-12943-4-git-send-email-amit.kachhap@linaro.org>

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@linaro.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,
> +};
> +

WARNING: multiple messages have this Message-ID (diff)
From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: Amit Daniel Kachhap <amit.kachhap@linaro.org>
Cc: linux-samsung-soc@vger.kernel.org, linaro-dev@lists.linaro.org,
	patches@linaro.org, linux-kernel@vger.kernel.org,
	lm-sensors@lm-sensors.org, linux-acpi@vger.kernel.org,
	linux-pm@lists.linux-foundation.org,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [lm-sensors] [PATCH V2 3/6] thermal: Add generic cpuhotplug cooling implementation
Date: Mon, 19 Mar 2012 11:57:40 +0000	[thread overview]
Message-ID: <4F671C64.5020803@linux.vnet.ibm.com> (raw)
In-Reply-To: <1332137864-12943-4-git-send-email-amit.kachhap@linaro.org>

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@linaro.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,
> +};
> +


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

WARNING: multiple messages have this Message-ID (diff)
From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: Amit Daniel Kachhap <amit.kachhap@linaro.org>
Cc: linux-pm@lists.linux-foundation.org,
	linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
	mjg59@srcf.ucam.org, linux-acpi@vger.kernel.org, lenb@kernel.org,
	linaro-dev@lists.linaro.org, lm-sensors@lm-sensors.org,
	patches@linaro.org, eduardo.valentin@ti.com,
	durgadoss.r@intel.com,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [PATCH V2 3/6] thermal: Add generic cpuhotplug cooling implementation
Date: Mon, 19 Mar 2012 17:15:40 +0530	[thread overview]
Message-ID: <4F671C64.5020803@linux.vnet.ibm.com> (raw)
In-Reply-To: <1332137864-12943-4-git-send-email-amit.kachhap@linaro.org>

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@linaro.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,
> +};
> +


  reply	other threads:[~2012-03-19 11:45 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-19  6:17 [PATCH V2 0/6] thermal: exynos: Add kernel thermal support for exynos platform Amit Daniel Kachhap
2012-03-19  6:29 ` [lm-sensors] " Amit Daniel Kachhap
2012-03-19  6:17 ` Amit Daniel Kachhap
2012-03-19  6:17 ` [PATCH V2 1/6] thermal: Add a new trip type to use cooling device instance number Amit Daniel Kachhap
2012-03-19  6:29   ` [lm-sensors] " Amit Daniel Kachhap
2012-03-19  6:17   ` Amit Daniel Kachhap
2012-03-19  6:17 ` [PATCH V2 2/6] thermal: Add generic cpufreq cooling implementation Amit Daniel Kachhap
2012-03-19  6:29   ` [lm-sensors] " Amit Daniel Kachhap
2012-03-19  6:17   ` Amit Daniel Kachhap
2012-03-19  6:17 ` [PATCH V2 3/6] thermal: Add generic cpuhotplug " Amit Daniel Kachhap
2012-03-19  6:29   ` [lm-sensors] " Amit Daniel Kachhap
2012-03-19  6:17   ` Amit Daniel Kachhap
2012-03-19 11:45   ` Srivatsa S. Bhat [this message]
2012-03-19 11:57     ` [lm-sensors] " Srivatsa S. Bhat
2012-03-19 11:45     ` Srivatsa S. Bhat
2012-03-20  6:06     ` Amit Kachhap
2012-03-20  6:18       ` [lm-sensors] " Amit Kachhap
2012-03-19  6:17 ` [PATCH V2 4/6] hwmon: exynos4: Move thermal sensor driver to driver/thermal directory Amit Daniel Kachhap
2012-03-19  6:29   ` [lm-sensors] " Amit Daniel Kachhap
2012-03-19  6:17   ` Amit Daniel Kachhap
2012-03-19  6:17 ` [PATCH V2 5/6] thermal: exynos4: Register the tmu sensor with the kernel thermal layer Amit Daniel Kachhap
2012-03-19  6:29   ` [lm-sensors] " Amit Daniel Kachhap
2012-03-19  6:17   ` Amit Daniel Kachhap
2012-03-19  6:17 ` [PATCH V2 6/6] ARM: exynos4: Add thermal sensor driver platform device support Amit Daniel Kachhap
2012-03-19  6:29   ` [lm-sensors] " Amit Daniel Kachhap
2012-03-19  6:17   ` Amit Daniel Kachhap
2012-04-04  4:32 ` [PATCH V2 0/6] thermal: exynos: Add kernel thermal support for exynos platform Amit Kachhap
2012-04-04  4:44   ` [lm-sensors] " Amit Kachhap
2012-04-04  4:32   ` Amit Kachhap
2012-04-10  0:58   ` Zhang Rui
2012-04-10  0:58     ` Zhang Rui
2012-04-10  0:58     ` [lm-sensors] " Zhang Rui
2012-04-11 12:47     ` Amit Kachhap
2012-04-11 12:59       ` [lm-sensors] " Amit Kachhap
2012-04-11 12:47       ` Amit Kachhap
2012-04-16  2:07       ` Zhang Rui
2012-04-16  2:07         ` Zhang Rui
2012-04-16  2:07         ` [lm-sensors] " Zhang Rui
2012-04-24 13:24         ` Amit Kachhap
2012-04-24 13:36           ` [lm-sensors] " Amit Kachhap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F671C64.5020803@linux.vnet.ibm.com \
    --to=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=amit.kachhap@linaro.org \
    --cc=linaro-dev@lists.linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    --cc=patches@linaro.org \
    --cc=paulmck@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.