/proc/pid/status: Add support for architecture specific output
Subsystems (4)
PATCH v14 1/3 /proc/pid/status: Add support for architecture specific output
The architecture specific information of the running processes could be useful to the userland. Add support to examine process architecture specific information externally.
--- fs/proc/array.c | 5 +++++ include/linux/proc_fs.h | 2 ++ 2 files changed, 7 insertions(+)
fs/proc/array.c +5 -0
@@ -401,6 +401,10 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)seq_printf (m,"THP_enabled:\t%d\n" , thp_enabled); } +void __weak arch_proc_pid_status (struct seq_file *m,struct task_struct *task) +{ +} +int proc_pid_status (struct seq_file *m,struct pid_namespace *ns,struct pid *pid,struct task_struct *task) {
@@ -424,6 +428,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,task_cpus_allowed (m, task);cpuset_task_status_allowed (m, task);task_context_switch_counts (m, task); +arch_proc_pid_status (m, task);return 0 ; }
include/linux/proc_fs.h +2 -0
@@ -74,6 +74,8 @@ struct proc_dir_entry *proc_create_net_single_write(const char *name, umode_t moproc_write_t write, void *data);extern struct pid *tgid_pidfd_to_pid (const struct file *file); +/* Add support for architecture specific output in /proc/pid/status */ +void arch_proc_pid_status (struct seq_file *m,struct task_struct *task);#else /* CONFIG_PROC_FS */
Signature · 1 line
2.21.0
PATCH v14 2/3 x86,/proc/pid/status: Add AVX-512 usage elapsed time
AVX-512 components use could cause core turbo frequency drop. So it's useful to expose AVX-512 usage elapsed time as a heuristic hint for the user space job scheduler to cluster the AVX-512 using tasks together.
Tensorflow example:
$ while [ 1 ]; do cat /proc/tid/status | grep AVX; sleep 1; done AVX512_elapsed_ms: 4 AVX512_elapsed_ms: 8 AVX512_elapsed_ms: 4
This means that 4 milliseconds have elapsed since the AVX512 usage of tensorflow task was detected when the task was scheduled out.
Or:
$ cat /proc/tid/status | grep AVX512_elapsed_ms AVX512_elapsed_ms: -1
The number '-1' indicates that no AVX512 usage recorded before thus the task unlikely has frequency drop issue.
User space tools may want to further check by:
$ perf stat --pid <pid> -e core_power.lvl2_turbo_license -- sleep 1
Performance counter stats for process id '3558':
3,251,565,961 core_power.lvl2_turbo_license
1.004031387 seconds time elapsedNon-zero counter value confirms that the task causes frequency drop.
--- arch/x86/kernel/fpu/xstate.c | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
arch/x86/kernel/fpu/xstate.c +42 -0
@@ -7,6 +7,8 @@#include <linux/cpu.h> #include <linux/mman.h> #include <linux/pkeys.h> +#include <linux/seq_file.h> +#include <linux/proc_fs.h> #include <asm/fpu/api.h> #include <asm/fpu/internal.h>
@@ -1243,3 +1245,43 @@ int copy_user_to_xstate(struct xregs_state *xsave, const void __user *ubuf)return 0 ; } + +/* +* Report the amount of time elapsed in millisecond since last AVX512 +* use in the task. +*/ +static void avx512_status (struct seq_file *m,struct task_struct *task) +{ +unsigned long timestamp =READ_ONCE (task->thread.fpu.avx512_timestamp); +long delta; + +if (!timestamp) { +/* +* Report -1 if no AVX512 usage +*/ + delta =-1 ; + }else { + delta = (long )(jiffies - timestamp); +/* +* Cap to LONG_MAX if time difference > LONG_MAX +*/ +if (delta <0 ) + delta =LONG_MAX ; + delta =jiffies_to_msecs (delta); + } + +seq_put_decimal_ll (m,"AVX512_elapsed_ms:\t" , delta); +seq_putc (m,'\n' ); +} + +/* +* Report architecture specific information +*/ +void arch_proc_pid_status (struct seq_file *m,struct task_struct *task) +{ +/* +* Report AVX512 state if the processor and build option supported. +*/ +if (cpu_feature_enabled (X86_FEATURE_AVX512F )) +avx512_status (m, task); +}
Signature · 1 line
2.21.0
PATCH v14 3/3 Documentation/filesystems/proc.txt: add AVX512_elapsed_ms
In reply to Aubrey LiAdded AVX512_elapsed_ms in /proc/<pid>/status. Report it in Documentation/filesystems/proc.txt
--- Documentation/filesystems/proc.txt | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
Documentation/filesystems/proc.txt +28 -1
@@ -207,6 +207,7 @@ read the file /proc/PID/status: Speculation_Store_Bypass: thread vulnerable voluntary_ctxt_switches: 0 nonvoluntary_ctxt_switches: 1 + AVX512_elapsed_ms: 8 This shows you nearly the same information you would get if you viewed it with the ps command. In fact, ps uses the proc file system to obtain its
@@ -224,7 +225,7 @@ asynchronous manner and the value may not be very precise. To see a precise snapshot of a moment, you can see /proc/<pid>/smaps file and scan page table. It's slow but very precise. -Table 1-2: Contents of the status files (as of 4.19) +Table 1-2: Contents of the status files (as of 5.1) .............................................................................. Field Content Name filename of the executable
@@ -289,6 +290,32 @@ Table 1-2: Contents of the status files (as of 4.19) Mems_allowed_list Same as previous, but in "list format" voluntary_ctxt_switches number of voluntary context switches nonvoluntary_ctxt_switches number of non voluntary context switches + AVX512_elapsed_ms time elapsed since last AVX512 usage recorded + + AVX512_elapsed_ms: + ------------------ + If AVX512 is supported on the machine, this entry shows the milliseconds + elapsed since the last time AVX512 usage was recorded. The recording + happens on a best effort basis when a task is scheduled out. This means + that the value depends on two factors: + + 1) The time which the task spent on the CPU without being scheduled + out. With CPU isolation and a single runnable task this can take + several seconds. + + 2) The time since the task was scheduled out last. Depending on the + reason for being scheduled out (time slice exhausted, syscall ...) + this can be arbitrary long time. + + As a consequence the value cannot be considered precise and authoritative + information. The application which uses this information has to be aware + of the overall scenario on the system in order to determine whether a + task is a real AVX512 user or not. + + A special value of '-1' indicates that no AVX512 usage was recorded, thus + the task is unlikely an AVX512 user, but depends on the workload and the + scheduling scenario, it also could be a false negative mentioned above. + .............................................................................. Table 1-3: Contents of the statm files (as of 2.6.8-rc3)
Signature · 1 line
2.21.0
Quoted 24 lines · Aubrey Li
The architecture specific information of the running processes could be useful to the userland. Add support to examine process architecture specific information externally.
Signed-off-by Aubrey Li <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andi Kleen <[email protected]>Cc Tim Chen <[email protected]>Cc Dave Hansen <[email protected]>Cc Arjan van de Ven <[email protected]>Cc Linux API <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Andrew Morton <[email protected]>--- fs/proc/array.c | 5 +++++ include/linux/proc_fs.h | 2 ++ 2 files changed, 7 insertions(+)fs/proc/array.c +0
-0
fs/proc/array.c static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm) · line 406
Quoted 6 lines
fs/proc/array.c +3
-0@@ -401,6 +401,10 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)seq_printf (m,"THP_enabled:\t%d\n" , thp_enabled); } +void __weak arch_proc_pid_status (struct seq_file *m,struct task_struct *task) +{ +}
This pointlessly bloats other architectures. Do this instead in an appropriate header:
#ifndef arch_proc_pid_status
static inline void arch_proc_pid_status(...)
{
}
#endif
Or add /proc/PID/x86_status, which sounds better in most respects to me.
Quoted 35 lines · Andy Lutomirski
Quoted 24 lines · Aubrey Li
The architecture specific information of the running processes could be useful to the userland. Add support to examine process architecture specific information externally.
Signed-off-by Aubrey Li <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andi Kleen <[email protected]>Cc Tim Chen <[email protected]>Cc Dave Hansen <[email protected]>Cc Arjan van de Ven <[email protected]>Cc Linux API <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Andrew Morton <[email protected]>--- fs/proc/array.c | 5 +++++ include/linux/proc_fs.h | 2 ++ 2 files changed, 7 insertions(+)fs/proc/array.c +0
-0fs/proc/array.c static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm) · line 406
Quoted 6 lines
fs/proc/array.c +3
-0@@ -401,6 +401,10 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)seq_printf (m,"THP_enabled:\t%d\n" , thp_enabled); } +void __weak arch_proc_pid_status (struct seq_file *m,struct task_struct *task) +{ +}This pointlessly bloats other architectures. Do this instead in an appropriate header:
Quoted 6 lines
#ifndef
arch_proc_pid_status
static inline voidarch_proc_pid_status(...)
{
}
#endif
I saw a bunch of similar weak functions, is it not acceptable?
fs/proc$ grep weak *.c
cpuinfo.c:__weak void arch_freq_prepare_all(void)
meminfo.c:void __attribute__((weak)) arch_report_meminfo(struct seq_file *m) vmcore.c:int __weak elfcorehdr_alloc(unsigned long long *addr, unsigned long long *size) vmcore.c:void __weak elfcorehdr_free(unsigned long long addr) vmcore.c:ssize_t __weak elfcorehdr_read(char *buf, size_t count, u64 *ppos) vmcore.c:ssize_t __weak elfcorehdr_read_notes(char *buf, size_t count, u64 *ppos) vmcore.c:int __weak remap_oldmem_pfn_range(struct vm_area_struct *vma, vmcore.c:ssize_t __weak
Quoted 2 lines
Or add
/proc/PID/x86_status, which sounds better in most respects to me.
I didn't figure out how to make /proc/PID/x86_status invisible to other architectures in an appropriate way, do you have any suggestions?
Thanks,
-Aubrey
Quoted 46 lines · Aubrey
Quoted 35 lines · Andy Lutomirski
Quoted 24 lines · Aubrey Li
The architecture specific information of the running processes could be useful to the userland. Add support to examine process architecture specific information externally.
Signed-off-by Aubrey Li <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andi Kleen <[email protected]>Cc Tim Chen <[email protected]>Cc Dave Hansen <[email protected]>Cc Arjan van de Ven <[email protected]>Cc Linux API <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Andrew Morton <[email protected]>--- fs/proc/array.c | 5 +++++ include/linux/proc_fs.h | 2 ++ 2 files changed, 7 insertions(+)fs/proc/array.c +0
-0fs/proc/array.c static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm) · line 406
Quoted 6 lines
fs/proc/array.c +3
-0@@ -401,6 +401,10 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)seq_printf (m,"THP_enabled:\t%d\n" , thp_enabled); } +void __weak arch_proc_pid_status (struct seq_file *m,struct task_struct *task) +{ +}This pointlessly bloats other architectures. Do this instead in an appropriate header:
Quoted 6 lines
#ifndef
arch_proc_pid_status
static inline voidarch_proc_pid_status(...)
{
}
#endifI saw a bunch of similar weak functions, is it not acceptable?
Quoted 9 lines
fs/proc$ grep weak *.c
cpuinfo.c:__weak voidarch_freq_prepare_all(void)
meminfo.c:void __attribute__((weak))arch_report_meminfo(struct seq_file *m)vmcore.c:int__weakelfcorehdr_alloc(unsigned long long *addr, unsigned long long *size)vmcore.c:void__weakelfcorehdr_free(unsigned long long addr)vmcore.c:ssize_t__weakelfcorehdr_read(char *buf, size_t count, u64 *ppos)vmcore.c:ssize_t__weakelfcorehdr_read_notes(char *buf, size_t count, u64 *ppos)vmcore.c:int__weakremap_oldmem_pfn_range(structvm_area_struct*vma, vmcore.c:ssize_t__weak
I think they're acceptable, but I don't personally like them.
Quoted 6 lines
Quoted 3 lines
Or add
/proc/PID/x86_status, which sounds better in most respects to me.I didn't figure out how to make
/proc/PID/x86_statusinvisible to other architectures in an appropriate way, do you have any suggestions?
#ifdef CONFIG_X86?
Quoted 57 lines · Andy Lutomirski
Quoted 46 lines · Aubrey
Quoted 35 lines · Andy Lutomirski
Quoted 24 lines · Aubrey Li
The architecture specific information of the running processes could be useful to the userland. Add support to examine process architecture specific information externally.
Signed-off-by Aubrey Li <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andi Kleen <[email protected]>Cc Tim Chen <[email protected]>Cc Dave Hansen <[email protected]>Cc Arjan van de Ven <[email protected]>Cc Linux API <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Andrew Morton <[email protected]>--- fs/proc/array.c | 5 +++++ include/linux/proc_fs.h | 2 ++ 2 files changed, 7 insertions(+)fs/proc/array.c +0
-0fs/proc/array.c static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm) · line 406
Quoted 6 lines
fs/proc/array.c +3
-0@@ -401,6 +401,10 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)seq_printf (m,"THP_enabled:\t%d\n" , thp_enabled); } +void __weak arch_proc_pid_status (struct seq_file *m,struct task_struct *task) +{ +}This pointlessly bloats other architectures. Do this instead in an appropriate header:
Quoted 6 lines
#ifndef
arch_proc_pid_status
static inline voidarch_proc_pid_status(...)
{
}
#endifI saw a bunch of similar weak functions, is it not acceptable?
Quoted 9 lines
fs/proc$ grep weak *.c
cpuinfo.c:__weak voidarch_freq_prepare_all(void)
meminfo.c:void __attribute__((weak))arch_report_meminfo(struct seq_file *m)vmcore.c:int__weakelfcorehdr_alloc(unsigned long long *addr, unsigned long long *size)vmcore.c:void__weakelfcorehdr_free(unsigned long long addr)vmcore.c:ssize_t__weakelfcorehdr_read(char *buf, size_t count, u64 *ppos)vmcore.c:ssize_t__weakelfcorehdr_read_notes(char *buf, size_t count, u64 *ppos)vmcore.c:int__weakremap_oldmem_pfn_range(structvm_area_struct*vma, vmcore.c:ssize_t__weak
Quoted 2 lines
I think they're acceptable, but I don't personally like them.
okay, let me try to see if I can refine it in an appropriate way.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Or add
/proc/PID/x86_status, which sounds better in most respects to me.I didn't figure out how to make
/proc/PID/x86_statusinvisible to other architectures in an appropriate way, do you have any suggestions?#ifdef
CONFIG_X86?
I'm not sure if everyone like adding an arch #ifdef in a common file, please allow me to wait a while to see if there are other comments.
Thanks,
-Aubrey
Quoted 58 lines · Aubrey
Quoted 57 lines · Andy Lutomirski
Quoted 55 lines · Aubrey
Quoted 35 lines · Andy Lutomirski
Quoted 24 lines · Aubrey Li
The architecture specific information of the running processes could be useful to the userland. Add support to examine process architecture specific information externally.
Signed-off-by Aubrey Li <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andi Kleen <[email protected]>Cc Tim Chen <[email protected]>Cc Dave Hansen <[email protected]>Cc Arjan van de Ven <[email protected]>Cc Linux API <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Andrew Morton <[email protected]>--- fs/proc/array.c | 5 +++++ include/linux/proc_fs.h | 2 ++ 2 files changed, 7 insertions(+)fs/proc/array.c +0
-0fs/proc/array.c static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm) · line 406
Quoted 6 lines
fs/proc/array.c +3
-0@@ -401,6 +401,10 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)seq_printf (m,"THP_enabled:\t%d\n" , thp_enabled); } +void __weak arch_proc_pid_status (struct seq_file *m,struct task_struct *task) +{ +}This pointlessly bloats other architectures. Do this instead in an appropriate header:
Quoted 6 lines
#ifndef
arch_proc_pid_status
static inline voidarch_proc_pid_status(...)
{
}
#endifI saw a bunch of similar weak functions, is it not acceptable?
fs/proc$ grep weak *.c
cpuinfo.c:__weak voidarch_freq_prepare_all(void)
meminfo.c:void __attribute__((weak))arch_report_meminfo(struct seq_file *m)vmcore.c:int__weakelfcorehdr_alloc(unsigned long long *addr, unsigned long long *size)vmcore.c:void__weakelfcorehdr_free(unsigned long long addr)vmcore.c:ssize_t__weakelfcorehdr_read(char *buf, size_t count, u64 *ppos)vmcore.c:ssize_t__weakelfcorehdr_read_notes(char *buf, size_t count, u64 *ppos)vmcore.c:int__weakremap_oldmem_pfn_range(structvm_area_struct*vma, vmcore.c:ssize_t__weak
Quoted 4 lines
Quoted 2 lines
I think they're acceptable, but I don't personally like them.
okay, let me try to see if I can refine it in an appropriate way.
Hi Andy,
Is this what you want?
Thanks,
-Aubrey
====================================================================
arch/x86/include/asm/processor.h +3 -0
@@ -990,5 +990,8 @@ enum l1tf_mitigations { };extern enum l1tf_mitigations l1tf_mitigation; +/* Add support for architecture specific output in /proc/pid/status */ +void arch_proc_pid_status (struct seq_file *m,struct task_struct *task); +#define arch_proc_pid_status arch_proc_pid_status#endif /* _ASM_X86_PROCESSOR_H */
fs/proc/array.c +6 -0
@@ -401,6 +401,11 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)seq_printf (m,"THP_enabled:\t%d\n" , thp_enabled); } +/* Add support for architecture specific output in /proc/pid/status */ +#ifndef arch_proc_pid_status +#define arch_proc_pid_status (m, task) +#endif +int proc_pid_status (struct seq_file *m,struct pid_namespace *ns,struct pid *pid,struct task_struct *task) {
@@ -424,6 +429,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,task_cpus_allowed (m, task);cpuset_task_status_allowed (m, task);task_context_switch_counts (m, task); +arch_proc_pid_status (m, task);return 0 ; }
Quoted 103 lines · Aubrey
Quoted 58 lines · Aubrey
Quoted 57 lines · Andy Lutomirski
Quoted 55 lines · Aubrey
Quoted 35 lines · Andy Lutomirski
Quoted 24 lines · Aubrey Li
The architecture specific information of the running processes could be useful to the userland. Add support to examine process architecture specific information externally.
Signed-off-by Aubrey Li <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andi Kleen <[email protected]>Cc Tim Chen <[email protected]>Cc Dave Hansen <[email protected]>Cc Arjan van de Ven <[email protected]>Cc Linux API <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Andrew Morton <[email protected]>--- fs/proc/array.c | 5 +++++ include/linux/proc_fs.h | 2 ++ 2 files changed, 7 insertions(+)fs/proc/array.c +0
-0fs/proc/array.c static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm) · line 406
Quoted 6 lines
fs/proc/array.c +3
-0@@ -401,6 +401,10 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)seq_printf (m,"THP_enabled:\t%d\n" , thp_enabled); } +void __weak arch_proc_pid_status (struct seq_file *m,struct task_struct *task) +{ +}This pointlessly bloats other architectures. Do this instead in an appropriate header:
Quoted 6 lines
#ifndef
arch_proc_pid_status
static inline voidarch_proc_pid_status(...)
{
}
#endifI saw a bunch of similar weak functions, is it not acceptable?
fs/proc$ grep weak *.c
cpuinfo.c:__weak voidarch_freq_prepare_all(void)
meminfo.c:void __attribute__((weak))arch_report_meminfo(struct seq_file *m)vmcore.c:int__weakelfcorehdr_alloc(unsigned long long *addr, unsigned long long *size)vmcore.c:void__weakelfcorehdr_free(unsigned long long addr)vmcore.c:ssize_t__weakelfcorehdr_read(char *buf, size_t count, u64 *ppos)vmcore.c:ssize_t__weakelfcorehdr_read_notes(char *buf, size_t count, u64 *ppos)vmcore.c:int__weakremap_oldmem_pfn_range(structvm_area_struct*vma, vmcore.c:ssize_t__weakQuoted 4 lines
Quoted 2 lines
I think they're acceptable, but I don't personally like them.
okay, let me try to see if I can refine it in an appropriate way.
Hi Andy,
Is this what you want?
Thanks,
-Aubrey====================================================================
arch/x86/include/asm/processor.h +3
-0@@ -990,5 +990,8 @@ enum l1tf_mitigations { };extern enum l1tf_mitigations l1tf_mitigation; +/* Add support for architecture specific output in /proc/pid/status */ +void arch_proc_pid_status (struct seq_file *m,struct task_struct *task); +#define arch_proc_pid_status arch_proc_pid_status#endif /* _ASM_X86_PROCESSOR_H */ fs/proc/array.c +5
-0@@ -401,6 +401,11 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)seq_printf (m,"THP_enabled:\t%d\n" , thp_enabled); } +/* Add support for architecture specific output in /proc/pid/status */ +#ifndef arch_proc_pid_status +#define arch_proc_pid_status (m, task) +#endif +int proc_pid_status (struct seq_file *m,struct pid_namespace *ns,struct pid *pid,struct task_struct *task) {
fs/proc/array.c int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, · line 435
Quoted 7 lines
fs/proc/array.c +1
-0@@ -424,6 +429,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,task_cpus_allowed (m, task);cpuset_task_status_allowed (m, task);task_context_switch_counts (m, task); +arch_proc_pid_status (m, task);return 0 ; }
Yes. But I still think it would be nicer to separate the arch stuff into its own file. Others might reasonably disagree with me.
Quoted 106 lines · Andy Lutomirski
Quoted 105 lines · Aubrey
Quoted 58 lines · Aubrey
Quoted 57 lines · Andy Lutomirski
Quoted 55 lines · Aubrey
Quoted 35 lines · Andy Lutomirski
Quoted 24 lines · Aubrey Li
The architecture specific information of the running processes could be useful to the userland. Add support to examine process architecture specific information externally.
Signed-off-by Aubrey Li <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andi Kleen <[email protected]>Cc Tim Chen <[email protected]>Cc Dave Hansen <[email protected]>Cc Arjan van de Ven <[email protected]>Cc Linux API <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Andrew Morton <[email protected]>--- fs/proc/array.c | 5 +++++ include/linux/proc_fs.h | 2 ++ 2 files changed, 7 insertions(+)fs/proc/array.c +0
-0fs/proc/array.c static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm) · line 406
Quoted 6 lines
fs/proc/array.c +3
-0@@ -401,6 +401,10 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)seq_printf (m,"THP_enabled:\t%d\n" , thp_enabled); } +void __weak arch_proc_pid_status (struct seq_file *m,struct task_struct *task) +{ +}This pointlessly bloats other architectures. Do this instead in an appropriate header:
Quoted 6 lines
#ifndef
arch_proc_pid_status
static inline voidarch_proc_pid_status(...)
{
}
#endifI saw a bunch of similar weak functions, is it not acceptable?
fs/proc$ grep weak *.c
cpuinfo.c:__weak voidarch_freq_prepare_all(void)
meminfo.c:void __attribute__((weak))arch_report_meminfo(struct seq_file *m)vmcore.c:int__weakelfcorehdr_alloc(unsigned long long *addr, unsigned long long *size)vmcore.c:void__weakelfcorehdr_free(unsigned long long addr)vmcore.c:ssize_t__weakelfcorehdr_read(char *buf, size_t count, u64 *ppos)vmcore.c:ssize_t__weakelfcorehdr_read_notes(char *buf, size_t count, u64 *ppos)vmcore.c:int__weakremap_oldmem_pfn_range(structvm_area_struct*vma, vmcore.c:ssize_t__weakQuoted 4 lines
Quoted 2 lines
I think they're acceptable, but I don't personally like them.
okay, let me try to see if I can refine it in an appropriate way.
Hi Andy,
Is this what you want?
Thanks,
-Aubrey====================================================================
arch/x86/include/asm/processor.h +3
-0@@ -990,5 +990,8 @@ enum l1tf_mitigations { };extern enum l1tf_mitigations l1tf_mitigation; +/* Add support for architecture specific output in /proc/pid/status */ +void arch_proc_pid_status (struct seq_file *m,struct task_struct *task); +#define arch_proc_pid_status arch_proc_pid_status#endif /* _ASM_X86_PROCESSOR_H */ fs/proc/array.c +5
-0@@ -401,6 +401,11 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)seq_printf (m,"THP_enabled:\t%d\n" , thp_enabled); } +/* Add support for architecture specific output in /proc/pid/status */ +#ifndef arch_proc_pid_status +#define arch_proc_pid_status (m, task) +#endif +int proc_pid_status (struct seq_file *m,struct pid_namespace *ns,struct pid *pid,struct task_struct *task) {@@ -424,6 +429,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,task_cpus_allowed (m, task);cpuset_task_status_allowed (m, task);
Quoted 9 lines
fs/proc/array.c int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, · line 435
Quoted 5 lines
fs/proc/array.c +1
-0task_context_switch_counts (m, task); +arch_proc_pid_status (m, task);return 0 ; }Yes. But I still think it would be nicer to separate the arch stuff into its own file. Others might reasonably disagree with me.
I like arch_status, I proposed but no other arch shows interesting in it.
I think the problem is similar for x86_status, it does not make sense for those x86 platform without AVX512 to have an empty arch file. I personally don't like [arch]_status because the code may become unclean if more arches added in future.
Maybe it's too early to have a separated arch staff file for now.
Thanks,
-Aubrey
Quoted 116 lines · Aubrey
Quoted 106 lines · Andy Lutomirski
Quoted 105 lines · Aubrey
Quoted 58 lines · Aubrey
Quoted 57 lines · Andy Lutomirski
Quoted 55 lines · Aubrey
Quoted 35 lines · Andy Lutomirski
Quoted 24 lines · Aubrey Li
The architecture specific information of the running processes could be useful to the userland. Add support to examine process architecture specific information externally.
Signed-off-by Aubrey Li <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andi Kleen <[email protected]>Cc Tim Chen <[email protected]>Cc Dave Hansen <[email protected]>Cc Arjan van de Ven <[email protected]>Cc Linux API <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Andrew Morton <[email protected]>--- fs/proc/array.c | 5 +++++ include/linux/proc_fs.h | 2 ++ 2 files changed, 7 insertions(+)fs/proc/array.c +0
-0fs/proc/array.c static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm) · line 406
Quoted 6 lines
fs/proc/array.c +3
-0@@ -401,6 +401,10 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)seq_printf (m,"THP_enabled:\t%d\n" , thp_enabled); } +void __weak arch_proc_pid_status (struct seq_file *m,struct task_struct *task) +{ +}This pointlessly bloats other architectures. Do this instead in an appropriate header:
Quoted 6 lines
#ifndef
arch_proc_pid_status
static inline voidarch_proc_pid_status(...)
{
}
#endifI saw a bunch of similar weak functions, is it not acceptable?
fs/proc$ grep weak *.c
cpuinfo.c:__weak voidarch_freq_prepare_all(void)
meminfo.c:void __attribute__((weak))arch_report_meminfo(struct seq_file *m)vmcore.c:int__weakelfcorehdr_alloc(unsigned long long *addr, unsigned long long *size)vmcore.c:void__weakelfcorehdr_free(unsigned long long addr)vmcore.c:ssize_t__weakelfcorehdr_read(char *buf, size_t count, u64 *ppos)vmcore.c:ssize_t__weakelfcorehdr_read_notes(char *buf, size_t count, u64 *ppos)vmcore.c:int__weakremap_oldmem_pfn_range(structvm_area_struct*vma, vmcore.c:ssize_t__weakQuoted 4 lines
Quoted 2 lines
I think they're acceptable, but I don't personally like them.
okay, let me try to see if I can refine it in an appropriate way.
Hi Andy,
Is this what you want?
Thanks,
-Aubrey====================================================================
arch/x86/include/asm/processor.h +3
-0@@ -990,5 +990,8 @@ enum l1tf_mitigations { };extern enum l1tf_mitigations l1tf_mitigation; +/* Add support for architecture specific output in /proc/pid/status */ +void arch_proc_pid_status (struct seq_file *m,struct task_struct *task); +#define arch_proc_pid_status arch_proc_pid_status#endif /* _ASM_X86_PROCESSOR_H */ fs/proc/array.c +5
-0@@ -401,6 +401,11 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)seq_printf (m,"THP_enabled:\t%d\n" , thp_enabled); } +/* Add support for architecture specific output in /proc/pid/status */ +#ifndef arch_proc_pid_status +#define arch_proc_pid_status (m, task) +#endif +int proc_pid_status (struct seq_file *m,struct pid_namespace *ns,struct pid *pid,struct task_struct *task) {@@ -424,6 +429,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,task_cpus_allowed (m, task);cpuset_task_status_allowed (m, task);Quoted 9 lines
fs/proc/array.c int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, · line 435
Quoted 5 lines
fs/proc/array.c +1
-0task_context_switch_counts (m, task); +arch_proc_pid_status (m, task);return 0 ; }Yes. But I still think it would be nicer to separate the arch stuff into its own file. Others might reasonably disagree with me.
Quoted 8 lines
I like
arch_status, I proposed but no other arch shows interesting in it.I think the problem is similar for
x86_status, it does not make sense for those x86 platform without AVX512 to have an empty arch file. I personally don't like [arch]_status because the code may become unclean if more arches added in future.Maybe it's too early to have a separated arch staff file for now.
Hi Andy,
Is it acceptable to you if I make the above change and post v15?
Thanks,
-Aubrey