Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3460486rwo; Fri, 4 Aug 2023 05:25:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXGMbFcdctkN/M+cUa2CCJmbQwUHE6MGDNihfXm0sj6zSQq8PTNZZAwKTtABDom8bgevKZ X-Received: by 2002:a17:90a:2805:b0:268:47c2:e490 with SMTP id e5-20020a17090a280500b0026847c2e490mr1241038pjd.1.1691151952175; Fri, 04 Aug 2023 05:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691151952; cv=none; d=google.com; s=arc-20160816; b=RWZPtTRbSPkQtYPI/JDp+ZjeyhSI1ZFS11aZJJ0rOGFrc9BpthryemdpgJWbxZWgsg 7kPt7VwP4qdXyKg4ZueDH1+NtnF4hXvqoqn7gh3J2j6NYYdlLpKf8TzqoFPVI1MPTDH8 rODlsIJOph5g/6qqYlGGPzb6DgShFuCZLR1CkN8EiSL5KeRXVuWEObXhjz0UfWClX0TA a9AFYkPZO3rTnak66S+QimTICllH9fihidW3A7xsgCXLXlbKGynYRfR5pSnUV2XHWPao Lxb+PuROct1hz0tmfxu8bh6yammAEE3BCBcmdScP02FxWjAebYAsDeCBQWDSflGOergq 8wNw== 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:dkim-signature :dkim-signature:from; bh=1T2AeWiya68KJLNtsfeN+eBKy/0/70O9BggovBkInGY=; fh=w7Jnui2cUMiTJ2TUWQmWTtlLGVu4EPXAehuv8FR1tDs=; b=Z9zcWcUnUcbDCD8v4WCyoCusz8yd/SK4DfokvN+kgNjZ/FZnqFwV3lW1/IbXPTjFJZ 4XlN+QnbmwCqEAJZJK2qz8jsEKbKeGmWCXQdpQ0Onax+RMA/KRRegbzPtWVHfttFEYGP 0eVybOXJfWTDIp7tunB0PAZ97JjWhPQ+Ktut4rlJ/Bk3JRapGeiq1yPMcKAwCSjx2X6e d1PNjVCs+7nJDiNj5KQnkN96UOumOm2UmRzU/KwpoB8UOsn4m7CNCAELcyzkGmIUacRg 6gFHLKHTue80t/y49QK+zRSmsJN4sk29e+V7KQbekaKschN6bs72lt4bTFDEdYMgvLvt ZHVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=TMbtZKjl; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a17090ad98800b002682498d8c0si4898833pjv.187.2023.08.04.05.25.40; Fri, 04 Aug 2023 05:25:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=TMbtZKjl; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229942AbjHDLav (ORCPT + 99 others); Fri, 4 Aug 2023 07:30:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbjHDLau (ORCPT ); Fri, 4 Aug 2023 07:30:50 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFA43E7 for ; Fri, 4 Aug 2023 04:30:48 -0700 (PDT) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691148646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1T2AeWiya68KJLNtsfeN+eBKy/0/70O9BggovBkInGY=; b=TMbtZKjleCooMYS4uB+lFWSsOnrkfX78pGv4mnOlxMBKg3E2ejw5zXx0u3O6gMNvieET3J 04ATwz6F+0bDOXBWORbVMRd8OJAAccCU4CWW4K6uPliemgFaKdv7BGUUhByp+XLMLA+9ns 1HsIoYmrY1yzqNWCpYmpA9wWKGZWR4rWpp3QgtIN+6EtfYTUakId2RVn6tGcDRz6SK2jb0 cWjoXqT9vE0NmHUsdlBLnGltEBavXcuWF8YCgvOPGbA+azZnx2EtSqfweNQjuPMZg14I9E fWA0NlOc04Zdqf7F5lTvaAQgq+IS1SqEROuTeer8O5CfIbS8fxi8NHdqDXXiWg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691148646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1T2AeWiya68KJLNtsfeN+eBKy/0/70O9BggovBkInGY=; b=t4Ak2F4YBaw6B5zQGDc8F5Hl/F8C2wCrFjOfUK3CFag/dBDbS/qZKLFT52bbDHmN1EYuQZ I/hCb6EvOE6K6LAg== To: linux-kernel@vger.kernel.org Cc: Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Frederic Weisbecker , Ingo Molnar , John Stultz , Juri Lelli , Mel Gorman , Peter Zijlstra , Stephen Boyd , Steven Rostedt , Thomas Gleixner , Valentin Schneider , Vincent Guittot , Sebastian Andrzej Siewior Subject: [RFC PATCH 1/3] sched/core: Provide a method to check if a task is PI-boosted. Date: Fri, 4 Aug 2023 13:30:37 +0200 Message-Id: <20230804113039.419794-2-bigeasy@linutronix.de> In-Reply-To: <20230804113039.419794-1-bigeasy@linutronix.de> References: <20230804113039.419794-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Provide a method to check if a task inherited the priority from another task. This happens if a task owns a lock which is requested by a task with higher priority. This can be used as a hint to add a preemption point to the critical section. Provide a function which reports true if the task is PI-boosted. Signed-off-by: Sebastian Andrzej Siewior --- include/linux/sched.h | 1 + kernel/sched/core.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index 609bde814cb06..77fd274133750 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1887,6 +1887,7 @@ static inline int dl_task_check_affinity(struct task_= struct *p, const struct cpu } #endif =20 +extern bool task_is_pi_boosted(const struct task_struct *p); extern int yield_to(struct task_struct *p, bool preempt); extern void set_user_nice(struct task_struct *p, long nice); extern int task_prio(const struct task_struct *p); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index c52c2eba7c739..132f06522efa0 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -8886,6 +8886,21 @@ static inline void preempt_dynamic_init(void) { } =20 #endif /* #ifdef CONFIG_PREEMPT_DYNAMIC */ =20 +/* + * task_is_pi_boosted - Check if task has been PI boosted. + * @p: Task to check. + * + * Return true if task is subject to priority inheritance. + */ +bool task_is_pi_boosted(const struct task_struct *p) +{ + int prio =3D p->prio; + + if (!rt_prio(prio)) + return false; + return prio !=3D p->normal_prio; +} + /** * yield - yield the current processor to other threads. * --=20 2.40.1