From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: Borislav Petkov <bp@alien8.de>
Cc: tony.luck@intel.com, tglx@linutronix.de, mingo@redhat.com,
hpa@zytor.com, x86@kernel.org, linux-edac@vger.kernel.org,
linux-kernel@vger.kernel.org,
Chris Wilson <chris@chris-wilson.co.uk>
Subject: Re: [PATCH] x86/mce/therm_throt: Handle case where throttle_active_work() is called on behalf of an offline CPU
Date: Sat, 22 Feb 2020 16:25:59 -0800 [thread overview]
Message-ID: <40989625ca5496a986ca3e595957da83723777f4.camel@linux.intel.com> (raw)
In-Reply-To: <20200222175151.GD11284@zn.tnic>
On Sat, 2020-02-22 at 18:51 +0100, Borislav Petkov wrote:
> On Sat, Feb 22, 2020 at 08:24:32AM -0800, Srinivas Pandruvada wrote:
> > During cpu-hotplug test with CONFIG_PREEMPTION and
> > CONFIG_DEBUG_PREEMPT
> > enabled, Chris reported error:
> >
> > BUG: using smp_processor_id() in preemptible [00000000] code:
> > kworker/1:0/17
> > caller is throttle_active_work+0x12/0x280
> >
> > Here throttle_active_work() is a work queue callback scheduled with
> > schedule_delayed_work_on(). This will not cause this error for the
> > use
> > of smp_processor_id() under normal conditions as there is a check
> > for
> > "current->nr_cpus_allowed == 1".
> > But when the target CPU is offline the workqueue becomes unbound.
> > Then the work queue callback can be scheduled on another CPU and
> > the
> > error is printed for the use of smp_processor_id() in preemptible
> > context.
>
> So what's wrong with simply doing:
>
> if (cpu_is_offline(this_cpu))
> return;
>
> ?
>
If the condition is false, will it prevent offline CPU before executing
next statement and reschedule on another CPU? Although It will not
cause any error or crash but in rare circumstance may print premature
warning/normal message based on the current CPU's state.
So I can submit something like this:
diff --git a/arch/x86/kernel/cpu/mce/therm_throt.c
b/arch/x86/kernel/cpu/mce/therm_throt.c
index b38010b541d6..7aa7c9d1df2a 100644
--- a/arch/x86/kernel/cpu/mce/therm_throt.c
+++ b/arch/x86/kernel/cpu/mce/therm_throt.c
@@ -239,11 +239,14 @@ static void throttle_active_work(struct
work_struct *work)
{
struct _thermal_state *state =
container_of(to_delayed_work(work),
struct _thermal_state,
therm_work);
- unsigned int i, avg, this_cpu = smp_processor_id();
+ unsigned int i, avg, this_cpu = state->cpu;
u64 now = get_jiffies_64();
bool hot;
u8 temp;
+ if (cpu_is_offline(this_cpu))
+ return;
+
get_therm_status(state->level, &hot, &temp);
/* temperature value is offset from the max so lesser means
hotter */
if (!hot && temp > state->baseline_temp) {
Thanks,
Srinivas
> You don't need to run the callback on an offlined CPU anyway...
>
next prev parent reply other threads:[~2020-02-23 0:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-22 16:24 [PATCH] x86/mce/therm_throt: Handle case where throttle_active_work() is called on behalf of an offline CPU Srinivas Pandruvada
2020-02-22 16:53 ` Chris Wilson
2020-02-22 17:51 ` Borislav Petkov
2020-02-23 0:25 ` Srinivas Pandruvada [this message]
2020-02-24 12:55 ` Borislav Petkov
2020-02-24 16:01 ` Thomas Gleixner
2020-02-24 19:25 ` Thomas Gleixner
2020-02-24 21:05 ` Pandruvada, Srinivas
2020-02-25 9:46 ` Srinivas Pandruvada
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=40989625ca5496a986ca3e595957da83723777f4.camel@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=bp@alien8.de \
--cc=chris@chris-wilson.co.uk \
--cc=hpa@zytor.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox