fs/proc: add Kthread flag to /proc/$pid/status
Subsystems (3)
PATCH v2 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.
--- Documentation/filesystems/proc.rst | 2 ++ fs/proc/array.c | 2 ++ 2 files changed, 4 insertions(+)
Documentation/filesystems/proc.rst +2 -0
@@ -179,6 +179,7 @@ read the file /proc/PID/status:: Gid: 100 100 100 100 FDSize: 256 Groups: 100 14 16 + Kthread: 0 VmPeak: 5004 kB VmSize: 5004 kB VmLck: 0 kB
@@ -256,6 +257,7 @@ It's slow but very precise. NSpid descendant namespace process ID hierarchy NSpgid descendant namespace process group ID hierarchy NSsid descendant namespace session ID hierarchy + Kthread kernel thread flag, 1 is yes, 0 is no VmPeak peak virtual memory size VmSize total program size VmLck locked memory size
fs/proc/array.c +2 -0
@@ -219,6 +219,8 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,seq_put_decimal_ull (m,"\t" ,task_session_nr_ns (p, pid->numbers[g].ns));#endif seq_putc (m,'\n' ); + +seq_printf (m,"Kthread:\t%c\n" , p->flags &PF_KTHREAD ?'1' :'0' ); } void render_sigset_t(struct seq_file *m, const char *header,
Signature · 1 line
2.39.1
Hi--
Quoted 9 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.Signed-off-by Chunguang Wu <[email protected]>
LGTM. Thanks.
Quoted 38 lines
--- Documentation/filesystems/proc.rst | 2 ++ fs/proc/array.c | 2 ++ 2 files changed, 4 insertions(+)Documentation/filesystems/proc.rst +2
-0@@ -179,6 +179,7 @@ read the file /proc/PID/status:: Gid: 100 100 100 100 FDSize: 256 Groups: 100 14 16 + Kthread: 0 VmPeak: 5004 kB VmSize: 5004 kB VmLck: 0 kB@@ -256,6 +257,7 @@ It's slow but very precise. NSpid descendant namespace process ID hierarchy NSpgid descendant namespace process group ID hierarchy NSsid descendant namespace session ID hierarchy + Kthread kernel thread flag, 1 is yes, 0 is no VmPeak peak virtual memory size VmSize total program size VmLck locked memory sizefs/proc/array.c +2
-0@@ -219,6 +219,8 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,seq_put_decimal_ull (m,"\t" ,task_session_nr_ns (p, pid->numbers[g].ns));#endif seq_putc (m,'\n' ); + +seq_printf (m,"Kthread:\t%c\n" , p->flags &PF_KTHREAD ?'1' :'0' ); } void render_sigset_t(struct seq_file *m, const char *header,
Signature · 1 line
~Randy