mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xuewen Yan <xuewen.yan@unisoc.com>
To: <akpm@linux-foundation.org>, <oleg@redhat.com>,
	<longman@redhat.com>, <peterz@infradead.org>
Cc: <dylanbhatch@google.com>, <rick.p.edgecombe@intel.com>,
	<ke.wang@unisoc.com>, <xuewen.yan94@gmail.com>,
	<linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>
Subject: [PATCH] sched/proc: Print user_cpus_ptr for task status
Date: Mon, 29 Apr 2024 16:46:33 +0800	[thread overview]
Message-ID: <20240429084633.9800-1-xuewen.yan@unisoc.com> (raw)

The commit 851a723e45d1c("sched: Always clear user_cpus_ptr in do_set_cpus_allowed()")
would clear the user_cpus_ptr when call the do_set_cpus_allowed.

In order to determine whether the user_cpus_ptr is taking effect,
it is better to print the task's user_cpus_ptr.

For top-cpuset:
ums9621_1h10:/ # while true; do done&
[1] 6786
ums9621_1h10:/ # cat /proc/6786/status | grep Cpus
Cpus_allowed:   ff
Cpus_allowed_list:      0-7
Cpus_user_allowed:        (null)
Cpus_user_allowed_list:   (null)

bind the task to 6-7:
ums9621_1h10:/ # taskset -p c0 6786
pid 6786's current affinity mask: ff
pid 6786's new affinity mask: c0
ums9621_1h10:/ # cat /proc/6786/status | grep Cpus
Cpus_allowed:   c0
Cpus_allowed_list:      6-7
Cpus_user_allowed:      c0
Cpus_user_allowed_list: 6-7

Offline cpu7:
ums9621_1h10:/ # echo 0 > /sys/devices/system/cpu/cpu7/online
ums9621_1h10:/ # cat /proc/6786/status | grep Cpus
Cpus_allowed:   c0
Cpus_allowed_list:      6-7
Cpus_user_allowed:      c0
Cpus_user_allowed_list: 6-7

Offline cpu6, and then the do_set_cpus_allowed will clear the user_ptr:
ums9621_1h10:/ # echo 0 > /sys/devices/system/cpu/cpu6/online
ums9621_1h10:/ # cat /proc/6786/status | grep Cpus
Cpus_allowed:   ff
Cpus_allowed_list:      0-7
Cpus_user_allowed:        (null)
Cpus_user_allowed_list:   (null)

Bringup the core6,7:
ums9621_1h10:/ # echo 1 > /sys/devices/system/cpu/cpu6/online
ums9621_1h10:/ # echo 1 > /sys/devices/system/cpu/cpu7/online
ums9621_1h10:/ # cat /proc/6786/status | grep Cpus
Cpus_allowed:   ff
Cpus_allowed_list:      0-7
Cpus_user_allowed:        (null)
Cpus_user_allowed_list:   (null)

Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
---
 fs/proc/array.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index 34a47fb0c57f..084bee2a2e2b 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -409,6 +409,10 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
 		   cpumask_pr_args(&task->cpus_mask));
 	seq_printf(m, "Cpus_allowed_list:\t%*pbl\n",
 		   cpumask_pr_args(&task->cpus_mask));
+	seq_printf(m, "Cpus_user_allowed:\t%*pb\n",
+		   cpumask_pr_args(task->user_cpus_ptr));
+	seq_printf(m, "Cpus_user_allowed_list:\t%*pbl\n",
+		   cpumask_pr_args(task->user_cpus_ptr));
 }
 
 static inline void task_core_dumping(struct seq_file *m, struct task_struct *task)
-- 
2.25.1


             reply	other threads:[~2024-04-29  8:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29  8:46 Xuewen Yan [this message]
2024-04-29 12:10 ` Peter Zijlstra
2024-05-06  8:04   ` Xuewen Yan
2024-05-06 18:03     ` Waiman Long
2024-05-07  6:57       ` Xuewen Yan
2024-05-08 17:01         ` Waiman Long

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=20240429084633.9800-1-xuewen.yan@unisoc.com \
    --to=xuewen.yan@unisoc.com \
    --cc=akpm@linux-foundation.org \
    --cc=dylanbhatch@google.com \
    --cc=ke.wang@unisoc.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rick.p.edgecombe@intel.com \
    --cc=xuewen.yan94@gmail.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

all inboxes | Powered by JetHome®