public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Ben Woodard <bwoodard@llnl.gov>,
	Brian Behlendorf <behlendorf1@llnl.gov>,
	Jeremy Fitzhardinge <jeremy@goop.org>,
	Mark Grondona <mgrondona@llnl.gov>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] trivial, document that div64_u64() is not precise on 32bit platforms
Date: Tue, 3 Aug 2010 15:28:12 -0700	[thread overview]
Message-ID: <20100803152812.210439dc.akpm@linux-foundation.org> (raw)
In-Reply-To: <20100802160951.GA13385@redhat.com>

On Mon, 2 Aug 2010 18:09:51 +0200
Oleg Nesterov <oleg@redhat.com> wrote:

> We have a bugreport which blames div64_u64() on 32bit platforms.
> 
> However, the code obviously doesn't even try to pretend it can do
> the 64bit division precisely. If there is something in the high
> word of divisor, div64_u64() just shifts both arguments and throws
> out the low bits.
> 
> Add a small comment to avoid the confusion.
> 
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> ---
> 
>  lib/div64.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> --- a/lib/div64.c
> +++ b/lib/div64.c
> @@ -77,7 +77,10 @@ s64 div_s64_rem(s64 dividend, s32 diviso
>  EXPORT_SYMBOL(div_s64_rem);
>  #endif
>  
> -/* 64bit divisor, dividend and result. dynamic precision */
> +/*
> + * 64bit divisor, dividend and result. Dynamic precision, unless
> + * divisor fits in u32 result is not exactly correct.
> + */
>  #ifndef div64_u64
>  u64 div64_u64(u64 dividend, u64 divisor)
>  {

Well that was a bit lazy of us - I wonder how hard it is to fix.

At present people will test their code on 64-bit only to find out later
that it doesn't work correctly on 32-bit.  Bad.  Perhaps we should
similarly break the 64-bit version :)


  reply	other threads:[~2010-08-03 22:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-02 16:09 [PATCH] trivial, document that div64_u64() is not precise on 32bit platforms Oleg Nesterov
2010-08-03 22:28 ` Andrew Morton [this message]
2010-08-04  0:12   ` Ben Woodard
2010-08-09 16:30   ` [PATCH] Make div64_u64() " Brian Behlendorf
2010-09-17  0:00     ` Oleg Nesterov

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=20100803152812.210439dc.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=behlendorf1@llnl.gov \
    --cc=bwoodard@llnl.gov \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgrondona@llnl.gov \
    --cc=oleg@redhat.com \
    /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