Message ID | 20221119225650.1044591-2-alobakin@pm.me |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp896998wrr; Sat, 19 Nov 2022 15:05:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf7y6PlqrFAB51lQW+NNG5tCiGXOrlrP33YZxL6Nuf7aFDXZOTgao4wiKC814IYkN7ASIJ0x X-Received: by 2002:a63:f503:0:b0:470:4acb:1eb with SMTP id w3-20020a63f503000000b004704acb01ebmr11959782pgh.440.1668899132564; Sat, 19 Nov 2022 15:05:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668899132; cv=none; d=google.com; s=arc-20160816; b=nDEAJRWiEeQG/bSbFrlHelA4NsqNmQvTutRWHlBKI408l6f4bLKWOerMdsYmDEtrcV WQ/xzHLzN/K4D43xCk4HdP5r5Srp68nlnuhPzSfe7AFWREFyAXx/Piw6yvfb+aDcJahK 775MYW5Xi/ih+/kpmLXQrhnCIWfSq1xkmkDmRdKVK4j3A1erdDj5+NeB4P8q9FOT45om zLu1pPkIjcyo4MNe9JwUq8sXioKu1Q/Zu5+j/PSeP7zMBEo2hgYn7uCnmfmbtujlDHSv FSnyQ4y+ds1sDHb0AZAY49U8509fD2a0dYKUQ5JAENTzmi+vvvV4RAnk/GbYhbTC/kFG oZ7A== 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 :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :dkim-signature:date; bh=2+sOxC40kt2h/1Sz9kRo5GxpGnAXAGHbxk3TUs+fmSg=; b=mj1ehwsrWzL7HU83QJ0VYuFrIzA5Q1Fth5+bwENvc5Yp/nFhd/bUwqnacRAPizOHKf XnU19oyJMZJ6+AR+68NadBqlqHFK4KfASjsDj1oc3isUCc+Pgwvb6SrNTC8zVCGwzDA7 Nc/RFldEG8EUxW6CvmMJu72uiYMdpkxUv/WkhFARWT3Ejof4OO3PBqXE4eNfrKDrUnDy WXUFFdgKwgd1Mwnc1Lt7BArNI3btbUNNk5g4n4WzIvz+3PsMfSt9HRXnNLE/2KkbLkxS T6XPXJeqZ5BGqSGj2gAuTokIf6L8vxdVQZhrkLnAsa3gehljYb1DTq97lhibzgE2tTkN vDPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail3 header.b=jAjIY4B0; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m8-20020a056a00080800b0056d89d8fba7si8356031pfk.154.2022.11.19.15.05.20; Sat, 19 Nov 2022 15:05:32 -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; dkim=pass header.i=@pm.me header.s=protonmail3 header.b=jAjIY4B0; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234739AbiKSXEb (ORCPT <rfc822;zhanghuayu.dev@gmail.com> + 99 others); Sat, 19 Nov 2022 18:04:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234728AbiKSXE3 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 19 Nov 2022 18:04:29 -0500 Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE78E13D59; Sat, 19 Nov 2022 15:04:27 -0800 (PST) Date: Sat, 19 Nov 2022 23:04:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1668899066; x=1669158266; bh=2+sOxC40kt2h/1Sz9kRo5GxpGnAXAGHbxk3TUs+fmSg=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=jAjIY4B0YN1LB7N8qwiwUWlFcsxMt9pRvkXj5uAappI40qAbxYMLRmBS/xbgf6UFg 8GP/4XFuSAiyX34JLKshx8QtDxyhLcwSg8dsUeAKR5DfHzJODZFz1SS7SFpqQWSE92 kQkHtGjvsLiAqMdChUFKvytUa2fSL2QHtyEw3OxIuXIZ6zn3iVDmoDx/5VThDaHwLy U5vkbtRx4Hbwa65avysoi42FPMolv/YzFlQXS86B4CWA/9FQaxRSg3BNwMEp9QINq6 E/CLZ0Sbuqy/cKsHn9Qrqq78W1vpYmSF+x1q3ltCWUp6CgeZTkZAX7neHMpso+F+82 pVYfmgihEegcw== To: linux-kbuild@vger.kernel.org From: Alexander Lobakin <alobakin@pm.me> Cc: Alexander Lobakin <alobakin@pm.me>, Masahiro Yamada <masahiroy@kernel.org>, Nicolas Schier <nicolas@fjasle.eu>, Jens Axboe <axboe@kernel.dk>, Boris Brezillon <bbrezillon@kernel.org>, Borislav Petkov <bp@alien8.de>, Tony Luck <tony.luck@intel.com>, Miquel Raynal <miquel.raynal@bootlin.com>, Vladimir Oltean <vladimir.oltean@nxp.com>, Alexandre Belloni <alexandre.belloni@bootlin.com>, Derek Chickles <dchickles@marvell.com>, Ioana Ciornei <ioana.ciornei@nxp.com>, Salil Mehta <salil.mehta@huawei.com>, Sunil Goutham <sgoutham@marvell.com>, Grygorii Strashko <grygorii.strashko@ti.com>, Daniel Scally <djrscally@gmail.com>, Hans de Goede <hdegoede@redhat.com>, Mark Brown <broonie@kernel.org>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, NXP Linux Team <linux-imx@nxp.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/18] block/rnbd: fix mixed module-builtin object Message-ID: <20221119225650.1044591-2-alobakin@pm.me> In-Reply-To: <20221119225650.1044591-1-alobakin@pm.me> References: <20221119225650.1044591-1-alobakin@pm.me> Feedback-ID: 22809121:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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?1749967576901636845?= X-GMAIL-MSGID: =?utf-8?q?1749967576901636845?= |
Series |
treewide: fix object files shared between several modules
|
|
Commit Message
Alexander Lobakin
Nov. 19, 2022, 11:04 p.m. UTC
From: Masahiro Yamada <masahiroy@kernel.org> With CONFIG_BLK_DEV_RNBD_CLIENT=m and CONFIG_BLK_DEV_RNBD_SERVER=y (or vice versa), rnbd-common.o is linked to a module and also to vmlinux even though CFLAGS are different between builtins and modules. This is the same situation as fixed by commit 637a642f5ca5 ("zstd: Fixing mixed module-builtin objects"). Turn rnbd_access_mode_str() into an inline function. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-and-tested-by: Alexander Lobakin <alobakin@pm.me> Signed-off-by: Alexander Lobakin <alobakin@pm.me> --- drivers/block/rnbd/Makefile | 6 ++---- drivers/block/rnbd/rnbd-common.c | 23 ----------------------- drivers/block/rnbd/rnbd-proto.h | 14 +++++++++++++- 3 files changed, 15 insertions(+), 28 deletions(-) delete mode 100644 drivers/block/rnbd/rnbd-common.c -- 2.38.1
Comments
On 11/19/22 5:04 PM, Alexander Lobakin wrote: > From: Masahiro Yamada <masahiroy@kernel.org> > > With CONFIG_BLK_DEV_RNBD_CLIENT=m and CONFIG_BLK_DEV_RNBD_SERVER=y > (or vice versa), rnbd-common.o is linked to a module and also to > vmlinux even though CFLAGS are different between builtins and modules. > > This is the same situation as fixed by commit 637a642f5ca5 ("zstd: > Fixing mixed module-builtin objects"). > > Turn rnbd_access_mode_str() into an inline function. > Why inline? All you should need is "static" to keep these internal to each compilation unit. Inline also bloats the object files when the function is called from multiple places. Let the compiler decide when to inline. Andrew > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > Reviewed-and-tested-by: Alexander Lobakin <alobakin@pm.me> > Signed-off-by: Alexander Lobakin <alobakin@pm.me> > --- > drivers/block/rnbd/Makefile | 6 ++---- > drivers/block/rnbd/rnbd-common.c | 23 ----------------------- > drivers/block/rnbd/rnbd-proto.h | 14 +++++++++++++- > 3 files changed, 15 insertions(+), 28 deletions(-) > delete mode 100644 drivers/block/rnbd/rnbd-common.c > > diff --git a/drivers/block/rnbd/Makefile b/drivers/block/rnbd/Makefile > index 40b31630822c..208e5f865497 100644 > --- a/drivers/block/rnbd/Makefile > +++ b/drivers/block/rnbd/Makefile > @@ -3,13 +3,11 @@ > ccflags-y := -I$(srctree)/drivers/infiniband/ulp/rtrs > > rnbd-client-y := rnbd-clt.o \ > - rnbd-clt-sysfs.o \ > - rnbd-common.o > + rnbd-clt-sysfs.o > > CFLAGS_rnbd-srv-trace.o = -I$(src) > > -rnbd-server-y := rnbd-common.o \ > - rnbd-srv.o \ > +rnbd-server-y := rnbd-srv.o \ > rnbd-srv-sysfs.o \ > rnbd-srv-trace.o > > diff --git a/drivers/block/rnbd/rnbd-common.c b/drivers/block/rnbd/rnbd-common.c > deleted file mode 100644 > index 596c3f732403..000000000000 > --- a/drivers/block/rnbd/rnbd-common.c > +++ /dev/null > @@ -1,23 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0-or-later > -/* > - * RDMA Network Block Driver > - * > - * Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved. > - * Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved. > - * Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved. > - */ > -#include "rnbd-proto.h" > - > -const char *rnbd_access_mode_str(enum rnbd_access_mode mode) > -{ > - switch (mode) { > - case RNBD_ACCESS_RO: > - return "ro"; > - case RNBD_ACCESS_RW: > - return "rw"; > - case RNBD_ACCESS_MIGRATION: > - return "migration"; > - default: > - return "unknown"; > - } > -} > diff --git a/drivers/block/rnbd/rnbd-proto.h b/drivers/block/rnbd/rnbd-proto.h > index ea7ac8bca63c..1849e7039fa1 100644 > --- a/drivers/block/rnbd/rnbd-proto.h > +++ b/drivers/block/rnbd/rnbd-proto.h > @@ -300,6 +300,18 @@ static inline u32 rq_to_rnbd_flags(struct request *rq) > return rnbd_opf; > } > > -const char *rnbd_access_mode_str(enum rnbd_access_mode mode); > +static inline const char *rnbd_access_mode_str(enum rnbd_access_mode mode) > +{ > + switch (mode) { > + case RNBD_ACCESS_RO: > + return "ro"; > + case RNBD_ACCESS_RW: > + return "rw"; > + case RNBD_ACCESS_MIGRATION: > + return "migration"; > + default: > + return "unknown"; > + } > +} > > #endif /* RNBD_PROTO_H */ > -- > 2.38.1 > >
On Tue, Nov 22, 2022 at 6:18 AM Andrew Davis <afd@ti.com> wrote: > > On 11/19/22 5:04 PM, Alexander Lobakin wrote: > > From: Masahiro Yamada <masahiroy@kernel.org> > > > > With CONFIG_BLK_DEV_RNBD_CLIENT=m and CONFIG_BLK_DEV_RNBD_SERVER=y > > (or vice versa), rnbd-common.o is linked to a module and also to > > vmlinux even though CFLAGS are different between builtins and modules. > > > > This is the same situation as fixed by commit 637a642f5ca5 ("zstd: > > Fixing mixed module-builtin objects"). > > > > Turn rnbd_access_mode_str() into an inline function. > > > > Why inline? All you should need is "static" to keep these internal to > each compilation unit. Inline also bloats the object files when the > function is called from multiple places. Let the compiler decide when > to inline. > > Andrew Since it is a header file. In header files, "static inline" should be always used. Never "static". If a header is included from a C file and there is a function that is not used from that C file, "static" would emit -Wunused-function warning (-Wunused-function is enabled by -Wall, which is the case for the kernel build).
On 11/21/22 11:59 PM, Masahiro Yamada wrote: > On Tue, Nov 22, 2022 at 6:18 AM Andrew Davis <afd@ti.com> wrote: >> >> On 11/19/22 5:04 PM, Alexander Lobakin wrote: >>> From: Masahiro Yamada <masahiroy@kernel.org> >>> >>> With CONFIG_BLK_DEV_RNBD_CLIENT=m and CONFIG_BLK_DEV_RNBD_SERVER=y >>> (or vice versa), rnbd-common.o is linked to a module and also to >>> vmlinux even though CFLAGS are different between builtins and modules. >>> >>> This is the same situation as fixed by commit 637a642f5ca5 ("zstd: >>> Fixing mixed module-builtin objects"). >>> >>> Turn rnbd_access_mode_str() into an inline function. >>> >> >> Why inline? All you should need is "static" to keep these internal to >> each compilation unit. Inline also bloats the object files when the >> function is called from multiple places. Let the compiler decide when >> to inline. >> >> Andrew > > > Since it is a header file. > > > In header files, "static inline" should be always used. > Never "static". > My comment was more "why"? > > If a header is included from a C file and there is a function > that is not used from that C file, > "static" would emit -Wunused-function warning > (-Wunused-function is enabled by -Wall, which is the case > for the kernel build). > > Inline still hints to the compiler to inline, causing unneeded object size bloat. Using "inline" to signal something else (that the function may be unused) when we already have a flag for that (__maybe_unused) feels wrong. Seems this was already debated way back in 2006.. So maybe not worth revisiting today, but still a cleanup that could be good to think more about later. Andrew
diff --git a/drivers/block/rnbd/Makefile b/drivers/block/rnbd/Makefile index 40b31630822c..208e5f865497 100644 --- a/drivers/block/rnbd/Makefile +++ b/drivers/block/rnbd/Makefile @@ -3,13 +3,11 @@ ccflags-y := -I$(srctree)/drivers/infiniband/ulp/rtrs rnbd-client-y := rnbd-clt.o \ - rnbd-clt-sysfs.o \ - rnbd-common.o + rnbd-clt-sysfs.o CFLAGS_rnbd-srv-trace.o = -I$(src) -rnbd-server-y := rnbd-common.o \ - rnbd-srv.o \ +rnbd-server-y := rnbd-srv.o \ rnbd-srv-sysfs.o \ rnbd-srv-trace.o diff --git a/drivers/block/rnbd/rnbd-common.c b/drivers/block/rnbd/rnbd-common.c deleted file mode 100644 index 596c3f732403..000000000000 --- a/drivers/block/rnbd/rnbd-common.c +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * RDMA Network Block Driver - * - * Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved. - * Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved. - * Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved. - */ -#include "rnbd-proto.h" - -const char *rnbd_access_mode_str(enum rnbd_access_mode mode) -{ - switch (mode) { - case RNBD_ACCESS_RO: - return "ro"; - case RNBD_ACCESS_RW: - return "rw"; - case RNBD_ACCESS_MIGRATION: - return "migration"; - default: - return "unknown"; - } -} diff --git a/drivers/block/rnbd/rnbd-proto.h b/drivers/block/rnbd/rnbd-proto.h index ea7ac8bca63c..1849e7039fa1 100644 --- a/drivers/block/rnbd/rnbd-proto.h +++ b/drivers/block/rnbd/rnbd-proto.h @@ -300,6 +300,18 @@ static inline u32 rq_to_rnbd_flags(struct request *rq) return rnbd_opf; } -const char *rnbd_access_mode_str(enum rnbd_access_mode mode); +static inline const char *rnbd_access_mode_str(enum rnbd_access_mode mode) +{ + switch (mode) { + case RNBD_ACCESS_RO: + return "ro"; + case RNBD_ACCESS_RW: + return "rw"; + case RNBD_ACCESS_MIGRATION: + return "migration"; + default: + return "unknown"; + } +} #endif /* RNBD_PROTO_H */