public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Mc Guire <der.herr@hofr.at>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Joel Fernandes <agnel.joel@gmail.com>,
	Greg Kroah-Hartman <greg@kroah.com>,
	linux-rt-users@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	kernelnewbies <kernelnewbies@nl.linux.org>,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: RFC on fixing mutex spinning on owner
Date: Thu, 17 Mar 2016 15:36:20 +0000	[thread overview]
Message-ID: <20160317153620.GA8933@osadl.at> (raw)
In-Reply-To: <alpine.DEB.2.11.1603171431490.3978@nanos>

On Thu, Mar 17, 2016 at 02:32:54PM +0100, Thomas Gleixner wrote:
> On Thu, 17 Mar 2016, Peter Zijlstra wrote:
> > On Thu, Mar 17, 2016 at 08:06:29AM -0400, Steven Rostedt wrote:
> > > On Thu, 17 Mar 2016 12:16:11 +0100 (CET)
> > > Thomas Gleixner <tglx@linutronix.de> wrote:
> > > 
> > > > On Thu, 17 Mar 2016, Peter Zijlstra wrote:
> > > > > 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.  
> > > > 
> > > > Well, that only gives you the information on a actual preemption, but not
> > > > information about long preempt disabled regions which can cause a problem
> > > > eventually.
> > > > 
> > > 
> > > Actually, I was thinking the reverse. If need_resched() is called and
> > > is false, then do a reset of the preemption time. But if need_resched()
> > > is true, then do nothing, as that would measure the total time preempt
> > > disable was set and a task could not schedule.
> > > 
> > > Question is, should this be a hook and each location audited, or add
> > > this to need_resched() itself?
> > 
> > Is anybody calling need_resched() and then not doing anything with the
> > value?
> 
> Probably not. So Stevens idea makes a lot of sense.
>

Provably not (provided I did not screw up the spec). So all need_resched
are ither in a if|while condition, an argument to a function or part of a 
return value.

<snip>
@need_resched exists@
identifier func,val;
statement S1,S2;
expression E1,E2;
position p;
@@

(
  if(<+... need_resched()@p ...+>) S1 else S2
|
  while (<+... need_resched()@p ...+>) S1
//|
//  Do while not supported in coccinelle :(
//  do { ... } while (<+... need_resched()@p ...+>);
|
  val = need_resched()@p ? E1 : E2;
|
  func(..., need_resched()@p, ...);
|
  return <+... need_resched()@p ...+>;
)

@need_resched_unused exists@
position p != need_resched.p;
@@

* need_resched()@p

@script:python@
p << need_resched_unused.p;
@@
print "need_resched() in %s line %s not used" % (p[0].file,p[0].line)
<snip> 

 except for the unhandled do{...} while(need_resched()); cases as cocci
 currently does not support do{}while(); constructs this does not report
 any unused need_resched() cases and the 5 reported findings:
need_resched() in ./include/net/busy_poll.h line 112 not used
need_resched() in ./kernel/sched/core.c line 3453 not used
need_resched() in ./kernel/sched/core.c line 3573 not used
need_resched() in ./kernel/sched/core.c line 3546 not used
need_resched() in ./kernel/sched/core.c line 3406 not used
 where manually checked and are all do{}while(need_resched()); cases.

thx!
hofrat

      reply	other threads:[~2016-03-17 16:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 23:22 RFC on fixing mutex spinning on owner Joel Fernandes
2016-03-16 23:35 ` Greg Kroah-Hartman
2016-03-16 23:38   ` Joel Fernandes
2016-03-17  2:17     ` Steven Rostedt
2016-03-17  5:35       ` Joel Fernandes
2016-03-17 12:08         ` Steven Rostedt
2016-03-17  7:36       ` Peter Zijlstra
2016-03-17  8:05         ` Nicholas Mc Guire
2016-03-17 10:18           ` Peter Zijlstra
2016-03-17 11:16             ` Thomas Gleixner
2016-03-17 12:06               ` Steven Rostedt
2016-03-17 12:13                 ` Peter Zijlstra
2016-03-17 13:32                   ` Thomas Gleixner
2016-03-17 15:36                     ` Nicholas Mc Guire [this message]

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=20160317153620.GA8933@osadl.at \
    --to=der.herr@hofr.at \
    --cc=agnel.joel@gmail.com \
    --cc=greg@kroah.com \
    --cc=kernelnewbies@nl.linux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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