From: "Dave Young" <hidave.darkstar@gmail.com>
To: "Andrew Morton" <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC] add time_after_now and other macros which compare with jiffies
Date: Fri, 7 Mar 2008 17:12:29 +0800 [thread overview]
Message-ID: <a8e1da0803070112p6a5e076aw569a50a69de91504@mail.gmail.com> (raw)
In-Reply-To: <20080307010228.de6700b5.akpm@linux-foundation.org>
On Fri, Mar 7, 2008 at 5:02 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Fri, 7 Mar 2008 11:09:01 +0800 Dave Young <hidave.darkstar@gmail.com> wrote:
>
> > Most of time_after like macros users just compare jiffies and
> > another number, so here add some other _now macros to do it.
> >
> > Another aproach is changing original time_ macros to use jiffies to compare,
> > add a generic compare macro like time_compare(a, b)
> >
> > Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
> >
> > ---
> > jiffies.h | 8 ++++++++
> > 1 file changed, 8 insertions(+)
> >
> > diff -upr linux/include/linux/jiffies.h linux.new/include/linux/jiffies.h
> > --- linux/include/linux/jiffies.h 2008-03-07 10:40:04.000000000 +0800
> > +++ linux.new/include/linux/jiffies.h 2008-03-07 10:50:12.000000000 +0800
> > @@ -134,6 +134,14 @@ static inline u64 get_jiffies_64(void)
> > ((__s64)(a) - (__s64)(b) >= 0))
> > #define time_before_eq64(a,b) time_after_eq64(b,a)
> >
> > +#define time_after_now(a) time_after(jiffies, a)
> > +
> > +#define time_before_now(a) time_before(jiffies, a)
> > +
> > +#define time_after_eq_now(a) time_after_eq(jiffies, a)
> > +
> > +#define time_before_eq_now(a) time_before_eq(jiffies, a)
> > +
> > /*
> > * Have the 32 bit jiffies value wrap 5 minutes after boot
> > * so jiffies wrap bugs show up earlier.
>
> time_after() and friends drive me nutty. I *always* have to go and look at
> the definition to make sure that people got the args the right way around.
Andrew, thanks for your patient.
>
> (does that)
>
> > * time_after(a,b) returns true if the time a is after time b.
>
> so, umm, I think you got it backwards. Your time_after_now(a) will return
> true if jiffies (ie: now) is after `a'. ie: if a is before or equal to
> "now".
>
> All this shouldn't be as hard as it is.
>
> One lesson we can learn from this: whatever we do, it needs careful
> commenting. Your change doesn't do that.
>
Indeed, I will add proper comment before them.
Thanks again.
next prev parent reply other threads:[~2008-03-07 9:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-07 3:09 [PATCH RFC] add time_after_now and other macros which compare with jiffies Dave Young
2008-03-07 9:02 ` Andrew Morton
2008-03-07 9:12 ` Dave Young [this message]
2008-03-07 9:22 ` Andrew Morton
2008-03-07 9:36 ` Dave Young
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=a8e1da0803070112p6a5e076aw569a50a69de91504@mail.gmail.com \
--to=hidave.darkstar@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.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