Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932737AbbKCVTf (ORCPT ); Tue, 3 Nov 2015 16:19:35 -0500 Received: from mx2.parallels.com ([199.115.105.18]:34939 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754871AbbKCVTe (ORCPT ); Tue, 3 Nov 2015 16:19:34 -0500 From: James Bottomley To: "linux@rasmusvillemoes.dk" CC: "ulf.hansson@linaro.org" , "keescook@chromium.org" , "andriy.shevchenko@linux.intel.com" , "vkuznets@redhat.com" , "linux-kernel@vger.kernel.org" , "akpm@linux-foundation.org" Subject: Re: [PATCH v3 1/4] lib/string_helpers: change blk_size to u32 for string_get_size() interface Thread-Topic: [PATCH v3 1/4] lib/string_helpers: change blk_size to u32 for string_get_size() interface Thread-Index: AQHRFnpETWMdTgEBxkW4jHz39JrfFJ6LU8mA Date: Tue, 3 Nov 2015 21:19:26 +0000 Message-ID: <1446585565.6440.45.camel@Odin.com> References: <1446136250-11507-1-git-send-email-vkuznets@redhat.com> <1446136250-11507-2-git-send-email-vkuznets@redhat.com> <1446157677.25009.2.camel@Odin.com> <87d1vwskfu.fsf@vitty.brq.redhat.com> <1446250866.25009.54.camel@Odin.com> <87y4egpf57.fsf@vitty.brq.redhat.com> <1446522039.2189.49.camel@Odin.com> <87egg7fcpn.fsf@vitty.brq.redhat.com> <1446570148.6440.11.camel@Odin.com> <87h9l2dcn3.fsf@rasmusvillemoes.dk> In-Reply-To: <87h9l2dcn3.fsf@rasmusvillemoes.dk> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Evolution 3.12.11 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [184.11.141.41] Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id tA3LJeDQ009861 Content-Length: 1468 Lines: 34 On Tue, 2015-11-03 at 21:57 +0100, Rasmus Villemoes wrote: > On Tue, Nov 03 2015, James Bottomley 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 ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?