From nobody Sun Feb 8 17:24:13 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90E2E155381 for ; Mon, 10 Jun 2024 16:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037757; cv=none; b=FGcx2hayA02PPoaQFlvycH68id6EUA0S3CPoXQDOC1V5xPJ6hNA0GCjOUiERiHY3zYn36z9ysJGEG6JQrx1r34mfHcja5I7+VK//QQTYddMrvo4LmOqGbMrrgomeKaar7UlFEXOGkNtXi8+jlWYMRpE7cMa+b0S1d5heWg3AcaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037757; c=relaxed/simple; bh=+8eJhLmLaBhsdGTxPY+WrOPg4LBJu0d/eL03Sd/TxJs=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=mUwa/LrONYnMOKsxaLnGT3pH/mF+NP3G5PPWCAb0522sIVR5hsGiHByUpjIOKlyWstEAGKMlhBaGLeH3NZRnZz2XDg/OfN+m+RLKpYiX/7VZE9+/bhU8IFyOCu1z/1alHhZRMS1LUjwboTxjzDF9luW/dWMD8+skIybl40QhSR0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=n3W1Hu20; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=PVSxu5x8; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="n3W1Hu20"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PVSxu5x8" Message-ID: <20240610164026.929337144@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718037754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=Uf6CyGlUDp6ZuYdKBwWfggnizxjbUvxBehy8Wo6qoQk=; b=n3W1Hu20fjU+TPQ3CcsNkobldImCjKMtoXzFo1J2iVqeaXrCADKhwDBntwsSWlwQetD/8S PCoyJ/67OgDyI2yLXtGx5HIH8t0nLrGmarBv/vuvUAKadUDKuFQ83v0OBNOnWMi/6IUUAX O8wsvvjA392UL2fMJG4Gi8JoZcnOdARszK914P6Mp8y10gtU828b51Z3w0wmz3BXhHg1q7 e4alGwlQcckXqiF7/y/9b7+yIPzNKyiS33pAnsvX74twnV3/YyRUTFVlxvD0Z2Jymjgqwi AZgDhasuefxchmFz+8pnW/e3Yufv3ogk0DB8H0j9WtVFv7p4GT5rnbWS6oWNzw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718037754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=Uf6CyGlUDp6ZuYdKBwWfggnizxjbUvxBehy8Wo6qoQk=; b=PVSxu5x8RiiGKvQESDosM+e4/uD8tBBqN5iVjWpwqlpE5uGJFX4rKVxYu0v5crEOdA/v0Z 4kKALu2Rql99aeBg== From: Thomas Gleixner To: LKML Cc: Anna-Maria Behnsen , Frederic Weisbecker , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: [patch V3 23/51] signal: Remove task argument from dequeue_signal() References: <20240610163452.591699700@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Mon, 10 Jun 2024 18:42:33 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Frederic Weisbecker --- fs/signalfd.c | 4 ++-- include/linux/sched/signal.h | 5 ++--- kernel/signal.c | 23 ++++++++++------------- 3 files changed, 14 insertions(+), 18 deletions(-) --- a/fs/signalfd.c +++ b/fs/signalfd.c @@ -160,7 +160,7 @@ static ssize_t signalfd_dequeue(struct s DECLARE_WAITQUEUE(wait, current); =20 spin_lock_irq(¤t->sighand->siglock); - ret =3D dequeue_signal(current, &ctx->sigmask, info, &type); + ret =3D dequeue_signal(&ctx->sigmask, info, &type); switch (ret) { case 0: if (!nonblock) @@ -175,7 +175,7 @@ static ssize_t signalfd_dequeue(struct s add_wait_queue(¤t->sighand->signalfd_wqh, &wait); for (;;) { set_current_state(TASK_INTERRUPTIBLE); - ret =3D dequeue_signal(current, &ctx->sigmask, info, &type); + ret =3D dequeue_signal(&ctx->sigmask, info, &type); if (ret !=3D 0) break; if (signal_pending(current)) { --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -276,8 +276,7 @@ static inline void signal_set_stop_flags extern void flush_signals(struct task_struct *); extern void ignore_signals(struct task_struct *); extern void flush_signal_handlers(struct task_struct *, int force_default); -extern int dequeue_signal(struct task_struct *task, sigset_t *mask, - kernel_siginfo_t *info, enum pid_type *type); +extern int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info, enum pid= _type *type); =20 static inline int kernel_dequeue_signal(void) { @@ -287,7 +286,7 @@ static inline int kernel_dequeue_signal( int ret; =20 spin_lock_irq(&task->sighand->siglock); - ret =3D dequeue_signal(task, &task->blocked, &__info, &__type); + ret =3D dequeue_signal(&task->blocked, &__info, &__type); spin_unlock_irq(&task->sighand->siglock); =20 return ret; --- a/kernel/signal.c +++ b/kernel/signal.c @@ -618,20 +618,18 @@ static int __dequeue_signal(struct sigpe } =20 /* - * Dequeue a signal and return the element to the caller, which is - * expected to free it. - * - * All callers have to hold the siglock. + * Try to dequeue a signal. If a deliverable signal is found fill in the + * caller provided siginfo and return the signal number. Otherwise return + * 0. */ -int dequeue_signal(struct task_struct *tsk, sigset_t *mask, - kernel_siginfo_t *info, enum pid_type *type) +int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info, enum pid_type *= type) { + struct task_struct *tsk =3D current; bool resched_timer =3D false; int signr; =20 - /* We only dequeue private signals from ourselves, we don't let - * signalfd steal them - */ + lockdep_assert_held(&tsk->sighand->siglock); + *type =3D PIDTYPE_PID; signr =3D __dequeue_signal(&tsk->pending, mask, info, &resched_timer); if (!signr) { @@ -2787,8 +2785,7 @@ bool get_signal(struct ksignal *ksig) type =3D PIDTYPE_PID; signr =3D dequeue_synchronous_signal(&ksig->info); if (!signr) - signr =3D dequeue_signal(current, ¤t->blocked, - &ksig->info, &type); + signr =3D dequeue_signal(¤t->blocked, &ksig->info, &type); =20 if (!signr) break; /* will return 0 */ @@ -3642,7 +3639,7 @@ static int do_sigtimedwait(const sigset_ signotset(&mask); =20 spin_lock_irq(&tsk->sighand->siglock); - sig =3D dequeue_signal(tsk, &mask, info, &type); + sig =3D dequeue_signal(&mask, info, &type); if (!sig && timeout) { /* * None ready, temporarily unblock those we're interested @@ -3661,7 +3658,7 @@ static int do_sigtimedwait(const sigset_ spin_lock_irq(&tsk->sighand->siglock); __set_task_blocked(tsk, &tsk->real_blocked); sigemptyset(&tsk->real_blocked); - sig =3D dequeue_signal(tsk, &mask, info, &type); + sig =3D dequeue_signal(&mask, info, &type); } spin_unlock_irq(&tsk->sighand->siglock);