lkml.org 
[lkml]   [2020]   [Apr]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 15/15] print_integer, proc: rewrite /proc/meminfo via print_integer()
Date
This actually makes /proc/meminfo slower, I need to check what's
going on.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
fs/proc/meminfo.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index 8c1f1bb1a5ce..6dff2298cc3f 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -24,12 +24,24 @@ void __attribute__((weak)) arch_report_meminfo(struct seq_file *m)
{
}

-static void show_val_kb(struct seq_file *m, const char *s, unsigned long num)
+static void _show_val_kb(struct seq_file *m, const char *s, size_t len,
+ unsigned long num)
{
- seq_put_decimal_ull_width(m, s, num << (PAGE_SHIFT - 10), 8);
- seq_write(m, " kB\n", 4);
+ char buf[64];
+ char *p = buf + sizeof(buf);
+ char *tmp;
+
+ p = memcpy(p - 4, " kB\n", 4);
+ tmp = memcpy(p - 8, " ", 8);
+ p = _print_integer_ul(p, num << (PAGE_SHIFT - 10));
+ p = min(p, tmp);
+ p = memcpy(p - len, s, len);
+
+ seq_write(m, p, buf + sizeof(buf) - p);
}

+#define show_val_kb(m, s, n) _show_val_kb((m), (s), strlen(s), (n))
+
static int meminfo_proc_show(struct seq_file *m, void *v)
{
struct sysinfo i;
--
2.24.1
\
 
 \ /
  Last update: 2020-04-20 22:59    [W:0.494 / U:0.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site