All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ulf Samuelsson <ulf.samuelsson@ericsson.com>
To: Michal Kubecek <mkubecek@suse.cz>
Cc: <netdev@vger.kernel.org>
Subject: Re: RFC: Use of "jiffies" vs "jiffies64" in the neighbour system.
Date: Wed, 25 Mar 2015 13:35:51 +0100	[thread overview]
Message-ID: <5512ABA7.6000706@ericsson.com> (raw)
In-Reply-To: <20150325102704.GB4673@unicorn.suse.cz>

On 03/25/2015 11:27 AM, Michal Kubecek wrote:
> On Wed, Mar 25, 2015 at 11:11:45AM +0100, Ulf Samuelsson wrote:
>> If you run HZ = 1000, then jiffies will wrap around after 49,71 days.
>> This means that all time compares in the neighbour system will fail.
>>
>>  From what I can see from "jiffies,h" there is no attempt to detect
>> the wrap-around.
>>
>> #define time_after(a,b)        \
>>      (typecheck(unsigned long, a) && \
>>       typecheck(unsigned long, b) && \
>>       ((long)(b) - (long)(a) < 0))
>> #define time_before(a,b)    time_after(b,a)
>>
>> #define time_after_eq(a,b)    \
>>      (typecheck(unsigned long, a) && \
>>       typecheck(unsigned long, b) && \
>>       ((long)(a) - (long)(b) >= 0))
>> #define time_before_eq(a,b)    time_after_eq(b,a)
> I might have misunderstood you but those macros do handle the
> wrap-around. For example, with 64-bit long and a = 1,
> b = 0xffffffffffffffff, you get
>
>    ((long)(b) - (long)(a)) = (-1) - (1) = -2 < 0
>
> so that time_after(1, 0xffffffffffffffff) is true. It will give correct
> results as long as the difference is less than half of range of the
> type.
>
>                                                           Michal Kubecek
>

OK, Now I see why it works.

Best Regards,
Ulf Samuelsson

      reply	other threads:[~2015-03-25 12:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-25 10:11 RFC: Use of "jiffies" vs "jiffies64" in the neighbour system Ulf Samuelsson
2015-03-25 10:27 ` Michal Kubecek
2015-03-25 12:35   ` Ulf Samuelsson [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=5512ABA7.6000706@ericsson.com \
    --to=ulf.samuelsson@ericsson.com \
    --cc=mkubecek@suse.cz \
    --cc=netdev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.