public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] dequeue_synchronous_signal: use SI_FROMKERNEL()
@ 2026-04-26 16:21 Oleg Nesterov
  2026-04-26 16:21 ` [PATCH 2/2] dequeue_synchronous_signal: kill the unnecessary still-pending check Oleg Nesterov
  0 siblings, 1 reply; 4+ messages in thread
From: Oleg Nesterov @ 2026-04-26 16:21 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

Cosmetic, to make the intent more clear to the reader.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/signal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index d65d0fe24bfb..9924489c43a5 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -681,8 +681,8 @@ static int dequeue_synchronous_signal(kernel_siginfo_t *info)
 	 * Return the first synchronous signal in the queue.
 	 */
 	list_for_each_entry(q, &pending->list, list) {
-		/* Synchronous signals have a positive si_code */
-		if ((q->info.si_code > SI_USER) &&
+		/* Synchronous signals are always from kernel */
+		if (SI_FROMKERNEL(&q->info) &&
 		    (sigmask(q->info.si_signo) & SYNCHRONOUS_MASK)) {
 			sync = q;
 			goto next;
-- 
2.52.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] dequeue_synchronous_signal: kill the unnecessary still-pending check
  2026-04-26 16:21 [PATCH 1/2] dequeue_synchronous_signal: use SI_FROMKERNEL() Oleg Nesterov
@ 2026-04-26 16:21 ` Oleg Nesterov
  2026-04-26 19:27   ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Oleg Nesterov @ 2026-04-26 16:21 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

The signals in SYNCHRONOUS_MASK are not real-time signals, so at most
one instance can be queued. Add a static_assert() to ensure.

Remove the list_for_each_entry_continue() loop and simplify the code.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/signal.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 9924489c43a5..529774926476 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -665,6 +665,8 @@ int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type)
 }
 EXPORT_SYMBOL_GPL(dequeue_signal);
 
+static_assert(ilog2(SYNCHRONOUS_MASK) + 1 < SIGRTMIN);
+
 static int dequeue_synchronous_signal(kernel_siginfo_t *info)
 {
 	struct task_struct *tsk = current;
@@ -676,7 +678,6 @@ static int dequeue_synchronous_signal(kernel_siginfo_t *info)
 	 */
 	if (!((pending->signal.sig[0] & ~tsk->blocked.sig[0]) & SYNCHRONOUS_MASK))
 		return 0;
-
 	/*
 	 * Return the first synchronous signal in the queue.
 	 */
@@ -685,22 +686,14 @@ static int dequeue_synchronous_signal(kernel_siginfo_t *info)
 		if (SI_FROMKERNEL(&q->info) &&
 		    (sigmask(q->info.si_signo) & SYNCHRONOUS_MASK)) {
 			sync = q;
-			goto next;
+			break;
 		}
 	}
-	return 0;
-next:
-	/*
-	 * Check if there is another siginfo for the same signal.
-	 */
-	list_for_each_entry_continue(q, &pending->list, list) {
-		if (q->info.si_signo == sync->info.si_signo)
-			goto still_pending;
-	}
+	if (!sync)
+		return 0;
 
 	sigdelset(&pending->signal, sync->info.si_signo);
 	recalc_sigpending();
-still_pending:
 	list_del_init(&sync->list);
 	copy_siginfo(info, &sync->info);
 	__sigqueue_free(sync);
-- 
2.52.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] dequeue_synchronous_signal: kill the unnecessary still-pending check
  2026-04-26 16:21 ` [PATCH 2/2] dequeue_synchronous_signal: kill the unnecessary still-pending check Oleg Nesterov
@ 2026-04-26 19:27   ` Andrew Morton
  2026-04-27 11:34     ` Oleg Nesterov
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2026-04-26 19:27 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel

On Sun, 26 Apr 2026 18:21:29 +0200 Oleg Nesterov <oleg@redhat.com> wrote:

> The signals in SYNCHRONOUS_MASK are not real-time signals, so at most
> one instance can be queued. Add a static_assert() to ensure.
> 
> Remove the list_for_each_entry_continue() loop and simplify the code.

AI review asked a thing:
	https://sashiko.dev/#/patchset/ae47bBSixfPpkQBm@redhat.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] dequeue_synchronous_signal: kill the unnecessary still-pending check
  2026-04-26 19:27   ` Andrew Morton
@ 2026-04-27 11:34     ` Oleg Nesterov
  0 siblings, 0 replies; 4+ messages in thread
From: Oleg Nesterov @ 2026-04-27 11:34 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

On 04/26, Andrew Morton wrote:
>
> On Sun, 26 Apr 2026 18:21:29 +0200 Oleg Nesterov <oleg@redhat.com> wrote:
>
> > The signals in SYNCHRONOUS_MASK are not real-time signals, so at most
> > one instance can be queued. Add a static_assert() to ensure.
> >
> > Remove the list_for_each_entry_continue() loop and simplify the code.
>
> AI review asked a thing:
> 	https://sashiko.dev/#/patchset/ae47bBSixfPpkQBm@redhat.com

OOPS. Indeed I am stupid. I forgor that posixtimer_send_sigqueue() checks
prepare_signal() but not legacy_queue().

Heh ;) Dear Sashiko, thanks for your quick NACK!

Oleg.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-27 11:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-26 16:21 [PATCH 1/2] dequeue_synchronous_signal: use SI_FROMKERNEL() Oleg Nesterov
2026-04-26 16:21 ` [PATCH 2/2] dequeue_synchronous_signal: kill the unnecessary still-pending check Oleg Nesterov
2026-04-26 19:27   ` Andrew Morton
2026-04-27 11:34     ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox