Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp484793lqp; Mon, 10 Jun 2024 09:47:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUl4HpgTwm823TqJ3c1kkQCkykvsbRMu+ty1tbcCn/bRRAd7U8I6gRMCcxHA3mBm3Yq14jaQJPTQMElKDZeieq8EWhd+wItmEzZhy8PcA== X-Google-Smtp-Source: AGHT+IEakNDlnBrxtVJ0pEuWlesJ+Ys3mwHFJD5ZPtRk3s1FJaEfNXISpLQg0nCDn0qYdwVwdZte X-Received: by 2002:a17:906:b798:b0:a6e:b5f0:6c62 with SMTP id a640c23a62f3a-a6eb5f06d0amr499509766b.8.1718038020232; Mon, 10 Jun 2024 09:47:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718038020; cv=pass; d=google.com; s=arc-20160816; b=cVcrstoY7JyOgcxOsFV2F32QYnh0deP0EZyGL8ckhAB6FYxdmNtUI3F9Bqho5AhHxN mcpuVkvOztWBWePO5VjUiAvjKrQZfVUOn/QkPfyV1pnzOdD2w0hLzTSvF2dk2u5RZqwU 5hqzM9XWRr50xPRWbJ69XRyiJ8MkJTLIEGG6MXlRPKzdGCZ00xTUqiZ/gpFZmoZl3heY rNivgJ477iIwDVq6eSgaztovmnhg57UQSSt8Y+WkkT7Q8Ih2Bmlph8NCQq9HjnFyn8c2 Ebr+Qx0H7X9y8LbpUzdSsUG61NwiYjYuTlo1zJ2zC/FJpoYuJZBQkl9EAROLnKj1rn74 2abg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:subject:cc:to:from:dkim-signature :dkim-signature:message-id; bh=Uf6CyGlUDp6ZuYdKBwWfggnizxjbUvxBehy8Wo6qoQk=; fh=joBs/8L+orz77ylyCy6wqNwwi35f7sYhLR+/TQjQjhI=; b=uF89fEtRKuvwT6mwaR6JGNGQlv7v2nghHJkYU4QjRlbHfg7RtqhI4LVpRdYnzNMhsj GQZv99txSMxluj2R8XRoz/HgOte0t0SqvLC7ewMw7WtQcp38d26ILrpzJTbZQ8yOjrcj VsTb9wNpr+P3lUG3199x3VnbKJNruMnmVuLVvKNThqJeYFzSj0EfjiWjZOvHqOf3+tae PKj30NTW5ZUrLp4TTwqgtjLceReU9AhnAMsMYdQ/kwkizD8PcQyGM7Ep+ePN8t6Q3dwL kvd78i6q7X83gtCihjG4gFkAEIk8572cJZKCvMDtxUjcSH0FrZ11So/1EmmvyfrhP1Nu SnQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=n3W1Hu20; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=PVSxu5x8; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-208586-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208586-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6e98261e59si333493766b.185.2024.06.10.09.47.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:47:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208586-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=n3W1Hu20; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=PVSxu5x8; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-208586-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208586-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C3DD71F21F9A for ; Mon, 10 Jun 2024 16:46:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14A4215575F; Mon, 10 Jun 2024 16:42:38 +0000 (UTC) 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" 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 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 Content-Type: text/plain; charset=UTF-8 Date: Mon, 10 Jun 2024 18:42:33 +0200 (CEST) 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); spin_lock_irq(¤t->sighand->siglock); - ret = dequeue_signal(current, &ctx->sigmask, info, &type); + ret = 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 = dequeue_signal(current, &ctx->sigmask, info, &type); + ret = dequeue_signal(&ctx->sigmask, info, &type); if (ret != 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); static inline int kernel_dequeue_signal(void) { @@ -287,7 +286,7 @@ static inline int kernel_dequeue_signal( int ret; spin_lock_irq(&task->sighand->siglock); - ret = dequeue_signal(task, &task->blocked, &__info, &__type); + ret = dequeue_signal(&task->blocked, &__info, &__type); spin_unlock_irq(&task->sighand->siglock); return ret; --- a/kernel/signal.c +++ b/kernel/signal.c @@ -618,20 +618,18 @@ static int __dequeue_signal(struct sigpe } /* - * 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 = current; bool resched_timer = false; int signr; - /* We only dequeue private signals from ourselves, we don't let - * signalfd steal them - */ + lockdep_assert_held(&tsk->sighand->siglock); + *type = PIDTYPE_PID; signr = __dequeue_signal(&tsk->pending, mask, info, &resched_timer); if (!signr) { @@ -2787,8 +2785,7 @@ bool get_signal(struct ksignal *ksig) type = PIDTYPE_PID; signr = dequeue_synchronous_signal(&ksig->info); if (!signr) - signr = dequeue_signal(current, ¤t->blocked, - &ksig->info, &type); + signr = dequeue_signal(¤t->blocked, &ksig->info, &type); if (!signr) break; /* will return 0 */ @@ -3642,7 +3639,7 @@ static int do_sigtimedwait(const sigset_ signotset(&mask); spin_lock_irq(&tsk->sighand->siglock); - sig = dequeue_signal(tsk, &mask, info, &type); + sig = 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 = dequeue_signal(tsk, &mask, info, &type); + sig = dequeue_signal(&mask, info, &type); } spin_unlock_irq(&tsk->sighand->siglock);