From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Jani Nikula <jani.nikula@intel.com>, linux-kernel@vger.kernel.org
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
intel-gfx@lists.freedesktop.org,
Vishal Kulkarni <vishal@chelsio.com>,
netdev@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH v2] lib/string-choice: add yesno(), onoff(), enableddisabled(), plural() helpers
Date: Mon, 30 Sep 2019 16:31:02 +0200 [thread overview]
Message-ID: <8e697984-03b5-44f3-304e-42d303724eaa@rasmusvillemoes.dk> (raw)
In-Reply-To: <20190930141842.15075-1-jani.nikula@intel.com>
On 30/09/2019 16.18, Jani Nikula wrote:
> The kernel has plenty of ternary operators to choose between constant
> strings, such as condition ? "yes" : "no", as well as value == 1 ? "" :
> "s":
>
>
> ---
>
> v2: add string-choice.[ch] to not clutter kernel.h and to actually save
> space on string constants.
>
> +EXPORT_SYMBOL(enableddisabled);
> +
> +const char *plural(long v)
> +{
> + return v == 1 ? "" : "s";
> +}
> +EXPORT_SYMBOL(plural);
>
Say what? I'll bet you a beer that this is a net loss: You're adding
hundreds of bytes of export symbol overhead, plus forcing gcc to emit
actual calls at the call sites, with all the register saving/restoring
that implies.
Please just do this as static inlines. As I said, the linker is
perfectly capable of merging string literals across translation units
(but of course not between vmlinux and modules), so any built-in code
that uses those helpers (or open-codes them, doesn't matter) will
automatically share those literals.
Rasmus
next prev parent reply other threads:[~2019-09-30 14:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-30 14:18 [PATCH v2] lib/string-choice: add yesno(), onoff(), enableddisabled(), plural() helpers Jani Nikula
2019-09-30 14:31 ` Rasmus Villemoes [this message]
2019-10-01 8:07 ` [PATCH v3] string-choice: " Jani Nikula
2019-10-01 9:38 ` Greg Kroah-Hartman
2019-10-01 9:42 ` Jani Nikula
2019-10-01 9:59 ` Greg Kroah-Hartman
2019-10-01 10:17 ` [Intel-gfx] " Jani Nikula
2019-10-02 10:11 ` Jani Nikula
2019-10-02 11:00 ` Rasmus Villemoes
2019-10-04 9:09 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8e697984-03b5-44f3-304e-42d303724eaa@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=akpm@linux-foundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=julia.lawall@lip6.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=vishal@chelsio.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).