From: Qais Yousef <qyousef@layalina.io>
To: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
linux-kernel@vger.kernel.org,
Pierre Gondois <Pierre.Gondois@arm.com>
Subject: Re: [PATCH v6 2/4] sched/fair: Check a task has a fitting cpu when updating misfit
Date: Wed, 6 Mar 2024 21:47:04 +0000 [thread overview]
Message-ID: <20240306214704.uditboboedut2lm2@airbuntu> (raw)
In-Reply-To: <20240303174416.7m3gv5wywcmedov4@airbuntu>
On 03/03/24 17:44, Qais Yousef wrote:
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 174687252e1a..b0e60a565945 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8260,6 +8260,8 @@ static void set_task_max_allowed_capacity(struct task_struct *p)
> cpumask_t *cpumask;
>
> cpumask = cpu_capacity_span(entry);
> + if (!cpumask_intersects(cpu_active_mask, cpumask))
> + continue;
> if (!cpumask_intersects(p->cpus_ptr, cpumask))
> continue;
>
> @@ -8269,6 +8271,53 @@ static void set_task_max_allowed_capacity(struct task_struct *p)
> rcu_read_unlock();
> }
>
> +static void __update_tasks_max_allowed_capacity(unsigned long capacity)
> +{
> + struct task_struct *g, *p;
> +
> + for_each_process_thread(g, p) {
> + if (fair_policy(p->policy) && p->max_allowed_capacity == capacity)
This condition actually not good enough. We need to differentiate between going
online/offline. I didn't want to call set_task_max_allowed_capacity()
unconditionally and make hotplug even slower.
I'm doing more testing and will post v8 once done. I need to cater for a new
user when dynamic EM changes capacities too.. Small things can snow ball easily
hehe.
> + set_task_max_allowed_capacity(p);
> + }
> +}
> +
> +/*
> + * Handle a cpu going online/offline changing the available capacity levels.
> + */
> +static void update_tasks_max_allowed_capacity(int cpu, bool online)
> +{
> + struct asym_cap_data *entry;
> + bool do_update = false;
> +
> + if (!sched_asym_cpucap_active())
> + return;
> +
> + if (cpuhp_tasks_frozen)
> + return;
> +
> + rcu_read_lock();
> + /* Did a capacity level appear/disappear? */
> + list_for_each_entry_rcu(entry, &asym_cap_list, link) {
> + unsigned int nr_active;
> + cpumask_t *cpumask;
> +
> + cpumask = cpu_capacity_span(entry);
> +
> + if (!cpumask_test_cpu(cpu, cpumask))
> + continue;
> +
> + nr_active = cpumask_weight_and(cpu_active_mask, cpumask);
> + if (online)
> + do_update = nr_active == 1;
> + else
> + do_update = !nr_active;
> + break;
> + }
> + if (do_update)
> + __update_tasks_max_allowed_capacity(entry->capacity);
> + rcu_read_unlock();
> +}
> +
> static void set_cpus_allowed_fair(struct task_struct *p, struct affinity_context *ctx)
> {
> set_cpus_allowed_common(p, ctx);
> @@ -12500,6 +12549,8 @@ static void rq_online_fair(struct rq *rq)
> update_sysctl();
>
> update_runtime_enabled(rq);
> +
> + update_tasks_max_allowed_capacity(cpu_of(rq), true);
> }
>
> static void rq_offline_fair(struct rq *rq)
> @@ -12511,6 +12562,8 @@ static void rq_offline_fair(struct rq *rq)
>
> /* Ensure that we remove rq contribution to group share: */
> clear_tg_offline_cfs_rqs(rq);
> +
> + update_tasks_max_allowed_capacity(cpu_of(rq), false);
> }
>
> #endif /* CONFIG_SMP */
> --
> 2.34.1
next prev parent reply other threads:[~2024-03-06 21:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-20 22:56 [PATCH v6 0/4] sched: Don't trigger misfit if affinity is restricted Qais Yousef
2024-02-20 22:56 ` [PATCH v6 1/4] sched/topology: Export asym_capacity_list Qais Yousef
2024-02-23 9:30 ` Vincent Guittot
2024-02-20 22:56 ` [PATCH v6 2/4] sched/fair: Check a task has a fitting cpu when updating misfit Qais Yousef
2024-02-23 9:30 ` Vincent Guittot
2024-02-23 13:48 ` [PATCH v7] " Qais Yousef
2024-02-23 13:50 ` [PATCH v6 2/4] " Qais Yousef
2024-02-27 9:42 ` Dietmar Eggemann
2024-03-03 17:44 ` Qais Yousef
2024-03-06 21:47 ` Qais Yousef [this message]
2024-03-07 9:14 ` Vincent Guittot
2024-03-07 10:35 ` Qais Yousef
2024-03-07 17:54 ` Dietmar Eggemann
2024-03-21 12:20 ` Qais Yousef
2024-02-20 22:56 ` [PATCH v6 3/4] sched/topology: Remove max_cpu_capacity from root_domain Qais Yousef
2024-02-23 9:31 ` Vincent Guittot
2024-02-20 22:56 ` [PATCH v6 4/4] sched/fair: Don't double balance_interval for migrate_misfit Qais Yousef
2024-02-23 9:32 ` Vincent Guittot
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=20240306214704.uditboboedut2lm2@airbuntu \
--to=qyousef@layalina.io \
--cc=Pierre.Gondois@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=vincent.guittot@linaro.org \
/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®