From: Ian Kent <raven@themaw.net>
To: Julia Lawall <julia@diku.dk>
Cc: "H. Peter Anvin" <hpa@zytor.com>, Ray Lee <ray-lk@madrabbit.org>,
autofs@linux.kernel.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [autofs] [PATCH 1/4] fs/autofs: Use time_before, time_before_eq, etc.
Date: Fri, 28 Dec 2007 13:34:10 +0900 [thread overview]
Message-ID: <1198816450.3089.24.camel@raven.themaw.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0712270805370.6952@ask.diku.dk>
On Thu, 2007-12-27 at 08:08 +0100, Julia Lawall wrote:
> On Wed, 26 Dec 2007, H. Peter Anvin wrote:
>
> > Ray Lee wrote:
> > > On Dec 26, 2007 7:21 AM, Julia Lawall <julia@diku.dk> wrote:
> > > > - if (jiffies - ent->last_usage < timeout)
> > > > + if (time_before(jiffies, ent->last_usage + timeout))
> > >
> > > I don't think this is a safe change? subtraction is always safe (if
> > > you think about it as 'distance'), addition isn't always safe unless
> > > you know the range. The time_before macro will expand that out to
> > > (effectively):
I don't see how subtraction is any different in this case as that could
just as easily underflow leading to the same issue.
> > >
> > > if ( (long)(ent->last_usage + timeout) - (long)(jiffies) < 0 )
> > >
> > > which seems to introduce an overflow condition in the first term.
> > >
> > > Dunno, I may be wrong (happens often), but at the very least what
> > > you've transformed it into is no longer obviously correct, and so it's
> > > not a great change.
> >
> > Indeed. The bottom form will have overflow issues at time
> > jiffies_wraparound/2, whereas the top form will have overflow issues only near
> > jiffies_wraparound/1.
>
> OK, so it seems like it is not such a good idea.
>
> There are, however, over 200 files that contain calls to the various time
> functions that follow this pattern, eg:
>
> arch/arm/kernel/ecard.c:563
> if (!last || time_after(jiffies, last + 5*HZ)) {
Including autofs4.
>
> Perhaps they should be coverted to use a subtraction as well?
Thinking about the cases involved always makes my head ache.
Ian
next prev parent reply other threads:[~2007-12-28 5:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-26 15:21 Julia Lawall
2007-12-26 17:48 ` H. Peter Anvin
2007-12-26 19:19 ` Julia Lawall
2007-12-26 19:58 ` Ray Lee
2007-12-26 20:45 ` H. Peter Anvin
2007-12-27 7:08 ` Julia Lawall
2007-12-28 1:39 ` YOSHIFUJI Hideaki / 吉藤英明
2007-12-28 4:34 ` Ian Kent [this message]
2007-12-28 9:27 ` Julia Lawall
2007-12-28 14:21 ` [autofs] " Fabio Olive Leite
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=1198816450.3089.24.camel@raven.themaw.net \
--to=raven@themaw.net \
--cc=autofs@linux.kernel.org \
--cc=hpa@zytor.com \
--cc=julia@diku.dk \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ray-lk@madrabbit.org \
/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
all inboxes | Powered by JetHome®