Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1654534pxj; Wed, 19 May 2021 10:43:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyid5AT63jQHF8f/XqZA2+4UNG4uB5o25Es5o1IQYsR3s+1ZVSt6RPoX8yLosQ1f/HBPSaA X-Received: by 2002:a05:6402:1686:: with SMTP id a6mr206177edv.123.1621446207138; Wed, 19 May 2021 10:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621446207; cv=none; d=google.com; s=arc-20160816; b=i5W74vjGcAnfTIz3gJutaWC3xIIRV5ClFCpNfn/kYOgeG+oiXPeUBxh3pa8/lomnoB 8qXaFBihQw+F8o/Zloa9j4u49htDSDvIcuoQ6ARxs205I07UMyACe/CyMmuXUhc+VVI2 uGlFtcIohIPgF0dCz/AART+/J6FN36Vr4Ba8IfgbhI68O51VQR3R7V52O4pXdO/qiE0k 8jp9Fb87Ux1BOFedIzGl7sXESekN53G4ZcPe42JGQiMmpunoTtzi9P0LWy1lmOLD/PyU nXv/S9usf6VMzw6g1Uf53oiKCzsWE+nUNW7j9hj8mDTS1SuCFWT0/zSNfwoFbZN2dImt Msqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bjr5vEOw53CCMoZJdtKmOzHU4bbp/tC78/DJIl5Tzo0=; b=ZRKuK8lRtkLbfiiY8f5c0xn00ACqzH0roI2z5pWrWWEoLq1YcsoMvcJzyOsHjSl3Uc VUnDiLYovCxfrQ2I8FiOH2zxjhFSgJazzt6zIOpGvBJPv5Ri99ieQkBr6iTeYoHskkSh bJTLtZq6r2S1BaKZgK3MP49fR27Wztaj/AdEbcGA3MJ2m2RuiZjw/4uGLPVYqwiW+GNl kmSsrYDapUbICyt/vSerJsCDcogsYDLOzzMiUzGYqqLRFR3m70WNyLVGUDIh+Nm3S2f6 2wkWrTXrrX0Y6EbCADXLm1VABA/P9jZg8jlP9eglpAkEyJIb7D99n4LUe+Zvr6jj14OB bcEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="JPz5w/gR"; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g12si22575826edn.564.2021.05.19.10.43.03; Wed, 19 May 2021 10:43:27 -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=@kernel.org header.s=k20201202 header.b="JPz5w/gR"; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348208AbhERJuk (ORCPT + 99 others); Tue, 18 May 2021 05:50:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:50408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241855AbhERJts (ORCPT ); Tue, 18 May 2021 05:49:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9224A613BD; Tue, 18 May 2021 09:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621331307; bh=Q01LQeqZQsXv68AWl8KkMRey0NZmXny9qiWfV/iWJII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JPz5w/gR25XyMMQKrC4eho1EemJnl53pOfF1NzmpglNZe2RSOE96Kds2ka+HXolIl ptG9/FImIbUYt4QTHoTw4vEoQczjItxnD9p0/oCyeyvLWXoDBMKJr6fM9PoEvqivdt Qeuo8RRkkYfZK/9d3w9v09581ROVM6otSwdPPkj3tXEhj365tYyngsuSoVk/+OVtSO 8ciHGLSgJFmejrB5u2ec+P0dWCRnf4M8egmOVAOC5trF57+RELuZXxxmX6uvul1dS4 0HtzSjMscx1fmZ5IerrD+r7Rbp4Ji0yqMpCqS2/VBuSDB7Zq46J+KSAenmLALaEuYy eEiR99C+3kROg== 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 , Li Zefan , Johannes Weiner , Ingo Molnar , Juri Lelli , Vincent Guittot , "Rafael J. Wysocki" , kernel-team@android.com Subject: [PATCH v6 14/21] freezer: Add frozen_or_skipped() helper function Date: Tue, 18 May 2021 10:47:18 +0100 Message-Id: <20210518094725.7701-15-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210518094725.7701-1-will@kernel.org> References: <20210518094725.7701-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 -- 2.31.1.751.gd2f1c929bd-goog