Skip to content

Commit a2b80ce

Browse files
KAGA-KOKOFrederic Weisbecker
authored andcommitted
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 <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]> Reviewed-by: Oleg Nesterov <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]>
1 parent 566e2d8 commit a2b80ce

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

fs/signalfd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static ssize_t signalfd_dequeue(struct signalfd_ctx *ctx, kernel_siginfo_t *info
159159
DECLARE_WAITQUEUE(wait, current);
160160

161161
spin_lock_irq(&current->sighand->siglock);
162-
ret = dequeue_signal(current, &ctx->sigmask, info, &type);
162+
ret = dequeue_signal(&ctx->sigmask, info, &type);
163163
switch (ret) {
164164
case 0:
165165
if (!nonblock)
@@ -174,7 +174,7 @@ static ssize_t signalfd_dequeue(struct signalfd_ctx *ctx, kernel_siginfo_t *info
174174
add_wait_queue(&current->sighand->signalfd_wqh, &wait);
175175
for (;;) {
176176
set_current_state(TASK_INTERRUPTIBLE);
177-
ret = dequeue_signal(current, &ctx->sigmask, info, &type);
177+
ret = dequeue_signal(&ctx->sigmask, info, &type);
178178
if (ret != 0)
179179
break;
180180
if (signal_pending(current)) {

include/linux/sched/signal.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ static inline void signal_set_stop_flags(struct signal_struct *sig,
276276
extern void flush_signals(struct task_struct *);
277277
extern void ignore_signals(struct task_struct *);
278278
extern void flush_signal_handlers(struct task_struct *, int force_default);
279-
extern int dequeue_signal(struct task_struct *task, sigset_t *mask,
280-
kernel_siginfo_t *info, enum pid_type *type);
279+
extern int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type);
281280

282281
static inline int kernel_dequeue_signal(void)
283282
{
@@ -287,7 +286,7 @@ static inline int kernel_dequeue_signal(void)
287286
int ret;
288287

289288
spin_lock_irq(&task->sighand->siglock);
290-
ret = dequeue_signal(task, &task->blocked, &__info, &__type);
289+
ret = dequeue_signal(&task->blocked, &__info, &__type);
291290
spin_unlock_irq(&task->sighand->siglock);
292291

293292
return ret;

kernel/signal.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -618,20 +618,18 @@ static int __dequeue_signal(struct sigpending *pending, sigset_t *mask,
618618
}
619619

620620
/*
621-
* Dequeue a signal and return the element to the caller, which is
622-
* expected to free it.
623-
*
624-
* All callers have to hold the siglock.
621+
* Try to dequeue a signal. If a deliverable signal is found fill in the
622+
* caller provided siginfo and return the signal number. Otherwise return
623+
* 0.
625624
*/
626-
int dequeue_signal(struct task_struct *tsk, sigset_t *mask,
627-
kernel_siginfo_t *info, enum pid_type *type)
625+
int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type)
628626
{
627+
struct task_struct *tsk = current;
629628
bool resched_timer = false;
630629
int signr;
631630

632-
/* We only dequeue private signals from ourselves, we don't let
633-
* signalfd steal them
634-
*/
631+
lockdep_assert_held(&tsk->sighand->siglock);
632+
635633
*type = PIDTYPE_PID;
636634
signr = __dequeue_signal(&tsk->pending, mask, info, &resched_timer);
637635
if (!signr) {
@@ -2793,8 +2791,7 @@ bool get_signal(struct ksignal *ksig)
27932791
type = PIDTYPE_PID;
27942792
signr = dequeue_synchronous_signal(&ksig->info);
27952793
if (!signr)
2796-
signr = dequeue_signal(current, &current->blocked,
2797-
&ksig->info, &type);
2794+
signr = dequeue_signal(&current->blocked, &ksig->info, &type);
27982795

27992796
if (!signr)
28002797
break; /* will return 0 */
@@ -3648,7 +3645,7 @@ static int do_sigtimedwait(const sigset_t *which, kernel_siginfo_t *info,
36483645
signotset(&mask);
36493646

36503647
spin_lock_irq(&tsk->sighand->siglock);
3651-
sig = dequeue_signal(tsk, &mask, info, &type);
3648+
sig = dequeue_signal(&mask, info, &type);
36523649
if (!sig && timeout) {
36533650
/*
36543651
* None ready, temporarily unblock those we're interested
@@ -3667,7 +3664,7 @@ static int do_sigtimedwait(const sigset_t *which, kernel_siginfo_t *info,
36673664
spin_lock_irq(&tsk->sighand->siglock);
36683665
__set_task_blocked(tsk, &tsk->real_blocked);
36693666
sigemptyset(&tsk->real_blocked);
3670-
sig = dequeue_signal(tsk, &mask, info, &type);
3667+
sig = dequeue_signal(&mask, info, &type);
36713668
}
36723669
spin_unlock_irq(&tsk->sighand->siglock);
36733670

0 commit comments

Comments
 (0)