From: Oleg Nesterov <oleg@redhat.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Denys Vlasenko <dvlasenk@redhat.com>,
Eric Wong <normalperson@yhbt.net>,
Jason Baron <jbaron@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] signals: eventpoll: set ->saved_sigmask at the start
Date: Wed, 26 Jun 2013 18:48:39 +0200 [thread overview]
Message-ID: <20130626164839.GA4552@redhat.com> (raw)
In-Reply-To: <20130625204447.GA17001@redhat.com>
On 06/25, Oleg Nesterov wrote:
>
> But if we remove this WARN_ON() we can probably change
> set_restore_sigmask() to set TS_RESTORE_SIGMASK and
> do saved_mask = blocked.
>
> Perhaps it can even acccept "sigset_t *newmask" and do
> set_current_blocked().
So, Al, what do you think if we do something like
--- x/arch/x86/include/asm/thread_info.h
+++ x/arch/x86/include/asm/thread_info.h
@@ -247,7 +247,6 @@ static inline void set_restore_sigmask(v
{
struct thread_info *ti = current_thread_info();
ti->status |= TS_RESTORE_SIGMASK;
- WARN_ON(!test_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags));
}
static inline void clear_restore_sigmask(void)
{
--- x/include/linux/signal.h
+++ x/include/linux/signal.h
@@ -249,6 +249,13 @@ extern void __set_current_blocked(const
extern int show_unhandled_signals;
extern int sigsuspend(sigset_t *);
+static inline set_restore_xxx(sigset_t *mask)
+{
+ set_restore_sigmask();
+ current->saved_sigmask = current->blocked;
+ set_current_blocked(mask);
+}
+
struct sigaction {
#ifndef __ARCH_HAS_IRIX_SIGACTION
__sighandler_t sa_handler;
Then sys_epoll_pwait() (and other users) can simply do
SYSCALL_DEFINE6(epoll_pwait, int, epfd, struct epoll_event __user *, events,
int, maxevents, int, timeout, const sigset_t __user *, sigmask,
size_t, sigsetsize)
{
int error;
/*
* If the caller wants a certain signal mask to be set during the wait,
* we apply it here.
*/
if (sigmask) {
sigset_t ksigmask;
if (sigsetsize != sizeof(sigset_t))
return -EINVAL;
if (copy_from_user(&ksigmask, sigmask, sizeof(ksigmask)))
return -EFAULT;
set_restore_xxx(&ksigmask);
}
error = sys_epoll_wait(epfd, events, maxevents, timeout);
if (error != -EINTR)
restore_saved_sigmask();
return error;
}
Hmm... and when I re-read your original email I am starting to think
that perhaps you proposed exactly this...
But I still think it would be better to do this change on top of the
cleanups I sent (fs/compat.c and fs/select.c should be updated too).
But, perhaps, it also makes sense to add
void restore_saved_sigmask_if(bool cond)
{
if (cond)
restore_saved_sigmask();
else
WARN_ON(TS_RESTORE_SIGMASK && !TIF_SIGPENDING);
}
so that epoll_pwait() could do
restore_saved_sigmask_if(error != -EINTR);
What do you think?
Oleg.
prev parent reply other threads:[~2013-06-26 16:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-25 19:57 [PATCH 0/2] signals: eventpoll: save/restore_sigmask cleanups Oleg Nesterov
2013-06-25 19:57 ` [PATCH 1/2] signals: eventpoll: do not use sigprocmask() Oleg Nesterov
2013-06-25 19:57 ` [PATCH 2/2] signals: eventpoll: set ->saved_sigmask at the start Oleg Nesterov
2013-06-25 20:23 ` Al Viro
2013-06-25 20:32 ` Oleg Nesterov
2013-06-25 20:44 ` Oleg Nesterov
2013-06-26 16:48 ` Oleg Nesterov [this message]
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=20130626164839.GA4552@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dvlasenk@redhat.com \
--cc=jbaron@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=normalperson@yhbt.net \
--cc=viro@ZenIV.linux.org.uk \
/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