lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <41beab3a.4f68.1858252166b.Coremail.00107082@163.com>
Date:   Thu, 5 Jan 2023 22:24:55 +0800 (CST)
From:   "David Wang" <00107082@....com>
To:     linux-kernel@...r.kernel.org
Subject: [proc/vmstat]set nr_kernel_stack in vmstat to nr_threads

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ