From: Reinette Chatre <reinette.chatre@intel.com>
To: Peter Newman <peternewman@google.com>, <fenghua.yu@intel.com>
Cc: <Babu.Moger@amd.com>, <bp@alien8.de>,
<dave.hansen@linux.intel.com>, <eranian@google.com>,
<gupasani@google.com>, <hpa@zytor.com>, <james.morse@arm.com>,
<linux-kernel@vger.kernel.org>, <mingo@redhat.com>,
<skodak@google.com>, <tglx@linutronix.de>, <tony.luck@intel.com>,
<x86@kernel.org>
Subject: Re: [PATCH v4 2/3] x86/resctrl: Parameterize rdt_move_group_tasks() task matching
Date: Thu, 23 Mar 2023 11:02:03 -0700 [thread overview]
Message-ID: <f103ec28-01b4-d4ca-f6e9-d557ea4efb81@intel.com> (raw)
In-Reply-To: <20230308131452.383914-3-peternewman@google.com>
Hi Peter,
On 3/8/2023 5:14 AM, Peter Newman wrote:
> Allow rdt_move_group_tasks() to be used for new group-scope operations.
This changelog jumps right into the solution. By doing so it makes what
follows hard to parse. Could you please start with the context, then
the problem and end with the solution?
> This function is currently only used to implement rmdir on a group or
> unmounting resctrlfs.
>
> Callers now provide a filtering function to indicate which tasks should
> be moved.
>
> No functional change.
>
> Signed-off-by: Peter Newman <peternewman@google.com>
> ---
> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 34 +++++++++++++++++++-------
> 1 file changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index c3fb525d52e9..84af23a29612 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -2393,22 +2393,29 @@ static int reset_all_ctrls(struct rdt_resource *r)
> }
>
> /*
> - * Move tasks from one to the other group. If @from is NULL, then all tasks
> - * in the systems are moved unconditionally (used for teardown).
> + * Move tasks from one to the other group.
> + *
> + * @from: passed unmodified to task_match_fn() for each task
When using this format it usually starts with a description of the parameter
before moving to how the parameter is used. Perhaps prefix the above with
something like "Resource group tasks are moved from." (Please feel free to
improve.) When starting to provide multiple sentences it helps formatting
to have each sentence start with a capital letter and end with a period.
> + * @to: group providing new config values for matching tasks
> + * @task_match_fn: callback returning true when a task requires update
Could this order please match the order of the parameters in the function?
> + * @mask: output-parameter indicating set of CPUs impacted by this
> + * operation
> *
> * If @mask is not NULL the cpus on which moved tasks are running are set
> * in that mask so the update smp function call is restricted to affected
> * cpus.
Could the above be merged with the earlier description of @mask? Please change
cpus to CPUs if you do.
> */
> -static void rdt_move_group_tasks(struct rdtgroup *from, struct rdtgroup *to,
> - struct cpumask *mask)
> +static void rdt_move_group_tasks(struct rdtgroup *from,
> + struct rdtgroup *to,
> + struct cpumask *mask,
> + bool task_match_fn(struct task_struct *,
> + struct rdtgroup *))
> {
> struct task_struct *p, *t;
>
> read_lock(&tasklist_lock);
> for_each_process_thread(p, t) {
> - if (!from || is_closid_match(t, from) ||
> - is_rmid_match(t, from)) {
> + if (task_match_fn(t, from)) {
> WRITE_ONCE(t->closid, to->closid);
> WRITE_ONCE(t->rmid, to->mon.rmid);
>
> @@ -2451,6 +2458,15 @@ static void free_all_child_rdtgrp(struct rdtgroup *rdtgrp)
> }
> }
>
> +/*
> + * If @from is NULL, then all tasks in the systems are moved unconditionally
> + * (used for teardown).
Could this description be expanded to describe what the matching does? Just jumping
in with the above sentence is quite cryptic.
> + */
> +static bool rmdir_match(struct task_struct *t, struct rdtgroup *from)
Could the function's name please reflect what the function does as opposed to
what the current users are doing at the time they call it? Perhaps
something like "task_in_any_group()" (thinking ahead about a possible
"task_in_mon_group()" for the next patch, please feel free to change).
Also note that the "from" is another naming that reflects the usage as
opposed to what the function does. It could just be "rdtgrp".
> +{
> + return !from || is_closid_match(t, from) || is_rmid_match(t, from);
> +}
> +
> /*
> * Forcibly remove all of subdirectories under root.
> */
> @@ -2459,7 +2475,7 @@ static void rmdir_all_sub(void)
> struct rdtgroup *rdtgrp, *tmp;
>
> /* Move all tasks to the default resource group */
> - rdt_move_group_tasks(NULL, &rdtgroup_default, NULL);
> + rdt_move_group_tasks(NULL, &rdtgroup_default, NULL, rmdir_match);
>
> list_for_each_entry_safe(rdtgrp, tmp, &rdt_all_groups, rdtgroup_list) {
> /* Free any child rmids */
> @@ -3124,7 +3140,7 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)
> int cpu;
>
> /* Give any tasks back to the parent group */
> - rdt_move_group_tasks(rdtgrp, prdtgrp, tmpmask);
> + rdt_move_group_tasks(rdtgrp, prdtgrp, tmpmask, rmdir_match);
>
> /* Update per cpu rmid of the moved CPUs first */
> for_each_cpu(cpu, &rdtgrp->cpu_mask)
> @@ -3164,7 +3180,7 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)
> int cpu;
>
> /* Give any tasks back to the default group */
> - rdt_move_group_tasks(rdtgrp, &rdtgroup_default, tmpmask);
> + rdt_move_group_tasks(rdtgrp, &rdtgroup_default, tmpmask, rmdir_match);
>
> /* Give any CPUs back to the default group */
> cpumask_or(&rdtgroup_default.cpu_mask,
This looks good. Thanks for creating the match function. I think it
turned out well.
Reinette
next prev parent reply other threads:[~2023-03-23 18:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 13:14 [PATCH v4 0/3] Subject: x86/resctrl: Implement rename to help move containers' tasks Peter Newman
2023-03-08 13:14 ` [PATCH v4 1/3] x86/resctrl: Factor rdtgroup lock for multi-file ops Peter Newman
2023-03-23 17:58 ` Reinette Chatre
2023-03-08 13:14 ` [PATCH v4 2/3] x86/resctrl: Parameterize rdt_move_group_tasks() task matching Peter Newman
2023-03-23 18:02 ` Reinette Chatre [this message]
2023-03-30 12:50 ` Peter Newman
2023-03-08 13:14 ` [PATCH v4 3/3] x86/resctrl: Implement rename op for mon groups Peter Newman
2023-03-23 18:08 ` Reinette Chatre
2023-03-30 13:43 ` Peter Newman
2023-04-03 18:21 ` Reinette Chatre
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=f103ec28-01b4-d4ca-f6e9-d557ea4efb81@intel.com \
--to=reinette.chatre@intel.com \
--cc=Babu.Moger@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=eranian@google.com \
--cc=fenghua.yu@intel.com \
--cc=gupasani@google.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peternewman@google.com \
--cc=skodak@google.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=x86@kernel.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®