signal: Remove task argument from dequeue_signal()

The task pointer which is handed to dequeue_signal() is always current. The
argument along with the first comment about signalfd in that function is
confusing at best. Remove it and use current internally.

Update the stale comment for dequeue_signal() while at it.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
This commit is contained in:
Thomas Gleixner 2024-06-10 18:42:33 +02:00 committed by Frederic Weisbecker
parent 566e2d8253
commit a2b80ce87a
3 changed files with 14 additions and 18 deletions

View File

@ -159,7 +159,7 @@ static ssize_t signalfd_dequeue(struct signalfd_ctx *ctx, kernel_siginfo_t *info
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
spin_lock_irq(&current->sighand->siglock); spin_lock_irq(&current->sighand->siglock);
ret = dequeue_signal(current, &ctx->sigmask, info, &type); ret = dequeue_signal(&ctx->sigmask, info, &type);
switch (ret) { switch (ret) {
case 0: case 0:
if (!nonblock) if (!nonblock)
@ -174,7 +174,7 @@ static ssize_t signalfd_dequeue(struct signalfd_ctx *ctx, kernel_siginfo_t *info
add_wait_queue(&current->sighand->signalfd_wqh, &wait); add_wait_queue(&current->sighand->signalfd_wqh, &wait);
for (;;) { for (;;) {
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
ret = dequeue_signal(current, &ctx->sigmask, info, &type); ret = dequeue_signal(&ctx->sigmask, info, &type);
if (ret != 0) if (ret != 0)
break; break;
if (signal_pending(current)) { if (signal_pending(current)) {

View File

@ -276,8 +276,7 @@ static inline void signal_set_stop_flags(struct signal_struct *sig,
extern void flush_signals(struct task_struct *); extern void flush_signals(struct task_struct *);
extern void ignore_signals(struct task_struct *); extern void ignore_signals(struct task_struct *);
extern void flush_signal_handlers(struct task_struct *, int force_default); extern void flush_signal_handlers(struct task_struct *, int force_default);
extern int dequeue_signal(struct task_struct *task, sigset_t *mask, extern int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type);
kernel_siginfo_t *info, enum pid_type *type);
static inline int kernel_dequeue_signal(void) static inline int kernel_dequeue_signal(void)
{ {
@ -287,7 +286,7 @@ static inline int kernel_dequeue_signal(void)
int ret; int ret;
spin_lock_irq(&task->sighand->siglock); spin_lock_irq(&task->sighand->siglock);
ret = dequeue_signal(task, &task->blocked, &__info, &__type); ret = dequeue_signal(&task->blocked, &__info, &__type);
spin_unlock_irq(&task->sighand->siglock); spin_unlock_irq(&task->sighand->siglock);
return ret; return ret;

View File

@ -618,20 +618,18 @@ static int __dequeue_signal(struct sigpending *pending, sigset_t *mask,
} }
/* /*
* Dequeue a signal and return the element to the caller, which is * Try to dequeue a signal. If a deliverable signal is found fill in the
* expected to free it. * caller provided siginfo and return the signal number. Otherwise return
* * 0.
* All callers have to hold the siglock.
*/ */
int dequeue_signal(struct task_struct *tsk, sigset_t *mask, int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type)
kernel_siginfo_t *info, enum pid_type *type)
{ {
struct task_struct *tsk = current;
bool resched_timer = false; bool resched_timer = false;
int signr; int signr;
/* We only dequeue private signals from ourselves, we don't let lockdep_assert_held(&tsk->sighand->siglock);
* signalfd steal them
*/
*type = PIDTYPE_PID; *type = PIDTYPE_PID;
signr = __dequeue_signal(&tsk->pending, mask, info, &resched_timer); signr = __dequeue_signal(&tsk->pending, mask, info, &resched_timer);
if (!signr) { if (!signr) {
@ -2793,8 +2791,7 @@ relock:
type = PIDTYPE_PID; type = PIDTYPE_PID;
signr = dequeue_synchronous_signal(&ksig->info); signr = dequeue_synchronous_signal(&ksig->info);
if (!signr) if (!signr)
signr = dequeue_signal(current, &current->blocked, signr = dequeue_signal(&current->blocked, &ksig->info, &type);
&ksig->info, &type);
if (!signr) if (!signr)
break; /* will return 0 */ break; /* will return 0 */
@ -3648,7 +3645,7 @@ static int do_sigtimedwait(const sigset_t *which, kernel_siginfo_t *info,
signotset(&mask); signotset(&mask);
spin_lock_irq(&tsk->sighand->siglock); spin_lock_irq(&tsk->sighand->siglock);
sig = dequeue_signal(tsk, &mask, info, &type); sig = dequeue_signal(&mask, info, &type);
if (!sig && timeout) { if (!sig && timeout) {
/* /*
* None ready, temporarily unblock those we're interested * None ready, temporarily unblock those we're interested
@ -3667,7 +3664,7 @@ static int do_sigtimedwait(const sigset_t *which, kernel_siginfo_t *info,
spin_lock_irq(&tsk->sighand->siglock); spin_lock_irq(&tsk->sighand->siglock);
__set_task_blocked(tsk, &tsk->real_blocked); __set_task_blocked(tsk, &tsk->real_blocked);
sigemptyset(&tsk->real_blocked); sigemptyset(&tsk->real_blocked);
sig = dequeue_signal(tsk, &mask, info, &type); sig = dequeue_signal(&mask, info, &type);
} }
spin_unlock_irq(&tsk->sighand->siglock); spin_unlock_irq(&tsk->sighand->siglock);