Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp319166pxx; Thu, 29 Oct 2020 03:32:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3QU2CzaL9YtlBt1cz910lhfxv+JZZcyIxqc2Q4OQFIk4f8lgBU9Xn8QXMQx0L3kS7bIU9 X-Received: by 2002:a17:906:b084:: with SMTP id x4mr3486337ejy.374.1603967531838; Thu, 29 Oct 2020 03:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603967531; cv=none; d=google.com; s=arc-20160816; b=Cu0jGNYIAgmQVoR9+kL+6m+MpdmqxwQBysHjrq+nvvYQCcsbts8afmHQ+anf0innwz yEiqf30Olv9L2zX4Nm+Sxb8wSDKeJhTRgektffHo0OICr+qV8pntSHcJ4aZbjNf6es3v sqF/VK0pHocUuYBpQu+52BGw5KqB5Y3lvICzWfWvcBfO1jMg1GXZcChnJvGg2iH7o8RQ EiMP98ojbzYwO+FQDyRfvVDDCg+p/8oYcwiPQ10OwqUTU2EgDvXMbk2kSRp/BrlyGmcU DtmApn48O1zpYfMgNi5N6u209w6ewRFlpu+Ufqg2pDK6+ybGNAJ6vHr+JHOHoCsL3q1m PPNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=CP1McKmFoG89FuR5vLKzdnZKTdPCA47TdvaNbaRIMg0=; b=DL2gfB0Fpoc7RXet9Ekit6Jny1qIRWJ8JFRpoo9FrQZYe6Fi50h+15DD5hmzKF9zqS qHqhE/yu+rot7IyOywPL7OLFsOZoQoHVLvhzGzSaRVNtU/MVIvgYxEMtVFvEkDJQ9c6G ywR1U460EkckWmJa8Z71Gtrm/HmAJC0E/39aM5cITk/6dyq+mTt3mOES/cNr9wFFBBNW F1qFaiqNCh1UukV+tnYickNsguTNbX1MVffELvvqJQeHnEycl48KCMkTSGzZUrhpwtpd /f7PfEBXNaNHUM0AV8zptrPPM5zKqt/ZkWmssFx6tRn1f09KB5vMJhDupOGlZ4x+Eoal eCcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vMKsZT7x; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dg11si1643130edb.246.2020.10.29.03.31.48; Thu, 29 Oct 2020 03:32:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vMKsZT7x; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726699AbgJ2KaR (ORCPT + 99 others); Thu, 29 Oct 2020 06:30:17 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:60568 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726013AbgJ2KaN (ORCPT ); Thu, 29 Oct 2020 06:30:13 -0400 Date: Thu, 29 Oct 2020 10:30:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1603967411; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CP1McKmFoG89FuR5vLKzdnZKTdPCA47TdvaNbaRIMg0=; b=vMKsZT7xnwOh3/lT++VGXGZZ0VS4x1MF5zEDU1U+n3e00hfUMAG8Hq4Qr+RrWgI7nHk1b2 DbpJWINmaPC3hd4xPc4OOVBayoQ3Z6VWCnoGKLCN8FC1KQT24gu2GcH8ahDkNo2sR9LQX2 TDaNBarm5hVPC6xkuGLw9R9g2lRdQaRF9B/LoUVDo+gOMqV8aG9ONtYiIOxP7mV8q6x6uZ N/tD5ubkg8nROeXQnezF4FviEQP6+ghHalNp42uYUi7zok4T8P4cb1EgpHccdR1GvwZdk4 dze1s77m9IyIiKBoZS1EGDZtW95TL8uIPqBEoJraSmXIOGYt2TF/cINWdoKTlw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1603967411; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CP1McKmFoG89FuR5vLKzdnZKTdPCA47TdvaNbaRIMg0=; b=dhgX9FtSEOQW61XlYP7/UftK3CHPzVGERX5p+c9DRf6Bh/f3GTzUHe0PvnKiP22YhdNYhh 8G1UnIVPc1L6sfBQ== From: "tip-bot2 for Jens Axboe" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: core/entry] signal: Add task_sigpending() helper Cc: Jens Axboe , Thomas Gleixner , Oleg Nesterov , x86 , LKML In-Reply-To: <20201026203230.386348-2-axboe@kernel.dk> References: <20201026203230.386348-2-axboe@kernel.dk> MIME-Version: 1.0 Message-ID: <160396741064.397.16273112747578386551.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the core/entry branch of tip: Commit-ID: 5c251e9dc0e127bac6fc5b8e6696363d2e35f515 Gitweb: https://git.kernel.org/tip/5c251e9dc0e127bac6fc5b8e6696363d2e35f515 Author: Jens Axboe AuthorDate: Mon, 26 Oct 2020 14:32:27 -06:00 Committer: Thomas Gleixner CommitterDate: Thu, 29 Oct 2020 09:37:36 +01:00 signal: Add task_sigpending() helper This is in preparation for maintaining signal_pending() as the decider of whether or not a schedule() loop should be broken, or continue sleeping. This is different than the core signal use cases, which really need to know whether an actual signal is pending or not. task_sigpending() returns non-zero if TIF_SIGPENDING is set. Only core kernel use cases should care about the distinction between the two, make sure those use the task_sigpending() helper. Signed-off-by: Jens Axboe Signed-off-by: Thomas Gleixner Reviewed-by: Thomas Gleixner Reviewed-by: Oleg Nesterov Link: https://lore.kernel.org/r/20201026203230.386348-2-axboe@kernel.dk --- include/linux/sched/signal.h | 9 +++++++-- kernel/events/uprobes.c | 2 +- kernel/signal.c | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index 1bad18a..404145d 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -353,11 +353,16 @@ static inline int restart_syscall(void) return -ERESTARTNOINTR; } -static inline int signal_pending(struct task_struct *p) +static inline int task_sigpending(struct task_struct *p) { return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING)); } +static inline int signal_pending(struct task_struct *p) +{ + return task_sigpending(p); +} + static inline int __fatal_signal_pending(struct task_struct *p) { return unlikely(sigismember(&p->pending.signal, SIGKILL)); @@ -365,7 +370,7 @@ static inline int __fatal_signal_pending(struct task_struct *p) static inline int fatal_signal_pending(struct task_struct *p) { - return signal_pending(p) && __fatal_signal_pending(p); + return task_sigpending(p) && __fatal_signal_pending(p); } static inline int signal_pending_state(long state, struct task_struct *p) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 649fd53..edd0c98 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -1973,7 +1973,7 @@ bool uprobe_deny_signal(void) WARN_ON_ONCE(utask->state != UTASK_SSTEP); - if (signal_pending(t)) { + if (task_sigpending(t)) { spin_lock_irq(&t->sighand->siglock); clear_tsk_thread_flag(t, TIF_SIGPENDING); spin_unlock_irq(&t->sighand->siglock); diff --git a/kernel/signal.c b/kernel/signal.c index 42b67d2..b179ecc 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -983,7 +983,7 @@ static inline bool wants_signal(int sig, struct task_struct *p) if (task_is_stopped_or_traced(p)) return false; - return task_curr(p) || !signal_pending(p); + return task_curr(p) || !task_sigpending(p); } static void complete_signal(int sig, struct task_struct *p, enum pid_type type) @@ -2822,7 +2822,7 @@ static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which) /* Remove the signals this thread can handle. */ sigandsets(&retarget, &retarget, &t->blocked); - if (!signal_pending(t)) + if (!task_sigpending(t)) signal_wake_up(t, 0); if (sigisemptyset(&retarget)) @@ -2856,7 +2856,7 @@ void exit_signals(struct task_struct *tsk) cgroup_threadgroup_change_end(tsk); - if (!signal_pending(tsk)) + if (!task_sigpending(tsk)) goto out; unblocked = tsk->blocked; @@ -2900,7 +2900,7 @@ long do_no_restart_syscall(struct restart_block *param) static void __set_task_blocked(struct task_struct *tsk, const sigset_t *newset) { - if (signal_pending(tsk) && !thread_group_empty(tsk)) { + if (task_sigpending(tsk) && !thread_group_empty(tsk)) { sigset_t newblocked; /* A set of now blocked but previously unblocked signals. */ sigandnsets(&newblocked, newset, ¤t->blocked);