From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 4D49DEEC0 for ; Sun, 26 Apr 2026 16:21:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777220497; cv=none; b=JNmbjd9tZ1dNd6a0+YwFlJOQmm1eIDt85vc+YNbMW2G0F8XFadcYYK/+laSKpydetjc1iKmXVHeW9JcBjGxVdKJSC8d999O20aoU2z7lEt0oX91CSR1jepIt88ksPnqmoOgzo4sLArGAQYCda1ofp6NuSPcmLRIT+yjQc58pcWM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777220497; c=relaxed/simple; bh=JEWGQGtl3vdN19laQ8zBcgEDf4wSmb+mhhgY120u6/A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MSZHWg+oFyXm6cDwSh8oIl9Sb4vBpiG/qyWhXHWxjKDT7LqaumybWZVbXv14+S8GA0XImyujHsNuiEeXIn50lcYMLduWn0KfiMMPitbw7LWy+juE/9UJgzNttXZN87u+Aj+4AziohpXMt4E5w00xK9kxx6n5jbs0CViasjw7bWs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DZ1rGqBi; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DZ1rGqBi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777220495; 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: in-reply-to:in-reply-to:references:references; bh=jhMPIv6wcNPhaksK3m+LprksAQw18qFmjKM+MfnU3JQ=; b=DZ1rGqBi9ypKEDLV7gppMhm25cxdGx53dsRIrrW80NR/C1ixi6cSQM9xcw7LaPAl5PHdLh aeT1XWsR+xsp2xGVm08equlbMJunqa3OdG3asR6IYe5Mq0GeXM1d2vMQ3H+EOJQ+L+pUpn WgoeXliFOqhjDCX6bcgWkKGtRV5AVb4= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-244-lNR1e6RYPhetdAlrbT1kkw-1; Sun, 26 Apr 2026 12:21:33 -0400 X-MC-Unique: lNR1e6RYPhetdAlrbT1kkw-1 X-Mimecast-MFC-AGG-ID: lNR1e6RYPhetdAlrbT1kkw_1777220492 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AC2BC18003FC; Sun, 26 Apr 2026 16:21:32 +0000 (UTC) Received: from fedora (unknown [10.44.48.22]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 7A82A195608E; Sun, 26 Apr 2026 16:21:31 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sun, 26 Apr 2026 18:21:32 +0200 (CEST) Date: Sun, 26 Apr 2026 18:21:29 +0200 From: Oleg Nesterov To: Andrew Morton Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/2] dequeue_synchronous_signal: kill the unnecessary still-pending check Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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 --- 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