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


Groups > linux.kernel > #1359706

Re: RFC on fixing mutex spinning on owner

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: RFC on fixing mutex spinning on owner
Date 2016-03-17 11:20 +0100
Message-ID <rdDc6-65q-11@gated-at.bofh.it> (permalink)
References (1 earlier) <rdtcK-7ER-13@gated-at.bofh.it> <rdtcK-7ER-27@gated-at.bofh.it> <rdvHA-UH-7@gated-at.bofh.it> <rdAHg-4j7-7@gated-at.bofh.it> <rdC6m-5mE-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Mar 17, 2016 at 08:05:26AM +0000, Nicholas Mc Guire wrote:
> scanning for that patter with a quite relaxed spatch did not
> turn up more than a hand full:
> 
> @resched_spin exists@
> position p;
> @@
> 
> (
> * while@p (...) {
>           ...
>           if (need_resched() || ...)
>                   break;
>           ...
>           \(cpu_relax\|cpu_relax_lowlatency\)();
>   }
> |
> * while@p (!need_resched()) {
>           ...
>           \(cpu_relax\|cpu_relax_lowlatency\)();
>   }
> )
> 
> @script:python@
> p << resched_spin.p;
> @@
> print "%s:%s " % (p[0].file,p[0].line)                                          
> 
> 
> is this making some wrong assumptions here or is this
> really so infrequent ? 

Ah, a tool, nice! :-)

There should be one in the osq_lock, one in mutex, one in rwsem-xadd,
davidlohr was adding one to rt_mutex; and these are the one I can
remember from the top of my head.

But I would not be surprised if there are a fair few more. Also for (;;)
is a frequent loop pattern.

My biggest worry is how to not forget adding this annotation if we
create yet another instance of this. The tool could help I suppose.

Also, maybe the tracer should measure the time from need_resched()
getting true until the next preemption point, instead of the entire time
preemption was disabled. Which would avoid the entire issue altogether.

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


Thread

RFC on fixing mutex spinning on owner Joel Fernandes <agnel.joel@gmail.com> - 2016-03-17 00:30 +0100
  Re: RFC on fixing mutex spinning on owner Greg Kroah-Hartman <greg@kroah.com> - 2016-03-17 00:40 +0100
    Re: RFC on fixing mutex spinning on owner Joel Fernandes <agnel.joel@gmail.com> - 2016-03-17 00:40 +0100
      Re: RFC on fixing mutex spinning on owner Steven Rostedt <rostedt@goodmis.org> - 2016-03-17 03:20 +0100
        Re: RFC on fixing mutex spinning on owner Joel Fernandes <agnel.joel@gmail.com> - 2016-03-17 06:40 +0100
          Re: RFC on fixing mutex spinning on owner Steven Rostedt <rostedt@goodmis.org> - 2016-03-17 13:10 +0100
        Re: RFC on fixing mutex spinning on owner Peter Zijlstra <peterz@infradead.org> - 2016-03-17 08:40 +0100
          Re: RFC on fixing mutex spinning on owner Nicholas Mc Guire <der.herr@hofr.at> - 2016-03-17 10:10 +0100
            Re: RFC on fixing mutex spinning on owner Peter Zijlstra <peterz@infradead.org> - 2016-03-17 11:20 +0100
              Re: RFC on fixing mutex spinning on owner Thomas Gleixner <tglx@linutronix.de> - 2016-03-17 12:20 +0100
                Re: RFC on fixing mutex spinning on owner Steven Rostedt <rostedt@goodmis.org> - 2016-03-17 13:10 +0100
                Re: RFC on fixing mutex spinning on owner Peter Zijlstra <peterz@infradead.org> - 2016-03-17 13:20 +0100
                Re: RFC on fixing mutex spinning on owner Thomas Gleixner <tglx@linutronix.de> - 2016-03-17 14:40 +0100
                Re: RFC on fixing mutex spinning on owner Nicholas Mc Guire <der.herr@hofr.at> - 2016-03-17 17:50 +0100

csiph-web