Message ID | 20221220201819.1497577-1-ydroneaud@opteya.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3167146wrn; Tue, 20 Dec 2022 12:30:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXsdeOQAO7ge+tunvKp02q/ipvh3bU8zPLJmhnnk27OZWBTb5gtye3CjyX031X7fzVJMmFrq X-Received: by 2002:a17:90a:1911:b0:223:8e91:b0ee with SMTP id 17-20020a17090a191100b002238e91b0eemr16802866pjg.26.1671568243108; Tue, 20 Dec 2022 12:30:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671568243; cv=none; d=google.com; s=arc-20160816; b=0v74N1EbMDkSYO1BjQNv7W/DTjf0aqCYTHvTr1nYRvsxvAaYtMpDNQ2yS4FKqSEu2J dRSQRDnsAateJdqYb0AFMw37sBYs4djMufhFMIObRm1PK/SwXsmpQxNOXWlPVKwauiun rORM/Z7Y/BCDnv2+IXNf1wBHl0zjsR7iSy5gPaDQzwaoHVFPdgqKBQB5ZonXkEETDT34 7TfQPpQLEtzv8buezq+Bp4DdLlHoKrhlLBik19+vBpFNaL2/tPHkA7f8WcWUd1fFHec8 RrZv6s9vHh4dZVBN+M9ge6i8l+R4cYL4H5Gg6an4CptO0YfkyGVr+VZYBYXO8pEMR5I6 xK8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=FUMcfBa2XKxZZA9An8IFXz+LFmohn7F0tDiP3zdCIc4=; b=kmxdadXnsK622pWuk2nEBYfV5HjEJJe/XfBFpPYCsrdBBp4gXWGv70fWVIe4mVQZwX dtZrhLLRJX8vjcUJdaNYVFvbJTQ5a4J1WZt/ZMtcw3ffV1rSN0peJ696H9DB39tbeoFq dgX9Xqvid5nzpEXdEYq+t5CVRHp6wEAKYQvMseuDZp6rgx6cifC48/JLqyhNMXpzvq6U 0/23ePplEcRZhO3B1N5ZEDcWimd8q/uTcboYIJ++DJ3Bzq5ixNS2Iw+e+HGnoh6S0G+y Y3C4gps1AcUObgqmTtOluqjJATixMZd4o1XPdN4yimJqkBINZTXzIrBlEJDtzUfxssbb jmaw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a2-20020a17090a740200b0020d3424d919si20068369pjg.97.2022.12.20.12.30.28; Tue, 20 Dec 2022 12:30:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234297AbiLTUUc (ORCPT <rfc822;abdi.embedded@gmail.com> + 99 others); Tue, 20 Dec 2022 15:20:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234291AbiLTUUA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 20 Dec 2022 15:20:00 -0500 Received: from smtp6-g21.free.fr (smtp6-g21.free.fr [212.27.42.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B5FB1FCE2; Tue, 20 Dec 2022 12:18:34 -0800 (PST) Received: from localhost (unknown [IPv6:2a01:e35:39f2:1220:dc8b:b602:9bcd:3004]) by smtp6-g21.free.fr (Postfix) with ESMTPS id 7B28D780350; Tue, 20 Dec 2022 21:18:23 +0100 (CET) From: Yann Droneaud <ydroneaud@opteya.com> To: Tejun Heo <tj@kernel.org>, Josef Bacik <josef@toxicpanda.com>, Jens Axboe <axboe@kernel.dk> Cc: cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Yann Droneaud <ydroneaud@opteya.com> Subject: [PATCH] blk-iocost: don't make all constants unsigned long long Date: Tue, 20 Dec 2022 21:18:19 +0100 Message-Id: <20221220201819.1497577-1-ydroneaud@opteya.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752766342040495495?= X-GMAIL-MSGID: =?utf-8?q?1752766342040495495?= |
Series |
blk-iocost: don't make all constants unsigned long long
|
|
Commit Message
Yann Droneaud
Dec. 20, 2022, 8:18 p.m. UTC
My shiny new compiler (GCC 13) is reporting the following
warnings:
../block/blk-iocost.c: In function 'ioc_weight_prfill':
../block/blk-iocost.c:3035:37: warning: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'long unsigned int' [-Wformat=]
3035 | seq_printf(sf, "%s %u\n", dname, iocg->cfg_weight / WEIGHT_ONE);
| ~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| unsigned int long unsigned int
| %lu
../block/blk-iocost.c: In function 'ioc_weight_show':
../block/blk-iocost.c:3045:34: warning: format '%u' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Wformat=]
3045 | seq_printf(sf, "default %u\n", iocc->dfl_weight / WEIGHT_ONE);
| ~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| unsigned int long unsigned int
| %lu
It appears WEIGHT_ONE enum is unnecessarly unsigned long
(or unsigned long long on 32bit) because of VTIME_PER_SEC
and/or AUTOP_CYCLE_NSEC need the enum to be that large.
Addressed by lazy splitting the "catch all" anonymous
enum and placing the unsigned long long constants in
their own anonymous enums.
Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
---
block/blk-iocost.c | 8 ++++++++
1 file changed, 8 insertions(+)
Comments
On Tue, Dec 20, 2022 at 09:18:19PM +0100, Yann Droneaud <ydroneaud@opteya.com> wrote: > +enum { > /* switch iff the conditions are met for longer than this */ > AUTOP_CYCLE_NSEC = 10LLU * NSEC_PER_SEC, > +}; This looks gratuitous. What about indivudial #defines with typed literals instead of the "lazy splitting"? Regards, Michal
On Thu, Dec 22, 2022 at 02:58:55PM +0100, Michal Koutný wrote: > On Tue, Dec 20, 2022 at 09:18:19PM +0100, Yann Droneaud <ydroneaud@opteya.com> wrote: > > +enum { > > /* switch iff the conditions are met for longer than this */ > > AUTOP_CYCLE_NSEC = 10LLU * NSEC_PER_SEC, > > +}; > > This looks gratuitous. > > What about indivudial #defines with typed literals instead of the "lazy > splitting"? enums are so much better for debugging and tracing. This is a gcc caused problem where there's no other way to generate the same code between two gcc versions without splitting the enum definitions. I'm kinda baffled that this is what they chose to do but can't think of a better way to work around it. Thanks.
On Tue, Dec 20, 2022 at 09:18:19PM +0100, Yann Droneaud wrote: > My shiny new compiler (GCC 13) is reporting the following > warnings: > > ../block/blk-iocost.c: In function 'ioc_weight_prfill': > ../block/blk-iocost.c:3035:37: warning: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'long unsigned int' [-Wformat=] > 3035 | seq_printf(sf, "%s %u\n", dname, iocg->cfg_weight / WEIGHT_ONE); > | ~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | | | > | unsigned int long unsigned int > | %lu > ../block/blk-iocost.c: In function 'ioc_weight_show': > ../block/blk-iocost.c:3045:34: warning: format '%u' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Wformat=] > 3045 | seq_printf(sf, "default %u\n", iocc->dfl_weight / WEIGHT_ONE); > | ~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | | | > | unsigned int long unsigned int > | %lu > > It appears WEIGHT_ONE enum is unnecessarly unsigned long > (or unsigned long long on 32bit) because of VTIME_PER_SEC > and/or AUTOP_CYCLE_NSEC need the enum to be that large. > > Addressed by lazy splitting the "catch all" anonymous > enum and placing the unsigned long long constants in > their own anonymous enums. > > Signed-off-by: Yann Droneaud <ydroneaud@opteya.com> There's a better patch doing this which groups the enums into two groups. Let's do that instead. Thanks.
On Wed, Jan 04, 2023 at 12:15:06PM -1000, Tejun Heo wrote: > On Thu, Dec 22, 2022 at 02:58:55PM +0100, Michal Koutný wrote: > > On Tue, Dec 20, 2022 at 09:18:19PM +0100, Yann Droneaud <ydroneaud@opteya.com> wrote: > > > +enum { > > > /* switch iff the conditions are met for longer than this */ > > > AUTOP_CYCLE_NSEC = 10LLU * NSEC_PER_SEC, > > > +}; > > > > This looks gratuitous. > > > > What about indivudial #defines with typed literals instead of the "lazy > > splitting"? > > enums are so much better for debugging and tracing. This is a gcc caused > problem where there's no other way to generate the same code between two gcc > versions without splitting the enum definitions. I'm kinda baffled that this > is what they chose to do but can't think of a better way to work around it. I thought this was the other patch addressing this issue. The proposed patch is rather painful to look at. The other one splits it into two groups. Thanks.
diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 495396425bad..bb1f8522c0f1 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -232,7 +232,9 @@ enum { /* 1/64k is granular enough and can easily be handled w/ u32 */ WEIGHT_ONE = 1 << 16, +}; +enum { /* * As vtime is used to calculate the cost of each IO, it needs to * be fairly high precision. For example, it should be able to @@ -255,7 +257,9 @@ enum { VRATE_MIN = VTIME_PER_USEC * VRATE_MIN_PPM / MILLION, VRATE_CLAMP_ADJ_PCT = 4, +}; +enum { /* if IOs end up waiting for requests, issue less */ RQ_WAIT_BUSY_PCT = 5, @@ -293,10 +297,14 @@ enum { /* don't let cmds which take a very long time pin lagging for too long */ MAX_LAGGING_PERIODS = 10, +}; +enum { /* switch iff the conditions are met for longer than this */ AUTOP_CYCLE_NSEC = 10LLU * NSEC_PER_SEC, +}; +enum { /* * Count IO size in 4k pages. The 12bit shift helps keeping * size-proportional components of cost calculation in closer