From nobody Fri Dec 19 21:46:41 2025 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 6BF5F156221 for ; Mon, 10 Jun 2024 16:42:41 +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=1718037763; cv=none; b=Qy0JF/nzt0TXjVSOAcYJWDGWdFff8DeObHuLCRSYISshhj5ZKki4HYjpPIcBqLZmBQwI0km73pFTw2eYlVW7JME8QvF/UF7vARdASRgw+JiEfA5/nR9emUT4s18VF1kzCMu3+5WM05L2s1dAUEanTlQ+EnfOExpmhCpyJ4xrag4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037763; c=relaxed/simple; bh=ipfz+AaYDg2jRk2QzxjlJP24YxnDWUAysNYhb2QjuYU=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Ypi5vpdb+qfS/86umLFY41y+HsjViDyid4SX+CNXp0Dvi9w9UvIuGKZYUmDmb3aWL8TXPgBPyjIPP69y8+7w0HPsrukPFhHsi5jw1T4OgnOXjZh+xY6r12G4FTuchw+by2R28y/IvSVRV0v4FTuwU5CJ+tpg+q2jzh1/g8LVg5A= 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=Ig7CHDgS; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=TmBS80Rg; 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="Ig7CHDgS"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="TmBS80Rg" Message-ID: <20240610164027.175737443@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718037758; 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=t7pjsSQKBc6tEHZWynKUhlTqjE2Ct45jVqlBq7pgRI0=; b=Ig7CHDgSH0EjF8KG/YMtAF8vgWZdmuIaNmilJF5M7LmwTrtoCjdHuHjR3GmdE4yuoqzoFL I67G1p3jotFFqMPqfTJoKGle4kr4k0Q30rQ+QKE6zD5RPuDHyf5W0K+gMb24UYeGZT6ffh rDJ5OzeXT8wNszb34pa55E16pvw43hZHm9Q+dCRtuB/ixSXeXwBhFMtXernAy/UtWj4qqD dkbsB5+PNwWzZgMXDiyFt09nDMH2sVgRs4t3q8ncCNlcmbDASKZXP4lwCFEhjxJ2dVOrSW prv/iKuuqmt4pYC1lEGU0ecadmDGwcjJneOfxpl9pkzuv27T4HADMDengaYf2Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718037758; 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=t7pjsSQKBc6tEHZWynKUhlTqjE2Ct45jVqlBq7pgRI0=; b=TmBS80Rg0JR64rsW9MEt1Jwmyow/BfyNqbloFFX3QYk2UkquD9CnBQwd+z2ynml01cljSo AK06rupT78vLkWAA== 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 27/51] signal: Get rid of resched_timer logic 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:38 +0200 (CEST) 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 @@ -526,8 +526,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 @@ -549,12 +548,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 { /* @@ -571,13 +564,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 @@ -589,17 +581,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); @@ -626,7 +616,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 @@ -1011,6 +1001,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;