From: Swapnil Sapkal <Swapnil.Sapkal@amd.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: mingo@redhat.com, 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, iamjoonsoo.kim@lge.com,
linux-kernel@vger.kernel.org, gautham.shenoy@amd.com,
kprateek.nayak@amd.com, wyes.karny@amd.com
Subject: Re: [PATCH 2/2] sched/fair: Cleanup in migrate_degrades_locality() to improve readability
Date: Wed, 21 Jun 2023 10:14:10 +0530 [thread overview]
Message-ID: <4ff99651-fee5-f62c-0a19-9bd599de54c5@amd.com> (raw)
In-Reply-To: <20230619094529.GL4253@hirez.programming.kicks-ass.net>
Hello Peter,
On 6/19/2023 3:15 PM, Peter Zijlstra wrote:
> On Wed, Jun 14, 2023 at 10:22:24AM +0000, Swapnil Sapkal wrote:
>> The migrate_degrades_locality() returns tristate value whether
>> the migration will improve locality, degrades locality or no
>> impact. Handle this return values with enum to improve the
>> readability.
>
> I can see how you ended up there, that tristate is weird, but perhaps
> don't make it more complicated than it should be?
>
> ---
> kernel/sched/fair.c | 39 ++++++++++++++++++++-------------------
> 1 file changed, 20 insertions(+), 19 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 373ff5f55884..a8449f594348 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8446,42 +8446,42 @@ static int task_hot(struct task_struct *p, struct lb_env *env)
> #ifdef CONFIG_NUMA_BALANCING
> /*
> * Returns 1, if task migration degrades locality
> - * Returns 0, if task migration improves locality i.e migration preferred.
> - * Returns -1, if task migration is not affected by locality.
> + * Returns 0, if task migration is not affected by locality.
> + * Returns -1, if task migration improves locality i.e migration preferred.
> */
Because of the following hunk:
> @@ -8492,14 +8492,14 @@ static int migrate_degrades_locality(struct task_struct *p, struct lb_env *env)
> dst_weight = task_weight(p, dst_nid, dist);
> }
>
> - return dst_weight < src_weight;
> + return src_weight - dst_weight;
> }
>
I suppose we should also change the comment to:
/*
* Returns a positive value, if task migration degrades locality
* Returns 0, if task migration is not affected by locality.
* Returns a negative value, if task migration improves locality i.e migration preferred.
*/
Do I need to resend v2 with your changes for this patchset?
> -static int migrate_degrades_locality(struct task_struct *p, struct lb_env *env)
> +static long migrate_degrades_locality(struct task_struct *p, struct lb_env *env)
> {
> struct numa_group *numa_group = rcu_dereference(p->numa_group);
> unsigned long src_weight, dst_weight;
> int src_nid, dst_nid, dist;
>
> if (!static_branch_likely(&sched_numa_balancing))
> - return -1;
> + return 0;
>
> if (!p->numa_faults || !(env->sd->flags & SD_NUMA))
> - return -1;
> + return 0;
>
> src_nid = cpu_to_node(env->src_cpu);
> dst_nid = cpu_to_node(env->dst_cpu);
>
> if (src_nid == dst_nid)
> - return -1;
> + return 0;
>
> /* Migrating away from the preferred node is always bad. */
> if (src_nid == p->numa_preferred_nid) {
> if (env->src_rq->nr_running > env->src_rq->nr_preferred_running)
> return 1;
> else
> - return -1;
> + return 0;
> }
>
> /* Encourage migration to the preferred node. */
> if (dst_nid == p->numa_preferred_nid)
> - return 0;
> + return -1;
>
> /* Leaving a core idle is often worse than degrading locality. */
> if (env->idle == CPU_IDLE)
> - return -1;
> + return 0;
>
> dist = node_distance(src_nid, dst_nid);
> if (numa_group) {
> @@ -8492,14 +8492,14 @@ static int migrate_degrades_locality(struct task_struct *p, struct lb_env *env)
> dst_weight = task_weight(p, dst_nid, dist);
> }
>
> - return dst_weight < src_weight;
> + return src_weight - dst_weight;
> }
--
Thanks and regards,
Swapnil
prev parent reply other threads:[~2023-06-21 4:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-14 10:22 [PATCH 0/2] Cleanup and Fix for wrong accounting of migrated cache hot tasks Swapnil Sapkal
2023-06-14 10:22 ` [PATCH 1/2] sched/fair: Fix value reported by hot tasks pulled in /proc/schedstat Swapnil Sapkal
2023-06-19 9:22 ` Peter Zijlstra
2023-06-21 4:38 ` Swapnil Sapkal
2023-06-14 10:22 ` [PATCH 2/2] sched/fair: Cleanup in migrate_degrades_locality() to improve readability Swapnil Sapkal
2023-06-19 9:45 ` Peter Zijlstra
2023-06-21 4:44 ` Swapnil Sapkal [this message]
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=4ff99651-fee5-f62c-0a19-9bd599de54c5@amd.com \
--to=swapnil.sapkal@amd.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=gautham.shenoy@amd.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=wyes.karny@amd.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;
as well as URLs for NNTP newsgroup(s).