From patchwork Tue May 25 15:14:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 12279285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21395C2B9F8 for ; Tue, 25 May 2021 15:29:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E525E61260 for ; Tue, 25 May 2021 15:29:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E525E61260 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fzfv0DtpLS6zk/aV5nOdEpi6bBS6Kl1awEe/E3Lqc6A=; b=drXrqu/tepLL1T maf56UFUhiQ43uUmnPpFwixcCNNX+1Pn1OJNXJGK45o1W6znvECK7lMV5H1PZJp7AW727pDjD9Nk9 1K3yh4AEB27NxrwcToRze7O4MU8YUXz72c+2lRbY3PZJk0ADnFCNIbmK91rvoGBfexA0R1Id91uY5 o6q/z0sKr+ZuaQ4FYCKJGfwXgD+/BVK3iIc1qs9TbCTHBhgimexYYnRUXUhbmiWvBBnW3q3x+k/15 FOwhLPxDL3poqaaeD/RclVD4/ghOi7ttJz44JIaC2mr8ogG/QTac7ylEXU8k7nAUlnhb0lV4/075j XUkiKuYDR/K/2qe6RDsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1llYy2-005zXk-QX; Tue, 25 May 2021 15:27:39 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1llYmy-005tua-Fk for linux-arm-kernel@lists.infradead.org; Tue, 25 May 2021 15:16:14 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id CD71161429; Tue, 25 May 2021 15:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621955772; bh=88QGO6GFkFrMZ/mZqmBjqTxJcB37zYt9m+f1u0tTDnk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=esDQMvGCE7znUlKphB1UaWc0uh205v2ZgAcri43giJdHCWz6R2J7C8OEZZ2CSABIB WupYShsYBNvJQ70LzZOzUPzSrlKp1eY8CUK/t7c1D7HMgxrEVdz7A6OSbeGoEdGFhp JLvTSScuGbwFweldZwbbqnl5ZgkFpg0WQMqp9StPTulQ6Wa5X+wWFnudjr5kzd5Kkr G9br2puupvhiJR6PiO4SWz1EnnVBGrRHGtPp5omRX55qeuxGz+jPa+XS2qj8Wiu2x3 s2guRCvTLgEiu0ylOt/rvOTQpDN/zUfBOqRQQFCtZ90iaHyW4u8RmTJYiyM69EtPk+ hFDrTktYzflKQ== From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Will Deacon , Catalin Marinas , Marc Zyngier , Greg Kroah-Hartman , Peter Zijlstra , Morten Rasmussen , Qais Yousef , Suren Baghdasaryan , Quentin Perret , Tejun Heo , Johannes Weiner , Ingo Molnar , Juri Lelli , Vincent Guittot , "Rafael J. Wysocki" , Dietmar Eggemann , Daniel Bristot de Oliveira , kernel-team@android.com Subject: [PATCH v7 15/22] freezer: Add frozen_or_skipped() helper function Date: Tue, 25 May 2021 16:14:25 +0100 Message-Id: <20210525151432.16875-16-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210525151432.16875-1-will@kernel.org> References: <20210525151432.16875-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210525_081612_600678_F744A070 X-CRM114-Status: GOOD ( 13.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Occasionally it is necessary to see if a task is either frozen or sleeping in the PF_FREEZER_SKIP state. In preparation for adding additional users of this check, introduce a frozen_or_skipped() helper function and convert the hung task detector over to using it. Signed-off-by: Will Deacon --- include/linux/freezer.h | 6 ++++++ kernel/hung_task.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/linux/freezer.h b/include/linux/freezer.h index 0621c5f86c39..b9e1e4200101 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h @@ -27,6 +27,11 @@ static inline bool frozen(struct task_struct *p) return p->flags & PF_FROZEN; } +static inline bool frozen_or_skipped(struct task_struct *p) +{ + return p->flags & (PF_FROZEN | PF_FREEZER_SKIP); +} + extern bool freezing_slow_path(struct task_struct *p); /* @@ -270,6 +275,7 @@ static inline int freezable_schedule_hrtimeout_range(ktime_t *expires, #else /* !CONFIG_FREEZER */ static inline bool frozen(struct task_struct *p) { return false; } +static inline bool frozen_or_skipped(struct task_struct *p) { return false; } static inline bool freezing(struct task_struct *p) { return false; } static inline void __thaw_task(struct task_struct *t) {} diff --git a/kernel/hung_task.c b/kernel/hung_task.c index 396ebaebea3f..d2d4c4159b23 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -92,8 +92,8 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout) * Ensure the task is not frozen. * Also, skip vfork and any other user process that freezer should skip. */ - if (unlikely(t->flags & (PF_FROZEN | PF_FREEZER_SKIP))) - return; + if (unlikely(frozen_or_skipped(t))) + return; /* * When a freshly created task is scheduled once, changes its state to