From: Shawn Wang <shawnwang@linux.alibaba.com>
To: Reinette Chatre <reinette.chatre@intel.com>, fenghua.yu@intel.com
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, james.morse@arm.com, x86@kernel.org,
hpa@zytor.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/resctrl: Only show tasks' pids in current pid namespace
Date: Wed, 15 Mar 2023 23:06:26 +0800 [thread overview]
Message-ID: <7b331383-e6b7-f94b-6af8-72d5d8d688bf@linux.alibaba.com> (raw)
In-Reply-To: <95fca7d1-d473-e9e2-b6c8-c4ae3d44d2df@intel.com>
Hi Reinette,
On 2/16/23 5:43 AM, Reinette Chatre wrote:
> Hi Shawn,
>
> On 1/15/2023 11:12 PM, Shawn Wang wrote:
>> When writing a task id to the "tasks" file in an rdtgroup,
>> rdtgroup_tasks_write() treats the pid as a number in the current pid
>> namespace. But when reading the "tasks" file, rdtgroup_tasks_show() shows
>> the list of global pids from the init namespace. If current pid namespace
>> is not the init namespace, pids in "tasks" will be confusing and incorrect.
>>
>> To be more robust, let the "tasks" file only show pids in the current pid
>> namespace.
>>
>
> Is it possible to elaborate more on the use case that this is aiming to
> address? It is unexpected to me that resource management is approached from
> within a container. My expectation is that the resource management and monitoring
> is done from the host.
We have a scenario where we only want to mount the resctrl filesystem under a specific container.
And We found that the pids in the tasks under resctrl are inconsistent with the pids obtained by top.
Besides, current rdtgroup_move_task() uses the find_task_by_vpid() to get the real pid.
Our modification is also to maintain symmetry with the rdtgroup_move_task().
>> ---
>> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++++--
>> 1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> index 5993da21d822..9e97ae24c159 100644
>> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> @@ -718,11 +718,15 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of,
>> static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s)
>> {
>> struct task_struct *p, *t;
>> + pid_t pid;
>>
>> rcu_read_lock();
>> for_each_process_thread(p, t) {
>> - if (is_closid_match(t, r) || is_rmid_match(t, r))
>> - seq_printf(s, "%d\n", t->pid);
>> + if (is_closid_match(t, r) || is_rmid_match(t, r)) {
>> + pid = task_pid_vnr(t);
>> + if (pid)
>> + seq_printf(s, "%d\n", pid);
>> + }
>> }
>> rcu_read_unlock();
>> }
>
> This looks like it would solve the stated problem. Does it slow down
> reading a tasks file in a measurable way?
We didn't test it, but it is proportional to the number of pids in the group.
In addition, only an if statement is added here, and actually the reading of
the tasks interface will not be called frequently, so it will not be a bottleneck.
Thanks,
Shawn
next prev parent reply other threads:[~2023-03-15 15:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-16 7:12 Shawn Wang
2023-02-15 21:43 ` Reinette Chatre
2023-03-15 15:06 ` Shawn Wang [this message]
2023-03-16 21:41 ` Reinette Chatre
2023-03-16 22:18 ` 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=7b331383-e6b7-f94b-6af8-72d5d8d688bf@linux.alibaba.com \
--to=shawnwang@linux.alibaba.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.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®