From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753216AbbJZVs7 (ORCPT ); Mon, 26 Oct 2015 17:48:59 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:38124 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751429AbbJZVs5 (ORCPT ); Mon, 26 Oct 2015 17:48:57 -0400 From: Rasmus Villemoes To: Vitaly Kuznetsov Cc: Andrew Morton , Andy Shevchenko , Ulf Hansson , James Bottomley , Kees Cook , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] lib/string_helpers.c: don't lose precision in string_get_size() Organization: D03 References: <1445867720-25473-1-git-send-email-vkuznets@redhat.com> <1445867720-25473-3-git-send-email-vkuznets@redhat.com> X-Hashcash: 1:20:151026:ulf.hansson@linaro.org::POEEN82CKkc9B3xB:0000000000000000000000000000000000000000QYe X-Hashcash: 1:20:151026:akpm@linux-foundation.org::H/3WuTNm/4ibEQeM:000000000000000000000000000000000000044m X-Hashcash: 1:20:151026:keescook@chromium.org::JYQNi4FpFrUEak3G:00000000000000000000000000000000000000000j8B X-Hashcash: 1:20:151026:vkuznets@redhat.com::V4j3fBaQFV9Zwdjt:0000000000000000000000000000000000000000001J9K X-Hashcash: 1:20:151026:andriy.shevchenko@linux.intel.com::GK7KbytYHbAVDqz3:000000000000000000000000000016uw X-Hashcash: 1:20:151026:jbottomley@odin.com::EWsl0bgVq1AbF2nV:0000000000000000000000000000000000000000007viN X-Hashcash: 1:20:151026:linux-kernel@vger.kernel.org::iAnHn0YU9gRdvfYM:000000000000000000000000000000000KnFx Date: Mon, 26 Oct 2015 22:48:55 +0100 In-Reply-To: <1445867720-25473-3-git-send-email-vkuznets@redhat.com> (Vitaly Kuznetsov's message of "Mon, 26 Oct 2015 14:55:19 +0100") Message-ID: <8737wx712w.fsf@rasmusvillemoes.dk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org So I also played with this over the weekend, and also threw together a stupid script to check the output. I see you have more or less the same idea I used, namely to combine size and blk_size earlier. I put some code on github, https://github.com/Villemoes/get_size. All versions still fail a very simply case, size=1594323, blk_size=1, for which the correct answer is "1.52 MiB", but we get "1.51 MiB". But both your version and my two attempts seem to have the property that they are always at most one ULP (unit in the last place) too low, and never too high. ATM, my version 2 fails 70 of the 13598 test cases, while yours fail 86 (the former being a strict subset of the latter), so they're very similar. Regardless of which algorithm we go with, I have some cleanups I'd like to do, but they're mostly independent and can wait. Rasmus