* [proc/vmstat]set nr_kernel_stack in vmstat to nr_threads
@ 2023-01-05 14:24 David Wang
0 siblings, 0 replies; only message in thread
From: David Wang @ 2023-01-05 14:24 UTC (permalink / raw)
To: linux-kernel
nr_kernel_stack in /proc/vmstat is very confusing, its value is now the same as KernelStack in /proc/meminfo,
indicating kernel stack memory usage in KB. It would be helpful to expose a stat about the number of kernel thread,
(the sysinfo syscall return a proc number with type U16, overflow would happen). This patch set nr_kernel_stack in /proc/vmstat
to a value defined by a global variable nr_threads.
--
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 1ea6a5ce1c41..0040beaa1b24 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -28,6 +28,7 @@
#include <linux/mm_inline.h>
#include <linux/page_ext.h>
#include <linux/page_owner.h>
+#include <linux/sched/stat.h>
#include "internal.h"
@@ -1831,9 +1832,20 @@ static int vmstat_show(struct seq_file *m, void *arg)
{
unsigned long *l = arg;
unsigned long off = l - (unsigned long *)m->private;
-
+ static long nks_i = -1; // index for nr_kernel_stack
+ if (nks_i < 0 && nks_i > -128) {
+ if (strcmp("nr_kernel_stack", vmstat_text[off]) == 0) {
+ nks_i = off;
+ } else {
+ nks_i--;
+ }
+ }
seq_puts(m, vmstat_text[off]);
- seq_put_decimal_ull(m, " ", *l);
+ if (nks_i == off) {
+ seq_put_decimal_ull(m, " ", nr_threads);
+ } else {
+ seq_put_decimal_ull(m, " ", *l);
+ }
seq_putc(m, '\n');
if (off == NR_VMSTAT_ITEMS - 1) {
--
David
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-05 14:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 14:24 [proc/vmstat]set nr_kernel_stack in vmstat to nr_threads David Wang
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®