From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753431AbcLMMYW (ORCPT ); Tue, 13 Dec 2016 07:24:22 -0500 Received: from 92-243-34-74.adsl.nanet.at ([92.243.34.74]:50388 "EHLO mail.osadl.at" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752747AbcLMMYU (ORCPT ); Tue, 13 Dec 2016 07:24:20 -0500 Date: Tue, 13 Dec 2016 12:24:11 +0000 From: Nicholas Mc Guire To: Julia Lawall Cc: Jani Nikula , Nicholas Mc Guire , Thomas Gleixner , Jonathan Corbet , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Dan Carpenter Subject: Re: [PATCH] doc: add note on usleep_range range Message-ID: <20161213122411.GA7866@osadl.at> References: <1481601523-14004-1-git-send-email-hofrat@osadl.org> <87r35ctcrp.fsf@intel.com> <20161213091912.GA6347@osadl.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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