public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Mc Guire <der.herr@hofr.at>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Jani Nikula <jani.nikula@linux.intel.com>,
	Nicholas Mc Guire <hofrat@osadl.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH] doc: add note on usleep_range range
Date: Tue, 13 Dec 2016 12:24:11 +0000	[thread overview]
Message-ID: <20161213122411.GA7866@osadl.at> (raw)
In-Reply-To: <alpine.DEB.2.10.1612131304520.3207@hadrien>

On Tue, Dec 13, 2016 at 01:05:12PM +0100, Julia Lawall wrote:
> 
> 
> On Tue, 13 Dec 2016, Nicholas Mc Guire wrote:
> 
> > On Tue, Dec 13, 2016 at 11:10:50AM +0200, Jani Nikula wrote:
> > > On Tue, 13 Dec 2016, Nicholas Mc Guire <hofrat@osadl.org> wrote:
> > > > useleep_range() with a delta of 0 makes no sense and only prevents the
> > > > timer subsystem from optimizing interrupts. As any user of usleep_range()
> > > > is in non-atomic context the timer jitter is in the range of 10s of
> > > > microseconds anyway.
> > > >
> > > > This adds a note making it clear that a range of 0 is a bad idea.
> > >
> > > So I don't really have anything to do with the timer subsystem, I'm just
> > > their "consumer", so take this with a grain of salt.
> > >
> > > Documentation is good, but I don't think this will be enough.
> > >
> > > I think the only thing that will work is to detect and complain about
> > > things like this automatically. Some ideas:
> > >
> > > * WARN_ON(min == max) or WARN_ON_ONCE(min == max) in usleep_range()
> > >   might be drastic, but it would get the job done eventually.
> > >
> > > * If you want to avoid the runtime overhead (and complaints about the
> > >   backtraces), you could wrap usleep_range() in a macro that does
> > >   BUILD_BUG_ON(min == max) if the parameters are build time constants
> > >   (they usually are). But you'd have to fix all the problem cases first.
> > >
> > > * You could try (to persuade Julia or Dan) to come up with a
> > >   cocci/smatch check for usleep_range() calls where min == max, so we
> > >   could get bug reports for this. This probably works on expressions, so
> > >   this would catch also cases where the parameters aren't built time
> > >   constants.
> > >
> >
> > I fully agree - without automation it is almost usless
> > the coccinelle spatch is a seperate patch and it is tested butnot yet
> > submitted.
> >
> > the spatch for this iss actually trivial
> >
> > @nulldelta@
> > constant C;
> > position p;
> > @@
> >
> > * usleep_range@p(C,C)
> 
> People never use more complex expressions?
>
well yes 
@nulldelta@
expression E;
position p;
@@

* usleep_range@p(E,E)

but that seems to be it.
and the vast majority is simply constants

thx!
hofrat 

  reply	other threads:[~2016-12-13 12:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-13  3:58 [PATCH] doc: add note on usleep_range range Nicholas Mc Guire
2016-12-13  9:10 ` Jani Nikula
2016-12-13  9:19   ` Nicholas Mc Guire
2016-12-13 10:18     ` Jani Nikula
2016-12-13 12:05     ` Julia Lawall
2016-12-13 12:24       ` Nicholas Mc Guire [this message]
2016-12-14  0:27     ` Joe Perches
2016-12-14  0:37       ` Nicholas Mc Guire
2016-12-14  6:10         ` Joe Perches
2016-12-27 21:56 ` Pavel Machek
2017-01-07 19:41   ` Nicholas Mc Guire
2017-01-10 21:25     ` Pavel Machek
2017-01-11  8:50       ` Nicholas Mc Guire
2017-01-12 10:32         ` Pavel Machek

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=20161213122411.GA7866@osadl.at \
    --to=der.herr@hofr.at \
    --cc=corbet@lwn.net \
    --cc=dan.carpenter@oracle.com \
    --cc=hofrat@osadl.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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