From: "Moger, Babu" <babu.moger@amd.com>
To: "Yu, Fenghua" <fenghua.yu@intel.com>,
"Chatre, Reinette" <reinette.chatre@intel.com>
Cc: "tglx@linutronix.de" <tglx@linutronix.de>,
"mingo@redhat.com" <mingo@redhat.com>,
"bp@alien8.de" <bp@alien8.de>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"x86@kernel.org" <x86@kernel.org>,
"hpa@zytor.com" <hpa@zytor.com>,
"corbet@lwn.net" <corbet@lwn.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"Eranian, Stephane" <eranian@google.com>,
"peternewman@google.com" <peternewman@google.com>,
"Shankar, Ravi V" <ravi.v.shankar@intel.com>
Subject: Re: [RFC PATCH 2/3] x86/resctrl: Move the task's threads to the group automatically
Date: Wed, 4 Jan 2023 11:49:57 -0600 [thread overview]
Message-ID: <e3b5286f-469e-90ba-e4a9-09153c9562d4@amd.com> (raw)
In-Reply-To: <IA1PR11MB6097CF779BF29E7F716108849BF59@IA1PR11MB6097.namprd11.prod.outlook.com>
Hi Fenghua,
On 1/3/23 23:55, Yu, Fenghua wrote:
> Hi, Babu,
>
>> Some micro benchmarks run multiple threads when started. Monitoring (or
>> controlling) the benchmark using the task id is bit tricky. Users need to track all
>> the threads and assign them individually to monitor or control. For example:
>> $stream_lowOverhead -codeAlg 13 -nRep 100000 -cores 0 1 2 3 -memMB 32
>> -alignKB 8192 -aPadB 0 -bPadB 0 -cPadB 0 -testMask 1
>>
>> $pidof stream_lowOverhead
>> 6793
>>
>> This benchmark actually runs multiple threads underneath on the cores listed
>> above. It can be seen with the command:
>> $ps -T -p 6793
>> PID SPID TTY TIME CMD
>> 6793 6793 pts/2 00:00:00 stream_lowOverh
>> 6793 6802 pts/2 00:01:25 stream_lowOverh
>> 6793 6803 pts/2 00:01:25 stream_lowOverh
>> 6793 6804 pts/2 00:01:25 stream_lowOverh
>> 6793 6805 pts/2 00:01:25 stream_lowOverh
>>
>> Users need to assign these threads individually to the resctrl group for
>> monitoring or controlling.
>>
>> $echo 6793 > /sys/fs/restrl/clos1/tasks
>> $echo 6802 > /sys/fs/restrl/clos1/tasks
>> $echo 6803 > /sys/fs/restrl/clos1/tasks
>> $echo 6804 > /sys/fs/restrl/clos1/tasks
>> $echo 6805 > /sys/fs/restrl/clos1/tasks
>>
>> That is not easy when dealing with numerous threads.
>>
>> Detect the task's threads automatically and assign them to the resctrl group
>> when parent task is assigned. For example:
> But user may choose not to move threads along with the parent.
> You will need to have an option to opt in.
Yes. I agree.
>
>> $echo 6793 > /sys/fs/restrl/clos1/tasks
>>
>> All the threads will be assigned to the group automatically.
>> $cat /sys/fs/restrl/clos1/tasks
>> 6793
>> 6793
>> 6802
>> 6803
>> 6804
>> 6805
>>
>> Signed-off-by: Babu Moger <babu.moger@amd.com>
>> ---
>> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 9 ++++++++-
>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> index 344607853f4c..0d71ed22cfa9 100644
>> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> @@ -685,6 +685,7 @@ static int rdtgroup_move_task(pid_t pid, struct rdtgroup
>> *rdtgrp, static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of,
>> char *buf, size_t nbytes, loff_t off) {
>> + struct task_struct *task, *thread;
>> struct rdtgroup *rdtgrp;
>> char *pid_str;
>> int ret = 0;
>> @@ -723,7 +724,13 @@ static ssize_t rdtgroup_tasks_write(struct
>> kernfs_open_file *of,
>> goto exit;
>> }
>>
>> - ret = rdtgroup_move_task(pid, rdtgrp, of);
>> + task = find_task_by_vpid(pid);
>> + thread = task;
>> + do {
>> + ret = rdtgroup_move_task(thread->pid, rdtgrp, of);
>> + if (ret)
>> + goto exit;
> If failure happens in the middle of threads, will you reverse the previous
> moved threads (or even the task) or will you report this failure and move
> to the next thread? Seems to me you need to either move all threads or
> no thread moved at all.
Yes. We should handle the failures properly. Reversing all previous
movements requires quite a bit of book keeping.
As a work-around Reinette's comment "echo $$ >
/sys/fs/resctrl/clos1/tasks" seems to move all the threads.
I will have to think about this more closely.
Thanks
Babu
>
>> + } while_each_thread(task, thread);
>>
>> goto next;
>>
>>
> Thanks.
>
> -Fenghua
--
Thanks
Babu Moger
next prev parent reply other threads:[~2023-01-04 17:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-03 22:06 [RFC PATCH 0/3] x86/resctrl: Miscellaneous resctrl features Babu Moger
2023-01-03 22:06 ` [RFC PATCH 1/3] x86/resctrl: Add multiple tasks to the resctrl group at once Babu Moger
2023-01-04 5:46 ` Yu, Fenghua
2023-01-04 17:20 ` Moger, Babu
2023-01-03 22:06 ` [RFC PATCH 2/3] x86/resctrl: Move the task's threads to the group automatically Babu Moger
2023-01-04 5:55 ` Yu, Fenghua
2023-01-04 17:49 ` Moger, Babu [this message]
2023-01-04 16:43 ` Reinette Chatre
2023-01-04 18:06 ` Moger, Babu
2023-01-03 22:06 ` [RFC PATCH 3/3] x86/resctrl: Display the RMID and COSID for resctrl groups Babu Moger
2023-01-04 6:06 ` Yu, Fenghua
2023-01-04 6:45 ` Stephane Eranian
2023-01-04 18:01 ` Moger, Babu
2023-01-04 17:58 ` Moger, Babu
2023-01-04 23:54 ` Yu, Fenghua
2023-01-05 15:48 ` Moger, Babu
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=e3b5286f-469e-90ba-e4a9-09153c9562d4@amd.com \
--to=babu.moger@amd.com \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=eranian@google.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peternewman@google.com \
--cc=ravi.v.shankar@intel.com \
--cc=reinette.chatre@intel.com \
--cc=tglx@linutronix.de \
--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®