From patchwork Thu Jun 2 07:26:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 9149395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 79D7F60467 for ; Thu, 2 Jun 2016 07:26:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AE0820499 for ; Thu, 2 Jun 2016 07:26:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EBE82654B; Thu, 2 Jun 2016 07:26:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9EA720499 for ; Thu, 2 Jun 2016 07:26:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750938AbcFBH0f (ORCPT ); Thu, 2 Jun 2016 03:26:35 -0400 Received: from mail.skyhub.de ([78.46.96.112]:54290 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751315AbcFBH0e (ORCPT ); Thu, 2 Jun 2016 03:26:34 -0400 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de Received: from mail.skyhub.de ([127.0.0.1]) by localhost (door.skyhub.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id gM7P78wvSQMj; Thu, 2 Jun 2016 09:26:32 +0200 (CEST) Received: from pd.tnic (p5DDC62FD.dip0.t-ipconnect.de [93.220.98.253]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id D0693245A97; Thu, 2 Jun 2016 09:26:31 +0200 (CEST) Received: by pd.tnic (Postfix, from userid 1000) id E40B0160612; Thu, 2 Jun 2016 09:26:19 +0200 (CEST) Date: Thu, 2 Jun 2016 09:26:19 +0200 From: Borislav Petkov To: Guenter Roeck Cc: Ingo Molnar , linux-hwmon@vger.kernel.org, X86 ML , LKML , Rui Huang , Sherry Hurwitz Subject: Re: [PATCH] hwmon: (fam15h_power) Disable preemption when reading registers Message-ID: <20160602072619.GB10803@pd.tnic> References: <1464775486-23446-1-git-send-email-bp@alien8.de> <574EE1B3.9010704@roeck-us.net> <20160601134126.GB22373@pd.tnic> <20160601181509.GB10954@roeck-us.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160601181509.GB10954@roeck-us.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, Jun 01, 2016 at 11:15:09AM -0700, Guenter Roeck wrote: > It would be great if you can add at least part of the BUG message as well > as a Fixes: tag into the patch description. How's that: --- From: Borislav Petkov Date: Wed, 1 Jun 2016 11:36:13 +0200 Subject: [PATCH] hwmon: (fam15h_power) Disable preemption when reading registers We need to read a bunch of registers on each compute unit and possibly on the current CPU too. Disable preemption around it. Otherwise, you get: BUG: using smp_processor_id() in preemptible [00000000] code: systemd-udevd/327 caller is read_registers+0x6a/0x110 [fam15h_power] CPU: 3 PID: 327 Comm: systemd-udevd Not tainted 4.7.0-rc1+ #4 Hardware name: HP HP EliteBook 745 G3/807E, BIOS N73 Ver. 01.08 01/28/2016 ... Signed-off-by: Borislav Petkov Cc: Rui Huang Cc: Sherry Hurwitz Cc: Guenter Roeck Fixes: fa7943449943 ("hwmon: (fam15h_power) Add compute unit accumulated power") --- drivers/hwmon/fam15h_power.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c index eb97a9241d17..69bb810f528b 100644 --- a/drivers/hwmon/fam15h_power.c +++ b/drivers/hwmon/fam15h_power.c @@ -172,9 +172,9 @@ static void do_read_registers_on_cu(void *_data) */ static int read_registers(struct fam15h_power_data *data) { - int this_cpu, ret, cpu; int core, this_core; cpumask_var_t mask; + int ret, cpu; ret = zalloc_cpumask_var(&mask, GFP_KERNEL); if (!ret) @@ -183,7 +183,6 @@ static int read_registers(struct fam15h_power_data *data) memset(data->cu_on, 0, sizeof(int) * MAX_CUS); get_online_cpus(); - this_cpu = smp_processor_id(); /* * Choose the first online core of each compute unit, and then @@ -205,10 +204,13 @@ static int read_registers(struct fam15h_power_data *data) cpumask_set_cpu(cpumask_any(topology_sibling_cpumask(cpu)), mask); } - if (cpumask_test_cpu(this_cpu, mask)) + preempt_disable(); + smp_call_function_many(mask, do_read_registers_on_cu, data, true); + + if (cpumask_test_cpu(smp_processor_id(), mask)) do_read_registers_on_cu(data); - smp_call_function_many(mask, do_read_registers_on_cu, data, true); + preempt_enable(); put_online_cpus(); free_cpumask_var(mask);