mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Nicolas Pitre <npitre@baylibre.com>
Cc: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mul_u64_u64_div_u64: make it precise always
Date: Fri, 28 Jun 2024 15:15:55 -0700	[thread overview]
Message-ID: <20240628151555.93232b84d1135ad96066471d@linux-foundation.org> (raw)
In-Reply-To: <9nr61164-o95o-s47s-33sq-ss86499p6sso@onlyvoer.pbz>

On Fri, 28 Jun 2024 17:46:33 -0400 (EDT) Nicolas Pitre <npitre@baylibre.com> wrote:

> On Fri, 28 Jun 2024, Andrew Morton wrote:
> 
> > On Fri, 28 Jun 2024 15:06:20 -0400 (EDT) Nicolas Pitre <npitre@baylibre.com> wrote:
> > 
> > > Library facilities must always return exact results. If the caller may
> > > be contented with approximations then it should do the approximation on
> > > its own.
> > > 
> > > In this particular case the comment in the code says "the algorithm
> > > ... might lose some precision". Well, if you try it with e.g.:
> > > 
> > > 	a = 18446462598732840960
> > > 	b = 18446462598732840960
> > > 	c = 18446462598732840961
> > > 
> > > then the produced answer is 0 whereas the exact answer should be
> > > 18446462598732840959. This is _some_ precision loss indeed!
> > > 
> > > Let's reimplement this function so it always produces the exact result
> > > regardless of its inputs while preserving existing fast paths
> > > when possible.
> > 
> > I assume this was tested with some userspace harness?  It would be
> > interesting to see that so that reviewers can see that suitable cases
> > have been covered.
> 
> I do have a user space test tool but it isn't pretty looking.
> How should this be acceptably presented for public consumption?

Well, the fancy way would be as a new lib/test_XXX.c.  There's a ton of
precedent for that.  A less fancy way would be to paste the code into
this email thread ;)


      reply	other threads:[~2024-06-28 22:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-28 19:06 Nicolas Pitre
2024-06-28 21:20 ` Andrew Morton
2024-06-28 21:46   ` Nicolas Pitre
2024-06-28 22:15     ` Andrew Morton [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=20240628151555.93232b84d1135ad96066471d@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npitre@baylibre.com \
    --cc=u.kleine-koenig@baylibre.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

all inboxes | Powered by JetHome®