lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <86920c17-13a7-4cc3-8603-ab6d757fef56@wanadoo.fr>
Date: Fri, 19 Apr 2024 20:59:20 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Al Viro <viro@...iv.linux.org.uk>, David Laight <David.Laight@...lab.com>
Cc: Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
 "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
 "kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>,
 "linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>
Subject: Re: [PATCH] seq_file: Optimize seq_puts()

Le 17/04/2024 à 03:04, Al Viro a écrit :
> 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?

Based on results from:
    git grep seq_puts.*\"\"

there is no such cases.


>  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]);

missing break;

>> 	default: seq_write(m, s, len);
>> 	}
> 
> Umm...  That's probably OK, but I wonder how useful would that
> be...
> 

Thanks all for your feedback.

I'll send a v2.

CJ

> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ