[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1446585565.6440.45.camel@Odin.com>
Date: Tue, 3 Nov 2015 21:19:26 +0000
From: James Bottomley <jbottomley@...n.com>
To: "linux@...musvillemoes.dk" <linux@...musvillemoes.dk>
CC: "ulf.hansson@...aro.org" <ulf.hansson@...aro.org>,
"keescook@...omium.org" <keescook@...omium.org>,
"andriy.shevchenko@...ux.intel.com"
<andriy.shevchenko@...ux.intel.com>,
"vkuznets@...hat.com" <vkuznets@...hat.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>
Subject: Re: [PATCH v3 1/4] lib/string_helpers: change blk_size to u32 for
string_get_size() interface
On Tue, 2015-11-03 at 21:57 +0100, Rasmus Villemoes wrote:
> On Tue, Nov 03 2015, James Bottomley <jbottomley@...n.com> wrote:
>
> >
> > It was a suggestion when I explained what the missing sources of
> > precision were, I don't think it's really a suggestion when it comes
> > with an exemplary patch.
>
> ex·em·pla·ry
> adjective
>
> 1.
> serving as a desirable model; representing the best of its kind.
>
> Said exemplary patch produces "1.10 KiB" for size=2047,
> blk_size=1. (This is caused by the introduction of rounding, and is
> probably fixable.)
>
> James, I do understand the algorithm you're trying to use. What I don't
> understand is why you insist on using the approach of reducing size and
> blk_size all the way before multiplying them. It seems much simpler to
> just reduce them till they're below U32_MAX (not keeping track of any
> remainders at that point), multiply them, and then proceed as usual,
> This avoids having to deal with weird cross-multiplication terms, gives
> more accurate results (yes, I tested that) and avoids the extra 64/32
> division you introduce by decrementing i.
Well, wood and trees, I think. I don't believe there's any more
accuracy with the second order term, but it is a lot simpler for anyone
to understand. I'll post a v2.
James
Powered by blists - more mailing lists