Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp431614rdh; Thu, 26 Oct 2023 06:21:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpZvm78VxKTjw+jfk4rOk8jm31+6ujeiJwgJbtUu8SgOuGFSvu/Tf5tjlSfkAaXFiOQNY2 X-Received: by 2002:a05:6870:4c05:b0:1ea:2a:dc59 with SMTP id pk5-20020a0568704c0500b001ea002adc59mr23336581oab.51.1698326471113; Thu, 26 Oct 2023 06:21:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698326471; cv=none; d=google.com; s=arc-20160816; b=Uo+QBDyMUzcT5FtCFgB++bH7CSCWT4uOzRvmWgM8eK20nCnx6att0Z6EUBasRP2OiS jTWKi79VgUJ2y6F1OLJLQ/LFWewJUc5WGfChBaNJtjEC2xoePKothHpQgrarIpqIXE1y si62E8Z9GEDgQmGhSpGWypF4o1PXMR9Q2TcgUykySSau0z/tM0VMC2Jh3a6SZDaR3mfM D28T5/qebmkVO5pIvo4Db+KCcKeB7/ZDV4Ai4Kww0pPjq+9LZT7dXL1s6i5SMSLGLsje 1uWLK8wEfHMTQZAdSB4YCl0cuOlejC94OCvs34E5Vwz7sJoENXUQdGBbaAhsToRtGrta R54g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=XrC3XSxzYz4GHvHYHbhAhqiRBW/ASvj0IWyfsFTmQLA=; fh=sS0m9SSvw79k5dgAmrph9k6N5DGsSEsDbpErqzjpPks=; b=aZ7cd6DShZYQI/HAUpv3yvdBF5ZMEoRtmFDXzrwWQuitHG0Qu/6HlNDLf0DJ7YhqtC y9f2a0DVYMfWi3qC8LaUu2PhgHahD2aRV7lTB2zqRcoi/FhxWr1gqBx9OgL9mDqqEcU3 M1mck2mZWUhwld1B2YhH/lRJfICjqVt5GQAvGTHxQq1xaBo7qCTSjYGK+cSqJPlVNsn1 VskxM650bxv+/lmV+clPEAdr1CHihLKhHKh6AXKqQfBEi+CzcWP23CKoCFzF5GKL2nbJ x7kUVPodV/gI01E0I3CY68XrNU0XQEvorFyOyuEEbhn5EyNdLfl1PhFSW/SdTSJWlM/B Qscw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id v34-20020a25fc22000000b00d7c0fad6db0si14358478ybd.608.2023.10.26.06.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 06:21:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 4AE62824E793; Thu, 26 Oct 2023 06:21:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345027AbjJZNUw (ORCPT + 99 others); Thu, 26 Oct 2023 09:20:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230413AbjJZNUv (ORCPT ); Thu, 26 Oct 2023 09:20:51 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BD1BAB for ; Thu, 26 Oct 2023 06:20:49 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="366888831" X-IronPort-AV: E=Sophos;i="6.03,253,1694761200"; d="scan'208";a="366888831" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 06:12:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="709066380" X-IronPort-AV: E=Sophos;i="6.03,253,1694761200"; d="scan'208";a="709066380" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga003.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 06:12:56 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC3) (envelope-from ) id 1qw0AP-00000008rQH-0tLs; Thu, 26 Oct 2023 16:12:53 +0300 Date: Thu, 26 Oct 2023 16:12:52 +0300 From: Andy Shevchenko To: Kent Overstreet Cc: Suren Baghdasaryan , akpm@linux-foundation.org, keescook@chromium.org, rostedt@goodmis.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 01/39] lib/string_helpers: Add flags param to string_get_size() Message-ID: References: <20231024134637.3120277-1-surenb@google.com> <20231024134637.3120277-2-surenb@google.com> <20231024194653.c24qbnk6bx3hep6y@moria.home.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231024194653.c24qbnk6bx3hep6y@moria.home.lan> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 26 Oct 2023 06:21:07 -0700 (PDT) On Tue, Oct 24, 2023 at 03:46:53PM -0400, Kent Overstreet wrote: > On Tue, Oct 24, 2023 at 05:26:18PM +0300, Andy Shevchenko wrote: > > On Tue, Oct 24, 2023 at 06:45:58AM -0700, Suren Baghdasaryan wrote: ... > > > string_get_size(nblocks, queue_logical_block_size(q), > > > - STRING_UNITS_10, cap_str_10, sizeof(cap_str_10)); > > > + 0, cap_str_10, sizeof(cap_str_10)); > > > > This doesn't seem right (even if it works). We shouldn't rely on the > > implementation details. > > It's now a flags parameter: passing an empty set of flags is not > "relying on an implementation detail". 0 is the "default" flag which is definitely relies on the "implementation detail". And I think that it's better that caller will explicitly tell what they want. ... > > > -/* Descriptions of the types of units to > > > - * print in */ > > > -enum string_size_units { > > > - STRING_UNITS_10, /* use powers of 10^3 (standard SI) */ > > > - STRING_UNITS_2, /* use binary powers of 2^10 */ > > > +enum string_size_flags { > > > > So, please add UNITS_10 as it is now. It will help if anybody in the future > > wants to add, e.g., 8-base numbers. > > Octal human readable numbers? No, no one's wanted that so far and I > very much doubt anyone will want that in the future. I also in doubt, but still, the explicit is better than implicit in this case in my opinion. > > > + STRING_SIZE_BASE2 = (1 << 0), > > > + STRING_SIZE_NOSPACE = (1 << 1), > > > + STRING_SIZE_NOBYTES = (1 << 2), > > > }; ... > > > +enum string_size_units { > > > + STRING_UNITS_10, /* use powers of 10^3 (standard SI) */ > > > + STRING_UNITS_2, /* use binary powers of 2^10 */ > > > +}; > > > > And what a point now in having these? > > Minimizing the size of the diff and making it more reviewable. It's fine > as an internal implementation thing. It's not an issue to rename these all over the places as you already did that for most of the users. And minimizing diff could be done better with --histogram algorithm or so. Otherwise it is not an objective here, right? ... > > I assume you need to split this to a few patches: > > > > 1) rename parameter to be a flags without renaming the definitions (this will > > touch only string_helpers part); > > 2) do the end job by renaming it all over the drivers; > > 3) add the other flags one-by-one (each in a separate change); > > 4) use new flags where it's needed; > > No, those would not be atomic changes. In particular changing the > parameter to a flags without changing the callers - that's not how we do > things. > We're currently working towards _better_ type safety for enums, fyi. > > The new flags _could_ be a separate patch, but since it would be > touching much the same code as the previous patch I don't see the point > in splitting it. Individual flags can be discussed, objected or approved and won't affect the rest of the changes. That's why I highly recommend to reconsider splitting of this change. It would be possible to squash back if maintainer wants this, but from review perspective you are adding more burden to the reviewer's shoulders is not good. ... > > > static const char *const units_10[] = { > > > - "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" > > > + "", "k", "M", "G", "T", "P", "E", "Z", "Y" > > > }; > > > static const char *const units_2[] = { > > > - "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB" > > > + "", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi" > > > }; > > > > Ouch, instead of leaving this and actually "cutting the letter" with NO* flags, > > you did something different. > > Not sure I understand your complaint? Were you attached to the redundant > Bs? Flag means "cutting" while in the code you "adding" (doing the opposite). Why not do exactly "cutting" without touching there. Or since you mentioned changes across the all callers, make them explicitly tell that they want Bytes suffix. -- With Best Regards, Andy Shevchenko