[Maverick] [PATCH 1/1] x86, hwmon: Fix unsafe smp_processor_id() in thermal_throttle_add_dev
Tim Gardner
tim.gardner at canonical.com
Tue Sep 14 18:59:23 UTC 2010
On 09/14/2010 12:36 PM, Leann Ogasawara wrote:
> Hi All,
>
> We'd applied a set of patches in Maverick [1] to provide Package Thermal
> Status and Power Limit Notification which is a new feature for Intel's
> Sandy Bridge processor. The following patch is an upstream cherry-pick
> to resolve "BUG: using smp_processor_id() in preemptible" errors
> introduced by this patch set. Proposing for Maverick.
>
> Thanks,
> Leann
>
> [1] https://lists.ubuntu.com/archives/kernel-team/2010-August/012487.html
>
> From a2ba1e647812788c0e87965d717a54907912ceb1 Mon Sep 17 00:00:00 2001
> From: Sergey Senozhatsky<sergey.senozhatsky at gmail.com>
> Date: Fri, 20 Aug 2010 10:36:34 +0300
> Subject: [PATCH] x86, hwmon: Fix unsafe smp_processor_id() in thermal_throttle_add_dev
>
> BugLink: http://bugs.launchpad.net/bugs/601073
>
> Fix BUG: using smp_processor_id() in preemptible thermal_throttle_add_dev.
> We know the cpu number when calling thermal_throttle_add_dev, so we can
> remove smp_processor_id call in thermal_throttle_add_dev by supplying
> the cpu number as argument.
>
> This should resolve kernel bugzilla 16615/16629.
>
> Signed-off-by: Sergey Senozhatsky<sergey.senozhatsky at gmail.com>
> LKML-Reference:<20100820073634.GB5209 at swordfish.minsk.epam.com>
> Cc: Fenghua Yu<fenghua.yu at intel.com>
> Cc: Joerg Roedel<Joerg.Roedel at amd.com>
> Cc: Maciej Rutecki<maciej.rutecki at gmail.com>
> Signed-off-by: H. Peter Anvin<hpa at zytor.com>
> (cherry picked from commit 51e3c1b558b31b11bf5fc66d3c6f5adacf3573f7)
>
> Signed-off-by: Leann Ogasawara<leann.ogasawara at canonical.com>
> ---
> arch/x86/kernel/cpu/mcheck/therm_throt.c | 9 +++++----
> 1 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
> index c2a8b26..d9368ee 100644
> --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
> +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
> @@ -202,10 +202,11 @@ static int therm_throt_process(bool new_event, int event, int level)
>
> #ifdef CONFIG_SYSFS
> /* Add/Remove thermal_throttle interface for CPU device: */
> -static __cpuinit int thermal_throttle_add_dev(struct sys_device *sys_dev)
> +static __cpuinit int thermal_throttle_add_dev(struct sys_device *sys_dev,
> + unsigned int cpu)
> {
> int err;
> - struct cpuinfo_x86 *c =&cpu_data(smp_processor_id());
> + struct cpuinfo_x86 *c =&cpu_data(cpu);
>
> err = sysfs_create_group(&sys_dev->kobj,&thermal_attr_group);
> if (err)
> @@ -251,7 +252,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
> case CPU_UP_PREPARE:
> case CPU_UP_PREPARE_FROZEN:
> mutex_lock(&therm_cpu_lock);
> - err = thermal_throttle_add_dev(sys_dev);
> + err = thermal_throttle_add_dev(sys_dev, cpu);
> mutex_unlock(&therm_cpu_lock);
> WARN_ON(err);
> break;
> @@ -287,7 +288,7 @@ static __init int thermal_throttle_init_device(void)
> #endif
> /* connect live CPUs to sysfs */
> for_each_online_cpu(cpu) {
> - err = thermal_throttle_add_dev(get_cpu_sysdev(cpu));
> + err = thermal_throttle_add_dev(get_cpu_sysdev(cpu), cpu);
> WARN_ON(err);
> }
> #ifdef CONFIG_HOTPLUG_CPU
Acked-by: Tim Gardner <tim.gardner at canonical.com>
--
Tim Gardner tim.gardner at canonical.com
More information about the kernel-team
mailing list