From nobody Sun Feb 8 21:27:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF030C7EE24 for ; Tue, 6 Jun 2023 14:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238156AbjFFOjO (ORCPT ); Tue, 6 Jun 2023 10:39:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238130AbjFFOi3 (ORCPT ); Tue, 6 Jun 2023 10:38:29 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C07791BCC for ; Tue, 6 Jun 2023 07:37:55 -0700 (PDT) Message-ID: <20230606142032.265274690@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686062274; 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=pTwgQriJEXYz/BGSH2oQaAJz9q8TYA27uj1w2y/zcJc=; b=0IRnAHwIhJIqglZvpXDrkZu/M/QwBgEWV0yLKYPAXoPN4kfedaIOLiuO2Z5c5hn3FtPUuu QGE7N7o7rl5iQg6iHrhjKFaYtTqIYjNsJ6DOC5S4bM6SAHBATUCGLkAfbT6FK3BzBe5nFL Toi2QxVGSgU74Ak5v8wR34tC742JhdqyFhqjxrji1CFbDYfrtvN7/O7kEy7xIlJgu+BgAm mXFgL6K7p6gPkpg9uQ87lk9akugxVrSUwIAa8xb2ye54ygC3fodE8dLn+4A76CIHznpTrr sEcWOjihR7swEfGfh9xix9cOzwsBw/E7KojqlxpE3vxK3kVlvU5nDusbj6TCTw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686062274; 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=pTwgQriJEXYz/BGSH2oQaAJz9q8TYA27uj1w2y/zcJc=; b=JRFbBcCjP4x4iocN+ozTdkGi1p1nb01JhhQ6f5PJp6rE0q/eY9U36wAeEw+i+XMHN5fnK4 KpBY5EooAmYsNODQ== From: Thomas Gleixner To: LKML Cc: Frederic Weisbecker , Anna-Maria Behnsen , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: [patch 22/45] signal: Get rid of resched_timer logic References: <20230606132949.068951363@linutronix.de> MIME-Version: 1.0 Date: Tue, 6 Jun 2023 16:37:53 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is no reason for handing the *resched pointer argument through several functions just to check whether the signal is related to a self rearming posix timer. SI_TIMER is only used by the posix timer code and cannot be queued from user space. The only extra check in collect_signal() to verify whether the queued signal is preallocated is not really useful. Some other places already check purely the SI_TIMER type. Signed-off-by: Thomas Gleixner --- kernel/signal.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) --- a/kernel/signal.c +++ b/kernel/signal.c @@ -529,8 +529,7 @@ bool unhandled_signal(struct task_struct return !tsk->ptrace; } =20 -static void collect_signal(int sig, struct sigpending *list, kernel_siginf= o_t *info, - bool *resched_timer) +static void collect_signal(int sig, struct sigpending *list, kernel_siginf= o_t *info) { struct sigqueue *q, *first =3D NULL; =20 @@ -552,12 +551,6 @@ static void collect_signal(int sig, stru still_pending: list_del_init(&first->list); copy_siginfo(info, &first->info); - - *resched_timer =3D - (first->flags & SIGQUEUE_PREALLOC) && - (info->si_code =3D=3D SI_TIMER) && - (info->si_sys_private); - __sigqueue_free(first); } else { /* @@ -574,13 +567,12 @@ static void collect_signal(int sig, stru } } =20 -static int __dequeue_signal(struct sigpending *pending, sigset_t *mask, - kernel_siginfo_t *info, bool *resched_timer) +static int __dequeue_signal(struct sigpending *pending, sigset_t *mask, ke= rnel_siginfo_t *info) { int sig =3D next_signal(pending, mask); =20 if (sig) - collect_signal(sig, pending, info, resched_timer); + collect_signal(sig, pending, info); return sig; } =20 @@ -592,17 +584,15 @@ static int __dequeue_signal(struct sigpe 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 lockdep_assert_held(&tsk->sighand->siglock); =20 *type =3D PIDTYPE_PID; - signr =3D __dequeue_signal(&tsk->pending, mask, info, &resched_timer); + signr =3D __dequeue_signal(&tsk->pending, mask, info); if (!signr) { *type =3D PIDTYPE_TGID; - signr =3D __dequeue_signal(&tsk->signal->shared_pending, - mask, info, &resched_timer); + signr =3D __dequeue_signal(&tsk->signal->shared_pending, mask, info); =20 if (unlikely(signr =3D=3D SIGALRM)) posixtimer_rearm_itimer(tsk); @@ -629,7 +619,7 @@ int dequeue_signal(sigset_t *mask, kerne } =20 if (IS_ENABLED(CONFIG_POSIX_TIMERS)) { - if (unlikely(resched_timer)) + if (unlikely(info->si_code =3D=3D SI_TIMER && info->si_sys_private)) posixtimer_rearm(info); } =20 @@ -1015,6 +1005,9 @@ static int __send_signal_locked(int sig, =20 lockdep_assert_held(&t->sighand->siglock); =20 + if (WARN_ON_ONCE(!is_si_special(info) && info->si_code =3D=3D SI_TIMER)) + return 0; + result =3D TRACE_SIGNAL_IGNORED; if (!prepare_signal(sig, t, force)) goto ret;