Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1596303

Re: [PATCH] clock: Fix smp_processor_id() in preemptible bug

From "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH] clock: Fix smp_processor_id() in preemptible bug
Date 2017-03-09 19:40 +0100
Message-ID <tjb8J-yF-5@gated-at.bofh.it> (permalink)
References <tiRMJ-3Y7-11@gated-at.bofh.it> <tj8aR-71c-9@gated-at.bofh.it> <tj8kx-76H-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Mar 09, 2017 at 07:31:14AM -0800, Paul E. McKenney wrote:
> On Thu, Mar 09, 2017 at 04:24:20PM +0100, Peter Zijlstra wrote:
> > On Wed, Mar 08, 2017 at 01:53:06PM -0800, Paul E. McKenney wrote:
> > > The v4.11-rc1 kernel emits the following splat in some configurations:
> > > 
> > > [   43.681891] BUG: using smp_processor_id() in preemptible [00000000] code: kworker/3:1/49
> > > [   43.682511] caller is debug_smp_processor_id+0x17/0x20
> > > [   43.682893] CPU: 0 PID: 49 Comm: kworker/3:1 Not tainted 4.11.0-rc1+ #1
> > > [   43.683382] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> > > [   43.683497] Workqueue: events __clear_sched_clock_stable
> > > [   43.683497] Call Trace:
> > > [   43.683497]  dump_stack+0x4f/0x69
> > > [   43.683497]  check_preemption_disabled+0xd9/0xf0
> > > [   43.683497]  debug_smp_processor_id+0x17/0x20
> > > [   43.683497]  __clear_sched_clock_stable+0x11/0x60
> > > [   43.683497]  process_one_work+0x146/0x430
> > > [   43.683497]  worker_thread+0x126/0x490
> > > [   43.683497]  kthread+0xfc/0x130
> > > [   43.683497]  ? process_one_work+0x430/0x430
> > > [   43.683497]  ? kthread_create_on_node+0x40/0x40
> > > [   43.683497]  ? umh_complete+0x30/0x30
> > > [   43.683497]  ? call_usermodehelper_exec_async+0x12a/0x130
> > > [   43.683497]  ret_from_fork+0x29/0x40
> > > [   43.689244] sched_clock: Marking unstable (43688244724, 179505618)<-(43867750342, 0)
> > > 
> > > This happens because workqueue handlers run with preemption enabled
> > > by default and the new this_scd() function accesses per-CPU variables.
> > > This commit therefore disables preemption across this call to this_scd()
> > > and to the uses of the pointer that it returns.  Lightly tested
> > > successfully on x86.
> > 
> > Does this also work?
> 
> Thank you!  I will give it a shot after the other tests complete.

And it does pass light testing.  I will hammer it harder this evening.

So please send a formal patch!

							Thanx, Paul

> > ---
> >  kernel/sched/clock.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c
> > index a08795e21628..c63042253b65 100644
> > --- a/kernel/sched/clock.c
> > +++ b/kernel/sched/clock.c
> > @@ -173,7 +173,7 @@ void clear_sched_clock_stable(void)
> >  	smp_mb(); /* matches sched_clock_init_late() */
> > 
> >  	if (sched_clock_running == 2)
> > -		schedule_work(&sched_clock_work);
> > +		schedule_work_on(smp_processor_id(), &sched_clock_work);
> >  }
> > 
> >  void sched_clock_init_late(void)
> > 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] clock: Fix smp_processor_id() in preemptible bug "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-03-08 23:00 +0100
  Re: [PATCH] clock: Fix smp_processor_id() in preemptible bug Peter Zijlstra <peterz@infradead.org> - 2017-03-09 16:30 +0100
    Re: [PATCH] clock: Fix smp_processor_id() in preemptible bug "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-03-09 16:40 +0100
      Re: [PATCH] clock: Fix smp_processor_id() in preemptible bug "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-03-09 19:40 +0100
        Re: [PATCH] clock: Fix smp_processor_id() in preemptible bug "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-03-10 18:30 +0100
        Re: [PATCH] clock: Fix smp_processor_id() in preemptible bug Peter Zijlstra <peterz@infradead.org> - 2017-03-13 13:50 +0100
          Re: [PATCH] clock: Fix smp_processor_id() in preemptible bug "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-03-13 17:00 +0100

csiph-web