From: Peter Zijlstra <peterz@infradead.org>
To: Hao Jia <jiahao.os@bytedance.com>
Cc: mingo@redhat.com, mingo@kernel.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
bristot@redhat.com, vschneid@redhat.com,
mgorman@techsingularity.net, linux-kernel@vger.kernel.org,
Cruz Zhao <CruzZhao@linux.alibaba.com>
Subject: Re: [PATCH] sched/core: Avoid selecting the task that is throttled to run when core-sched enable
Date: Mon, 20 Mar 2023 13:47:01 +0100 [thread overview]
Message-ID: <20230320124701.GL2194297@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20230316081806.69544-1-jiahao.os@bytedance.com>
On Thu, Mar 16, 2023 at 04:18:06PM +0800, Hao Jia wrote:
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index af017e038b48..27cb06e19b12 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -261,36 +261,51 @@ void sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags)
> resched_curr(rq);
> }
>
> +static int sched_task_is_throttled(struct task_struct *p, int cpu)
> {
> + if (p->sched_class->task_is_throttled)
> + return p->sched_class->task_is_throttled(p, cpu);
>
> + return 0;
> }
>
> static struct task_struct *sched_core_next(struct task_struct *p, unsigned long cookie)
> {
> struct rb_node *node = &p->core_node;
> + int cpu = task_cpu(p);
> +
> + do {
> + node = rb_next(node);
> + if (!node)
> + return NULL;
> +
> + p = container_of(node, struct task_struct, core_node);
I've changed this to __node_2_sc() to match the rest. It looks to have
been randomly not using it.
> + if (p->core_cookie != cookie)
> + return NULL;
> + } while (sched_task_is_throttled(p, cpu));
> +
> + return p;
> +}
>
> +/*
> + * Find left-most (aka, highest priority) and unthrottled task matching @cookie.
> + * If no suitable task is found, NULL will be returned.
> + */
> +static struct task_struct *sched_core_find(struct rq *rq, unsigned long cookie)
> +{
> + struct task_struct *p;
> + struct rb_node *node;
> +
> + node = rb_find_first((void *)cookie, &rq->core_tree, rb_sched_core_cmp);
> if (!node)
> return NULL;
>
> + p = __node_2_sc(node);
> + if (!sched_task_is_throttled(p, rq->cpu))
> + return p;
> +
> + return sched_core_next(p, cookie);
> }
>
> /*
OK, fair enough.
next prev parent reply other threads:[~2023-03-20 12:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-16 8:18 Hao Jia
2023-03-20 12:47 ` Peter Zijlstra [this message]
2023-03-21 6:16 ` [External] " Hao Jia
2023-03-21 9:07 ` Peter Zijlstra
2023-03-22 9:22 ` [tip: sched/core] " tip-bot2 for Hao Jia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230320124701.GL2194297@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=CruzZhao@linux.alibaba.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=jiahao.os@bytedance.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mgorman@techsingularity.net \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome