linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] block_sigmask() helper function
@ 2011-12-21 18:46 Matt Fleming
  2011-12-21 18:47 ` [PATCH 1/2] sparc: Make SA_NOMASK a synonym of SA_NODEFER Matt Fleming
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Matt Fleming @ 2011-12-21 18:46 UTC (permalink / raw)
  To: Andrew Morton; +Cc: David S. Miller, linux-kernel, Oleg Nesterov, Matt Fleming

From: Matt Fleming <matt.fleming@intel.com>

Hi Andrew,

Oleg doesn't have a repo on kernel.org yet and suggested that you
might take these patches through your -mm tree? Ideally I'd like to
get these two in for the 3.3 merge window because I've got a bunch of
other patches that can go through the respective maintainers' trees
once these two have been merged.

These two patches have been posted before (along with the other 40)
but I attempted to get them all merged in one go, which didn't really
work. The original thread is here,

      https://lkml.org/lkml/2011/8/19/411

Matt Fleming (2):
  sparc: Make SA_NOMASK a synonym of SA_NODEFER
  signal: Add block_sigmask() for adding sigmask to current->blocked

 arch/sparc/include/asm/signal.h |    3 ++-
 arch/x86/kernel/signal.c        |    6 +-----
 include/linux/signal.h          |    1 +
 kernel/signal.c                 |   21 +++++++++++++++++++++
 4 files changed, 25 insertions(+), 6 deletions(-)

-- 
1.7.4.4


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

* [PATCH 1/2] sparc: Make SA_NOMASK a synonym of SA_NODEFER
  2011-12-21 18:46 [PATCH 0/2] block_sigmask() helper function Matt Fleming
@ 2011-12-21 18:47 ` Matt Fleming
  2011-12-21 20:31   ` David Miller
  2011-12-22 18:02   ` Oleg Nesterov
  2011-12-21 18:47 ` [PATCH 2/2] signal: Add block_sigmask() for adding sigmask to current->blocked Matt Fleming
  2011-12-22 17:51 ` [PATCH 0/2] block_sigmask() helper function Oleg Nesterov
  2 siblings, 2 replies; 7+ messages in thread
From: Matt Fleming @ 2011-12-21 18:47 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David S. Miller, linux-kernel, Oleg Nesterov, Matt Fleming, sparclinux

From: Matt Fleming <matt.fleming@intel.com>

Unlike other architectures, sparc currently has no SA_NODEFER
definition but only the older SA_NOMASK. Since SA_NOMASK is the
historical name for SA_NODEFER, add SA_NODEFER and copy what other
architectures do by making SA_NOMASK a synonym for SA_NODEFER.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/sparc/include/asm/signal.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/sparc/include/asm/signal.h b/arch/sparc/include/asm/signal.h
index e49b828..aa42fe3 100644
--- a/arch/sparc/include/asm/signal.h
+++ b/arch/sparc/include/asm/signal.h
@@ -143,10 +143,11 @@ struct sigstack {
 #define SA_ONSTACK	_SV_SSTACK
 #define SA_RESTART	_SV_INTR
 #define SA_ONESHOT	_SV_RESET
-#define SA_NOMASK	0x20u
+#define SA_NODEFER	0x20u
 #define SA_NOCLDWAIT    0x100u
 #define SA_SIGINFO      0x200u
 
+#define SA_NOMASK	SA_NODEFER
 
 #define SIG_BLOCK          0x01	/* for blocking signals */
 #define SIG_UNBLOCK        0x02	/* for unblocking signals */
-- 
1.7.4.4


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

* [PATCH 2/2] signal: Add block_sigmask() for adding sigmask to current->blocked
  2011-12-21 18:46 [PATCH 0/2] block_sigmask() helper function Matt Fleming
  2011-12-21 18:47 ` [PATCH 1/2] sparc: Make SA_NOMASK a synonym of SA_NODEFER Matt Fleming
@ 2011-12-21 18:47 ` Matt Fleming
  2011-12-22 17:52   ` Oleg Nesterov
  2011-12-22 17:51 ` [PATCH 0/2] block_sigmask() helper function Oleg Nesterov
  2 siblings, 1 reply; 7+ messages in thread
From: Matt Fleming @ 2011-12-21 18:47 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David S. Miller, linux-kernel, Oleg Nesterov, Matt Fleming,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tejun Heo

From: Matt Fleming <matt.fleming@intel.com>

This patch abstracts the code sequence for adding a signal handler's
sa_mask to current->blocked because the sequence is identical for all
architectures. Furthermore, in the past some architectures actually
got this code wrong, so introduce a wrapper that all architectures can
use.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/x86/kernel/signal.c |    6 +-----
 include/linux/signal.h   |    1 +
 kernel/signal.c          |   21 +++++++++++++++++++++
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 54ddaeb2..46a01bd 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -682,7 +682,6 @@ static int
 handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
 		struct pt_regs *regs)
 {
-	sigset_t blocked;
 	int ret;
 
 	/* Are we from a system call? */
@@ -733,10 +732,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
 	 */
 	regs->flags &= ~X86_EFLAGS_TF;
 
-	sigorsets(&blocked, &current->blocked, &ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&blocked, sig);
-	set_current_blocked(&blocked);
+	block_sigmask(ka, sig);
 
 	tracehook_signal_handler(sig, info, ka, regs,
 				 test_thread_flag(TIF_SINGLESTEP));
diff --git a/include/linux/signal.h b/include/linux/signal.h
index a822300..7987ce74 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -254,6 +254,7 @@ extern void set_current_blocked(const sigset_t *);
 extern int show_unhandled_signals;
 
 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
+extern void block_sigmask(struct k_sigaction *ka, int signr);
 extern void exit_signals(struct task_struct *tsk);
 
 extern struct kmem_cache *sighand_cachep;
diff --git a/kernel/signal.c b/kernel/signal.c
index b3f78d0..22b6667 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2322,6 +2322,27 @@ relock:
 	return signr;
 }
 
+/**
+ * block_sigmask - add @ka's signal mask to current->blocked
+ * @ka: action for @signr
+ * @signr: signal that has been successfully delivered
+ *
+ * This function should be called when a signal has succesfully been
+ * delivered. It adds the mask of signals for @ka to current->blocked
+ * so that they are blocked during the execution of the signal
+ * handler. In addition, @signr will be blocked unless %SA_NODEFER is
+ * set in @ka->sa.sa_flags.
+ */
+void block_sigmask(struct k_sigaction *ka, int signr)
+{
+	sigset_t blocked;
+
+	sigorsets(&blocked, &current->blocked, &ka->sa.sa_mask);
+	if (!(ka->sa.sa_flags & SA_NODEFER))
+		sigaddset(&blocked, signr);
+	set_current_blocked(&blocked);
+}
+
 /*
  * It could be that complete_signal() picked us to notify about the
  * group-wide signal. Other threads should be notified now to take
-- 
1.7.4.4


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

* Re: [PATCH 1/2] sparc: Make SA_NOMASK a synonym of SA_NODEFER
  2011-12-21 18:47 ` [PATCH 1/2] sparc: Make SA_NOMASK a synonym of SA_NODEFER Matt Fleming
@ 2011-12-21 20:31   ` David Miller
  2011-12-22 18:02   ` Oleg Nesterov
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2011-12-21 20:31 UTC (permalink / raw)
  To: matt; +Cc: akpm, linux-kernel, oleg, matt.fleming, sparclinux

From: Matt Fleming <matt@console-pimps.org>
Date: Wed, 21 Dec 2011 18:47:00 +0000

> From: Matt Fleming <matt.fleming@intel.com>
> 
> Unlike other architectures, sparc currently has no SA_NODEFER
> definition but only the older SA_NOMASK. Since SA_NOMASK is the
> historical name for SA_NODEFER, add SA_NODEFER and copy what other
> architectures do by making SA_NOMASK a synonym for SA_NODEFER.
> 
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: sparclinux@vger.kernel.org
> Signed-off-by: Matt Fleming <matt.fleming@intel.com>

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [PATCH 0/2] block_sigmask() helper function
  2011-12-21 18:46 [PATCH 0/2] block_sigmask() helper function Matt Fleming
  2011-12-21 18:47 ` [PATCH 1/2] sparc: Make SA_NOMASK a synonym of SA_NODEFER Matt Fleming
  2011-12-21 18:47 ` [PATCH 2/2] signal: Add block_sigmask() for adding sigmask to current->blocked Matt Fleming
@ 2011-12-22 17:51 ` Oleg Nesterov
  2 siblings, 0 replies; 7+ messages in thread
From: Oleg Nesterov @ 2011-12-22 17:51 UTC (permalink / raw)
  To: Matt Fleming; +Cc: Andrew Morton, David S. Miller, linux-kernel, Matt Fleming

On 12/21, Matt Fleming wrote:
>
> Hi Andrew,
>
> Oleg doesn't have a repo on kernel.org yet and suggested that you
> might take these patches through your -mm tree?

Yes, could you take this please? I have no idea when I will restore
my korg account. If ever :/

> Ideally I'd like to
> get these two in for the 3.3 merge window because I've got a bunch of
> other patches that can go through the respective maintainers' trees
> once these two have been merged.

I was surpised by how many bugs there are in arch/ signal code, this
patch helps to factor out the code in the signal-deliver paths.

Oleg.


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

* Re: [PATCH 2/2] signal: Add block_sigmask() for adding sigmask to current->blocked
  2011-12-21 18:47 ` [PATCH 2/2] signal: Add block_sigmask() for adding sigmask to current->blocked Matt Fleming
@ 2011-12-22 17:52   ` Oleg Nesterov
  0 siblings, 0 replies; 7+ messages in thread
From: Oleg Nesterov @ 2011-12-22 17:52 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Andrew Morton, David S. Miller, linux-kernel, Matt Fleming,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tejun Heo

On 12/21, Matt Fleming wrote:
>
> From: Matt Fleming <matt.fleming@intel.com>
>
> This patch abstracts the code sequence for adding a signal handler's
> sa_mask to current->blocked because the sequence is identical for all
> architectures. Furthermore, in the past some architectures actually
> got this code wrong, so introduce a wrapper that all architectures can
> use.
>
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Matt Fleming <matt.fleming@intel.com>

Signed-off-by: Oleg Nesterov <oleg@redhat.com>


> ---
>  arch/x86/kernel/signal.c |    6 +-----
>  include/linux/signal.h   |    1 +
>  kernel/signal.c          |   21 +++++++++++++++++++++
>  3 files changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
> index 54ddaeb2..46a01bd 100644
> --- a/arch/x86/kernel/signal.c
> +++ b/arch/x86/kernel/signal.c
> @@ -682,7 +682,6 @@ static int
>  handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
>  		struct pt_regs *regs)
>  {
> -	sigset_t blocked;
>  	int ret;
>
>  	/* Are we from a system call? */
> @@ -733,10 +732,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
>  	 */
>  	regs->flags &= ~X86_EFLAGS_TF;
>
> -	sigorsets(&blocked, &current->blocked, &ka->sa.sa_mask);
> -	if (!(ka->sa.sa_flags & SA_NODEFER))
> -		sigaddset(&blocked, sig);
> -	set_current_blocked(&blocked);
> +	block_sigmask(ka, sig);
>
>  	tracehook_signal_handler(sig, info, ka, regs,
>  				 test_thread_flag(TIF_SINGLESTEP));
> diff --git a/include/linux/signal.h b/include/linux/signal.h
> index a822300..7987ce74 100644
> --- a/include/linux/signal.h
> +++ b/include/linux/signal.h
> @@ -254,6 +254,7 @@ extern void set_current_blocked(const sigset_t *);
>  extern int show_unhandled_signals;
>
>  extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
> +extern void block_sigmask(struct k_sigaction *ka, int signr);
>  extern void exit_signals(struct task_struct *tsk);
>
>  extern struct kmem_cache *sighand_cachep;
> diff --git a/kernel/signal.c b/kernel/signal.c
> index b3f78d0..22b6667 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -2322,6 +2322,27 @@ relock:
>  	return signr;
>  }
>
> +/**
> + * block_sigmask - add @ka's signal mask to current->blocked
> + * @ka: action for @signr
> + * @signr: signal that has been successfully delivered
> + *
> + * This function should be called when a signal has succesfully been
> + * delivered. It adds the mask of signals for @ka to current->blocked
> + * so that they are blocked during the execution of the signal
> + * handler. In addition, @signr will be blocked unless %SA_NODEFER is
> + * set in @ka->sa.sa_flags.
> + */
> +void block_sigmask(struct k_sigaction *ka, int signr)
> +{
> +	sigset_t blocked;
> +
> +	sigorsets(&blocked, &current->blocked, &ka->sa.sa_mask);
> +	if (!(ka->sa.sa_flags & SA_NODEFER))
> +		sigaddset(&blocked, signr);
> +	set_current_blocked(&blocked);
> +}
> +
>  /*
>   * It could be that complete_signal() picked us to notify about the
>   * group-wide signal. Other threads should be notified now to take
> --
> 1.7.4.4
>


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

* Re: [PATCH 1/2] sparc: Make SA_NOMASK a synonym of SA_NODEFER
  2011-12-21 18:47 ` [PATCH 1/2] sparc: Make SA_NOMASK a synonym of SA_NODEFER Matt Fleming
  2011-12-21 20:31   ` David Miller
@ 2011-12-22 18:02   ` Oleg Nesterov
  1 sibling, 0 replies; 7+ messages in thread
From: Oleg Nesterov @ 2011-12-22 18:02 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Andrew Morton, David S. Miller, linux-kernel, Matt Fleming, sparclinux

On 12/21, Matt Fleming wrote:
>
> Unlike other architectures, sparc currently has no SA_NODEFER
> definition but only the older SA_NOMASK. Since SA_NOMASK is the
> historical name for SA_NODEFER, add SA_NODEFER and copy what other
> architectures do by making SA_NOMASK a synonym for SA_NODEFER.

Without this patch arch/sparc can't use the new helper from 2/2

Acked-by: Oleg Nesterov <oleg@redhat.com>

> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: sparclinux@vger.kernel.org
> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
> ---
>  arch/sparc/include/asm/signal.h |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/sparc/include/asm/signal.h b/arch/sparc/include/asm/signal.h
> index e49b828..aa42fe3 100644
> --- a/arch/sparc/include/asm/signal.h
> +++ b/arch/sparc/include/asm/signal.h
> @@ -143,10 +143,11 @@ struct sigstack {
>  #define SA_ONSTACK	_SV_SSTACK
>  #define SA_RESTART	_SV_INTR
>  #define SA_ONESHOT	_SV_RESET
> -#define SA_NOMASK	0x20u
> +#define SA_NODEFER	0x20u
>  #define SA_NOCLDWAIT    0x100u
>  #define SA_SIGINFO      0x200u
>  
> +#define SA_NOMASK	SA_NODEFER
>  
>  #define SIG_BLOCK          0x01	/* for blocking signals */
>  #define SIG_UNBLOCK        0x02	/* for unblocking signals */
> -- 
> 1.7.4.4
> 


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

end of thread, other threads:[~2011-12-22 18:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-21 18:46 [PATCH 0/2] block_sigmask() helper function Matt Fleming
2011-12-21 18:47 ` [PATCH 1/2] sparc: Make SA_NOMASK a synonym of SA_NODEFER Matt Fleming
2011-12-21 20:31   ` David Miller
2011-12-22 18:02   ` Oleg Nesterov
2011-12-21 18:47 ` [PATCH 2/2] signal: Add block_sigmask() for adding sigmask to current->blocked Matt Fleming
2011-12-22 17:52   ` Oleg Nesterov
2011-12-22 17:51 ` [PATCH 0/2] block_sigmask() helper function Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).