lkml.org 
[lkml]   [2022]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] kernel: Optimize unused integer return values
On Wed, 27 Apr 2022 at 09:36, Li kunyu <kunyu@nfschina.com> wrote:
>
> Optimize unused integer return values

What is this optimizing?

Stylistically the current versions are consistent, and if in future
post_copy_siginfo_from_user32()'s implementation is changed to return
more than 0, it is easy to do.

Code-generation wise, this is de-optimizing and making code slower! In
particular, with what you've done the compiler can no longer tail-call
the functions. https://godbolt.org/z/j68MhjdzT

> Signed-off-by: Li kunyu <kunyu@nfschina.com>
> ---
> kernel/signal.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/signal.c b/kernel/signal.c
> index 30cd1ca43bcd..ae58a966c8de 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -3464,7 +3464,7 @@ int __copy_siginfo_to_user32(struct compat_siginfo __user *to,
> return 0;
> }
>
> -static int post_copy_siginfo_from_user32(kernel_siginfo_t *to,
> +static void post_copy_siginfo_from_user32(kernel_siginfo_t *to,
> const struct compat_siginfo *from)
> {
> clear_siginfo(to);
> @@ -3548,7 +3548,8 @@ static int __copy_siginfo_from_user32(int signo, struct kernel_siginfo *to,
> return -EFAULT;
>
> from.si_signo = signo;
> - return post_copy_siginfo_from_user32(to, &from);
> + post_copy_siginfo_from_user32(to, &from);
> + return 0;
> }
>
> int copy_siginfo_from_user32(struct kernel_siginfo *to,
> @@ -3559,7 +3560,8 @@ int copy_siginfo_from_user32(struct kernel_siginfo *to,
> if (copy_from_user(&from, ufrom, sizeof(struct compat_siginfo)))
> return -EFAULT;
>
> - return post_copy_siginfo_from_user32(to, &from);
> + post_copy_siginfo_from_user32(to, &from);
> + return 0;
> }
> #endif /* CONFIG_COMPAT */
>
> --
> 2.18.2
>

\
 
 \ /
  Last update: 2022-04-27 09:49    [W:3.210 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site