mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] vsprintf: uninline simple_strntoull(), reorder arguments
       [not found] <82a2af6e-9b6c-4a09-89d7-ca90cc1cdad1@p183>
@ 2023-10-30  8:59 ` Andy Shevchenko
  2023-11-01 16:48 ` Petr Mladek
  1 sibling, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2023-10-30  8:59 UTC (permalink / raw)
  To: Alexey Dobriyan
  Cc: Petr Mladek, Steven Rostedt, Rasmus Villemoes,
	Sergey Senozhatsky, linux-kernel

On Fri, Oct 27, 2023 at 05:13:58PM +0300, Alexey Dobriyan wrote:
> * uninline simple_strntoull(),
>   gcc overinlines and this function is not performance critical
> 
> * reorder arguments, so that appending INT_MAX as 4th argument
>   generates very efficient tail call
> 
> Space savings:
> 
> 	add/remove: 1/0 grow/shrink: 0/3 up/down: 27/-179 (-152)
> 	Function                            old     new   delta
> 	simple_strntoll                       -      27     +27
> 	simple_strtoull                      15      10      -5
> 	simple_strtoll                       41       7     -34
> 	vsscanf                            1930    1790    -140


Makes sense to me
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

...

>  		if (is_sign)
> -			val.s = simple_strntoll(str,
> -						field_width >= 0 ? field_width : INT_MAX,
> -						&next, base);
> +			val.s = simple_strntoll(str, &next, base,
> +						field_width >= 0 ? field_width : INT_MAX);
>  		else
> -			val.u = simple_strntoull(str,
> -						 field_width >= 0 ? field_width : INT_MAX,
> -						 &next, base);
> +			val.u = simple_strntoull(str, &next, base,
> +						 field_width >= 0 ? field_width : INT_MAX);

Looking at these, why do we even care about signedness? field_witdh IIRC is 16-bit or less
and if size_t is to big it's still fine. No?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] vsprintf: uninline simple_strntoull(), reorder arguments
       [not found] <82a2af6e-9b6c-4a09-89d7-ca90cc1cdad1@p183>
  2023-10-30  8:59 ` [PATCH] vsprintf: uninline simple_strntoull(), reorder arguments Andy Shevchenko
@ 2023-11-01 16:48 ` Petr Mladek
  1 sibling, 0 replies; 2+ messages in thread
From: Petr Mladek @ 2023-11-01 16:48 UTC (permalink / raw)
  To: Alexey Dobriyan
  Cc: Steven Rostedt, Andy Shevchenko, Rasmus Villemoes,
	Sergey Senozhatsky, linux-kernel

On Fri 2023-10-27 17:13:58, Alexey Dobriyan wrote:
> * uninline simple_strntoull(),
>   gcc overinlines and this function is not performance critical
> 
> * reorder arguments, so that appending INT_MAX as 4th argument
>   generates very efficient tail call
> 
> Space savings:
> 
> 	add/remove: 1/0 grow/shrink: 0/3 up/down: 27/-179 (-152)
> 	Function                            old     new   delta
> 	simple_strntoll                       -      27     +27
> 	simple_strtoull                      15      10      -5
> 	simple_strtoll                       41       7     -34
> 	vsscanf                            1930    1790    -140
> 
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>

I am usually quite skeptical about these micro-optimizations. They might
help only on some architectures with some compiler versions. And
they might make it worse for others.

Well, I could imagine that passing constant via the last parameter
might help in most cases. And the new ordering of the parameters
is fine. So let's get it in.

Reviewed-by: Petr Mladek <pmladek@suse.com>

I have just pushed the patch into printk/linux.git, branch for-6.7.

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-01 16:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <82a2af6e-9b6c-4a09-89d7-ca90cc1cdad1@p183>
2023-10-30  8:59 ` [PATCH] vsprintf: uninline simple_strntoull(), reorder arguments Andy Shevchenko
2023-11-01 16:48 ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®