introduce sig_needs_tasklist() helper
PATCH 1/1 introduce sig_needs_tasklist() helper
In my opinion this patch cleanups the code. Please say 'nack' if you think differently.
kernel/signal.c renamed from kernel/signal.c~4_SNT +4 -1
@@ -147,6 +147,9 @@ static kmem_cache_t *sigqueue_cachep;#define sig_kernel_stop (sig) \ (((sig) < SIGRTMIN) && T(sig, SIG_KERNEL_STOP_MASK)) +#define sig_needs_tasklist (sig) \ + (((sig) < SIGRTMIN) && T(sig, SIG_KERNEL_STOP_MASK | M(SIGCONT))) +#define sig_user_defined (t, signr) \ (((t)->sighand->action[(signr)-1].sa.sa_handler != SIG_DFL) && \ ((t)->sighand->action[(signr)-1].sa.sa_handler != SIG_IGN))
@@ -1202,7 +1205,7 @@ kill_proc_info(int sig, struct siginfo *struct task_struct *p;rcu_read_lock (); -if (unlikely (sig_kernel_stop (sig) || sig ==SIGCONT )) { +if (unlikely (sig_needs_tasklist (sig))) {read_lock (&tasklist_lock); acquired_tasklist_lock =1 ; }
Quoted 18 lines · Oleg Nesterov
In my opinion this patch cleanups the code. Please say 'nack' if you think differently.
Signed-off-by Oleg Nesterov <[email protected]>kernel/signal.c renamed from kernel/signal.c~4_SNT +3
-0@@ -147,6 +147,9 @@ static kmem_cache_t *sigqueue_cachep;#define sig_kernel_stop (sig) \ (((sig) < SIGRTMIN) && T(sig, SIG_KERNEL_STOP_MASK)) +#define sig_needs_tasklist (sig) \ + (((sig) < SIGRTMIN) && T(sig, SIG_KERNEL_STOP_MASK | M(SIGCONT))) +#define sig_user_defined (t, signr) \ (((t)->sighand->action[(signr)-1].sa.sa_handler != SIG_DFL) && \ ((t)->sighand->action[(signr)-1].sa.sa_handler != SIG_IGN))
kernel/signal.c kill_proc_info(int sig, struct siginfo * · line 1211
Quoted 8 lines
kernel/signal.c renamed from kernel/signal.c~4_SNT +1
-1@@ -1202,7 +1205,7 @@ kill_proc_info(int sig, struct siginfo *struct task_struct *p;rcu_read_lock (); -if (unlikely (sig_kernel_stop (sig) || sig ==SIGCONT )) { +if (unlikely (sig_needs_tasklist (sig))) {read_lock (&tasklist_lock); acquired_tasklist_lock =1 ; }
Seems to me to be an improvement, but why not also encapsulate the lock acquisition, something like:
static inline int sig_tasklist_lock(int sig)
{
if (unlikely(sig_needs_tasklist(sig)) {
read_lock(&tasklist_lock);
return 1;
}
return 0;
}
static inline void sig_tasklist_unlock(int acquired_tasklist_lock)
{
if (acquired_tasklist_lock)
read_unlock(&tasklist_lock);
}
...
rcu_read_lock();
acquired_tasklist_lock = sig_tasklist_lock(sig);
...
sig_tasklist_unlock(acquired_tasklist_lock);Seem reasonable?
Thanx, Paul
Quoted 9 lines · Paul E. McKenney
kernel/signal.c static kmem_cache_t *sigqueue_cachep; · line 152
Quoted 3 lines · Oleg Nesterov
kernel/signal.c renamed from kernel/signal.c~4_SNT +3
-0+#define sig_needs_tasklist (sig) \ + (((sig) < SIGRTMIN) && T(sig, SIG_KERNEL_STOP_MASK | M(SIGCONT))) +Seems to me to be an improvement, but why not also encapsulate the lock acquisition, something like:
Quoted 14 lines
static inline int sig_tasklist_lock(int sig)
{
if (unlikely(sig_needs_tasklist(sig)) {
read_lock(&tasklist_lock);
return 1;
}
return 0;
}
static inline void sig_tasklist_unlock(int acquired_tasklist_lock)
{
if (acquired_tasklist_lock)
read_unlock(&tasklist_lock);
}I hope we will have
#define sig_needs_tasklist(sig) (sig == SIGCONT)
really soon (I planned to submit the final bits today, but for some stupid reasons I can't do anything till weekend), so I think it's better to kill 'acquired_tasklist_lock' and just do:
void sig_tasklist_lock(sig)
{
if (sig_needs_tasklist(sig))
read_lock(&tasklist_lock);
}
void sig_tasklist_unlock(sig)
{
if (sig_needs_tasklist(sig));
read_unlock(&tasklist_lock);
}Oleg.
Quoted 34 lines · Oleg Nesterov
Quoted 9 lines · Paul E. McKenney
kernel/signal.c static kmem_cache_t *sigqueue_cachep; · line 152
Quoted 3 lines · Oleg Nesterov
kernel/signal.c renamed from kernel/signal.c~4_SNT +3
-0+#define sig_needs_tasklist (sig) \ + (((sig) < SIGRTMIN) && T(sig, SIG_KERNEL_STOP_MASK | M(SIGCONT))) +Seems to me to be an improvement, but why not also encapsulate the lock acquisition, something like:
Quoted 14 lines
static inline int sig_tasklist_lock(int sig) { if (unlikely(sig_needs_tasklist(sig)) { read_lock(&tasklist_lock); return 1; } return 0; } static inline void sig_tasklist_unlock(int acquired_tasklist_lock) { if (acquired_tasklist_lock) read_unlock(&tasklist_lock); }I hope we will have
#define sig_needs_tasklist(sig) (sig == SIGCONT)really soon (I planned to submit the final bits today, but for some stupid reasons I can't do anything till weekend), so I think it's better to kill '
acquired_tasklist_lock' and just do:
Quoted 11 lines
void sig_tasklist_lock(sig)
{
if (sig_needs_tasklist(sig))
read_lock(&tasklist_lock);
}
void sig_tasklist_unlock(sig)
{
if (sig_needs_tasklist(sig));
read_unlock(&tasklist_lock);
}Even better!
Thanx, Paul