fs/proc: add Kthread flag to /proc/$pid/status
Subsystems (2)
PATCH 1/1 fs/proc: add Kthread flag to /proc/$pid/status
The command ps -ef and top -c mark kernel thread by '[' and ']', but sometimes the result is not correct.
The task->flags in /proc/$pid/stat is good, but we need remember the value of PF_KTHREAD is 0x00200000 and convert dec to hex. If we have no binary program and shell script which read /proc/$pid/stat, we can know it directly bycat /proc/$pid/status.
--- fs/proc/array.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/proc/array.c +7 -0
@@ -434,6 +434,13 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,task_state (m, ns, pid, task); +seq_puts (m,"Kthread:\t" ); +if (task->flags &PF_KTHREAD ) { +seq_puts (m,"1\n" ); + }else { +seq_puts (m,"0\n" ); + } +if (mm) {task_mem (m, mm);task_core_dumping (m, task);
Signature · 1 line
2.39.1
Hi--
Quoted 8 lines · Chunguang Wu
The command
ps -efandtop -cmark kernel thread by '[' and ']', but sometimes the result is not correct.
Thetask->flagsin/proc/$pid/statis good, but we need remember the value ofPF_KTHREADis0x00200000and convert dec to hex. If we have no binary program and shell script which read/proc/$pid/stat, we can know it directly bycat /proc/$pid/status.
Please update Documentation/filesystems/proc.rst:
(1) the example:
For example, to get the status information of a process, all you have to do is read the file /proc/PID/status::
and (2): table 1-2
Thanks.
Quoted 23 lines
Signed-off-by Chunguang Wu <[email protected]>--- fs/proc/array.c | 7 +++++++ 1 file changed, 7 insertions(+)fs/proc/array.c +7
-0@@ -434,6 +434,13 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,task_state (m, ns, pid, task); +seq_puts (m,"Kthread:\t" ); +if (task->flags &PF_KTHREAD ) { +seq_puts (m,"1\n" ); + }else { +seq_puts (m,"0\n" ); + } +if (mm) {task_mem (m, mm);task_core_dumping (m, task);
Signature · 1 line
~Randy