Message ID | 20230804113039.419794-2-bigeasy@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:44a:b0:3f2:4152:657d with SMTP id ez10csp237733vqb; Fri, 4 Aug 2023 05:50:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEbgp6Nl5IyYhvykc3WPil4zngcB0rZQwS7JHnMaV9kTmeHWNbu84+gOYkzioOF+mv3eF4h X-Received: by 2002:a05:6a00:1306:b0:668:73f5:dce0 with SMTP id j6-20020a056a00130600b0066873f5dce0mr1406697pfu.29.1691153435740; Fri, 04 Aug 2023 05:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691153435; cv=none; d=google.com; s=arc-20160816; b=RMLvUKLta/mVfZCcS1PeEV2wL63L4F0oVa1E1RRvm6Uuq/4BNOSsjWMojHNTf1MFSl Trf8fZz2KwcowwbG4v2jUOlwCvd4BIDa98M7EZkRMHYctDGGl1N25hFM5lmut6JB0HvB i7oXcR8upz6fpA5kiJFDqWM3+lABpDI5nSD8bqc47JfMns+9sV+tlYY8pVrygvetxJXn vFKsDVBag1vLM8HqCx0SDi6Mu8aRCe2LCCPB0UzUZWbaDk9AuJNWGIHpfOAg1j5LKNKr nfccl4GPXbESwe59b+5xPjmGuDLesI0oc7W6jzMUXrpCVdxQSALiqfvjA/1viJIQXAD7 SyZg== 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 header.b=t4Ak2F4Y; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bu8-20020a056a00410800b0067801694c31si1643317pfb.383.2023.08.04.05.50.22; Fri, 04 Aug 2023 05:50:35 -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 header.b=t4Ak2F4Y; 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 S230003AbjHDLaw (ORCPT <rfc822;sukrut.bellary@gmail.com> + 99 others); Fri, 4 Aug 2023 07:30:52 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; Fri, 4 Aug 2023 04:30:48 -0700 (PDT) From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> 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 <bsegall@google.com>, Daniel Bristot de Oliveira <bristot@redhat.com>, Dietmar Eggemann <dietmar.eggemann@arm.com>, Frederic Weisbecker <frederic@kernel.org>, Ingo Molnar <mingo@redhat.com>, John Stultz <jstultz@google.com>, Juri Lelli <juri.lelli@redhat.com>, Mel Gorman <mgorman@suse.de>, Peter Zijlstra <peterz@infradead.org>, Stephen Boyd <sboyd@kernel.org>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, Valentin Schneider <vschneid@redhat.com>, Vincent Guittot <vincent.guittot@linaro.org>, Sebastian Andrzej Siewior <bigeasy@linutronix.de> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773302905352887497 X-GMAIL-MSGID: 1773302905352887497 |
Series |
Allow to preempt a timer softirq on PREEMPT_RT.
|
|
Commit Message
Sebastian Andrzej Siewior
Aug. 4, 2023, 11:30 a.m. UTC
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 <bigeasy@linutronix.de>
---
include/linux/sched.h | 1 +
kernel/sched/core.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
Comments
Hi, Apologies for noticing only now, but I believe this is still part of the 6.6-rt patches and I've got the below question to ask. On 04/08/23 13:30, Sebastian Andrzej Siewior wrote: > 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 <bigeasy@linutronix.de> > --- > 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 > > +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) { } > > #endif /* #ifdef CONFIG_PREEMPT_DYNAMIC */ > > +/* > + * 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 = p->prio; > + > + if (!rt_prio(prio)) > + return false; > + return prio != p->normal_prio; Does this need to also take DEADLINE tasks into consideration? We don't change priority when they are boosted, only pi_se changes (please check is_dl_boosted()). Thanks, Juri
On 2023-11-02 10:30:50 [+0100], Juri Lelli wrote: > Hi, Hi, > Apologies for noticing only now, but I believe this is still part of the > 6.6-rt patches and I've got the below question to ask. I'm not sure if we want this. I do have an alternative solution in the meantime. > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -8886,6 +8886,21 @@ static inline void preempt_dynamic_init(void) { } > > > > #endif /* #ifdef CONFIG_PREEMPT_DYNAMIC */ > > > > +/* > > + * 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 = p->prio; > > + > > + if (!rt_prio(prio)) > > + return false; > > + return prio != p->normal_prio; > > Does this need to also take DEADLINE tasks into consideration? We don't > change priority when they are boosted, only pi_se changes (please check > is_dl_boosted()). If we want this, then probably yes. Isn't task_struct::prio for the DL (boosted) task set to 0? While the RT priority go from 1…MAX_RT_PRIO - 1. > Thanks, > Juri Sebastian
On 02/11/23 17:03, Sebastian Andrzej Siewior wrote: > On 2023-11-02 10:30:50 [+0100], Juri Lelli wrote: > > Hi, > Hi, > > > Apologies for noticing only now, but I believe this is still part of the > > 6.6-rt patches and I've got the below question to ask. > > I'm not sure if we want this. I do have an alternative solution in the > meantime. Ah, OK. Guess what below is moot then. :) Will be watching for the alternative solution to show up. > > > > --- a/kernel/sched/core.c > > > +++ b/kernel/sched/core.c > > > @@ -8886,6 +8886,21 @@ static inline void preempt_dynamic_init(void) { } > > > > > > #endif /* #ifdef CONFIG_PREEMPT_DYNAMIC */ > > > > > > +/* > > > + * 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 = p->prio; > > > + > > > + if (!rt_prio(prio)) > > > + return false; > > > + return prio != p->normal_prio; > > > > Does this need to also take DEADLINE tasks into consideration? We don't > > change priority when they are boosted, only pi_se changes (please check > > is_dl_boosted()). > > If we want this, then probably yes. > Isn't task_struct::prio for the DL (boosted) task set to 0? While the RT > priority go from 1…MAX_RT_PRIO - 1. But then we can also have DL on DL boosting and in this case only the pi_se changes while prio stays the same. But, again, looks like this is moot anyway. Thanks! Juri
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 +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) { } #endif /* #ifdef CONFIG_PREEMPT_DYNAMIC */ +/* + * 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 = p->prio; + + if (!rt_prio(prio)) + return false; + return prio != p->normal_prio; +} + /** * yield - yield the current processor to other threads. *