From: Al Viro <viro@zeniv.linux.org.uk>
To: David Laight <David.Laight@aculab.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH] seq_file: Optimize seq_puts()
Date: Wed, 17 Apr 2024 02:04:30 +0100 [thread overview]
Message-ID: <20240417010430.GB2118490@ZenIV> (raw)
In-Reply-To: <ba306b2a1b5743bab79b3ebb04ece4df@AcuMS.aculab.com>
On Tue, Apr 16, 2024 at 08:56:51PM +0000, David Laight wrote:
> > static inline void seq_puts(struct seq_file *m, const char *s)
>
> That probably needs to be 'always_inline'.
What for? If compiler fails to inline it (and I'd be very surprised
if that happened - if s is not a constant string, we get a straight call
of __seq_puts() and for constant strings it boils down to call of
seq_putc(m, constant) or seq_write(m, s, constant)), nothing bad
would happen; we'd still get correct behaviour.
> > {
> > if (!__builtin_constant_p(*s))
> > __seq_puts(m, s);
> > else if (s[0] && !s[1])
> > seq_putc(m, s[0]);
> > else
> > seq_write(m, s, __builtin_strlen(s));
> > }
>
> You missed seq_puts(m, "");
Where have you seen one? And if it gets less than optimal, who cares?
> Could you do:
> size_t len = __builtin_strlen(s);
> if (!__builtin_constant_p(len))
> __seq_puts(m, s);
> else switch (len){
> case 0: break;
> case 1: seq_putc(m, s[0]);
> default: seq_write(m, s, len);
> }
Umm... That's probably OK, but I wonder how useful would that
be...
next prev parent reply other threads:[~2024-04-17 1:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-04 13:29 [PATCH] seq_file: Optimize seq_puts() Christophe JAILLET
2024-04-15 20:47 ` Christophe JAILLET
2024-04-15 21:00 ` Al Viro
2024-04-16 20:56 ` David Laight
2024-04-17 1:04 ` Al Viro [this message]
2024-04-19 18:59 ` Christophe JAILLET
2024-04-19 20:38 ` Christophe JAILLET
2024-04-19 21:32 ` Al Viro
2024-04-21 17:21 ` David Laight
2024-04-17 7:53 ` Rasmus Villemoes
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=20240417010430.GB2118490@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=David.Laight@aculab.com \
--cc=brauner@kernel.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=jack@suse.cz \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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).