From: Oleg Nesterov <oleg@redhat.com>
To: yury.norov@gmail.com, rth@twiddle.net, ink@jurassic.park.msu.ru,
akpm@linux-foundation.org, davem@davemloft.net
Cc: klimov.linux@gmail.com, linux-kernel@vger.kernel.org,
linux-alpha@vger.kernel.org, linux-mips@linux-mips.org,
sparclinux@vger.kernel.org
Subject: Re: [PATCH] signal: optimize 'sigaction' call path
Date: Tue, 7 Apr 2015 12:06:54 +0200 [thread overview]
Message-ID: <20150407100654.GA32743@redhat.com> (raw)
> There is a set of syscalls in the kernel about 'sigaction'.
> All they end up with calling the helper 'do_sigaction',
> so the generic scheme is:
>
> - copy user data to kernel;
> - 'do_sigaction';
> - copy kernel data to user.
>
> 'do_sigaction' checks 'signum' parameter before doing its main job.
> If this check fails syscall fails immediately, as well. But at this
> stage first copy is already done. And so there's a potential chance
> having it useless. It may affect performance significantly if user
> data was, say, swapped, and a fault was handled to obtain it.
Only if the signal number is wrong? So why do we care?
> In this patch, 'signum' sanity check is moved out of 'do_sigaction'
> to a small function 'user_signal'. So we can call it before any copying.
...
> arch/alpha/kernel/signal.c | 19 +++++++-------
> arch/mips/kernel/signal.c | 10 +++++---
> arch/mips/kernel/signal32.c | 10 +++++---
> arch/sparc/kernel/sys_sparc32.c | 10 ++++----
> arch/sparc/kernel/sys_sparc_32.c | 10 ++++----
> arch/sparc/kernel/sys_sparc_64.c | 10 ++++----
> include/linux/sched.h | 2 +-
> include/linux/signal.h | 5 ++++
> kernel/signal.c | 54 +++++++++++++++++++++-------------------
> 9 files changed, 71 insertions(+), 59 deletions(-)
And this blows the source and compiled code. Not too much, but this
change should be justified somehow.
And to me this patch doesn't look like a cleanup, imho this sanity
check makes more sense in one place.
Oleg.
WARNING: multiple messages have this Message-ID (diff)
From: Oleg Nesterov <oleg@redhat.com>
To: yury.norov@gmail.com, rth@twiddle.net, ink@jurassic.park.msu.ru,
akpm@linux-foundation.org, davem@davemloft.net
Cc: klimov.linux@gmail.com, linux-kernel@vger.kernel.org,
linux-alpha@vger.kernel.org, linux-mips@linux-mips.org,
sparclinux@vger.kernel.org
Subject: Re: [PATCH] signal: optimize 'sigaction' call path
Date: Tue, 07 Apr 2015 10:06:54 +0000 [thread overview]
Message-ID: <20150407100654.GA32743@redhat.com> (raw)
In-Reply-To: <1428146533-2208-1-git-send-email-yury.norov@gmail.com>
> There is a set of syscalls in the kernel about 'sigaction'.
> All they end up with calling the helper 'do_sigaction',
> so the generic scheme is:
>
> - copy user data to kernel;
> - 'do_sigaction';
> - copy kernel data to user.
>
> 'do_sigaction' checks 'signum' parameter before doing its main job.
> If this check fails syscall fails immediately, as well. But at this
> stage first copy is already done. And so there's a potential chance
> having it useless. It may affect performance significantly if user
> data was, say, swapped, and a fault was handled to obtain it.
Only if the signal number is wrong? So why do we care?
> In this patch, 'signum' sanity check is moved out of 'do_sigaction'
> to a small function 'user_signal'. So we can call it before any copying.
...
> arch/alpha/kernel/signal.c | 19 +++++++-------
> arch/mips/kernel/signal.c | 10 +++++---
> arch/mips/kernel/signal32.c | 10 +++++---
> arch/sparc/kernel/sys_sparc32.c | 10 ++++----
> arch/sparc/kernel/sys_sparc_32.c | 10 ++++----
> arch/sparc/kernel/sys_sparc_64.c | 10 ++++----
> include/linux/sched.h | 2 +-
> include/linux/signal.h | 5 ++++
> kernel/signal.c | 54 +++++++++++++++++++++-------------------
> 9 files changed, 71 insertions(+), 59 deletions(-)
And this blows the source and compiled code. Not too much, but this
change should be justified somehow.
And to me this patch doesn't look like a cleanup, imho this sanity
check makes more sense in one place.
Oleg.
next reply other threads:[~2015-04-07 10:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-07 10:06 Oleg Nesterov [this message]
2015-04-07 10:06 ` [PATCH] signal: optimize 'sigaction' call path Oleg Nesterov
-- strict thread matches above, loose matches on Subject: below --
2015-04-04 11:22 Yury Norov
2015-04-04 11:22 ` Yury Norov
2015-04-04 11:52 ` Richard Weinberger
2015-04-04 11:52 ` Richard Weinberger
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=20150407100654.GA32743@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=ink@jurassic.park.msu.ru \
--cc=klimov.linux@gmail.com \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=rth@twiddle.net \
--cc=sparclinux@vger.kernel.org \
--cc=yury.norov@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.