mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Andrea Righi <arighi@nvidia.com>
Cc: David Vernet <void@manifault.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] sched_ext: Introduce NUMA awareness to the default idle selection policy
Date: Sun, 27 Oct 2024 08:03:53 -1000	[thread overview]
Message-ID: <Zx6AiTja6jX7bC7R@slm.duckdns.org> (raw)
In-Reply-To: <20241027174953.49655-1-arighi@nvidia.com>

Hello,

On Sun, Oct 27, 2024 at 06:49:53PM +0100, Andrea Righi wrote:
...
> +static void update_selcpu_topology(void)
>  {
> +	bool enable_llc = false, enable_numa = false;
> +	s32 cpu;
>  
> +	rcu_read_lock();
> +	for_each_possible_cpu(cpu) {
> +		struct sched_domain *sd;
> +		const struct cpumask *cpus;
> +
> +		sd = rcu_dereference(per_cpu(sd_llc, cpu));
> +		if (sd) {
> +			cpus = sched_domain_span(sd);
> +			pr_debug("sched_ext: LLC cpu%d: %*pbl\n",
> +				 cpu, cpumask_pr_args(cpus));
> +			if (cpumask_weight(cpus) < num_possible_cpus())
> +				enable_llc = true;
> +		}
> +
> +		sd = highest_flag_domain(cpu, SD_NUMA);
> +		if (sd) {
> +			cpus = sched_group_span(sd->groups);
> +			pr_debug("sched_ext: NUMA cpu%d: %*pbl\n",
> +				 cpu, cpumask_pr_args(cpus));
> +			if (cpumask_weight(cpus) < num_possible_cpus())
> +				enable_numa = true;

This isn't a big problem but the loop looks a bit odd in that once both are
set, it's obvious that there's no reason to continue. Doesn't this need to
check only one CPU in fact? e.g. for the first possible CPU, if sd doesn't
exist or cpumask_weight(sd) == num_possible_cpu(), don't we know for sure
that llc or numa doesn't need to be enabled and vice-versa?

>  static s32 scx_select_cpu_dfl(struct task_struct *p, s32 prev_cpu,
>  			      u64 wake_flags, bool *found)
>  {
> +	const struct cpumask *llc_cpus = NULL;
> +	const struct cpumask *numa_cpus = NULL;
>  	s32 cpu;
>  
>  	*found = false;
...
> +	if (p->nr_cpus_allowed >= num_possible_cpus()) {
> +		if (static_branch_unlikely(&scx_selcpu_topo_numa))
> +			numa_cpus = cpumask_of_node(cpu_to_node(prev_cpu));
> +
> +		if (static_branch_unlikely(&scx_selcpu_topo_llc)) {

static_branch_maybe() is probably the better one for llc.

Thanks.

-- 
tejun

  reply	other threads:[~2024-10-27 18:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-27 17:49 Andrea Righi
2024-10-27 18:03 ` Tejun Heo [this message]
2024-10-27 18:51   ` Andrea Righi

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=Zx6AiTja6jX7bC7R@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=arighi@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=void@manifault.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

all inboxes | Powered by JetHome®