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 12/15] print_integer, proc: rewrite /proc/*/statm via print_integer()
Date
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
fs/proc/array.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index 6986f9f68ab7..16d66538fa61 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -695,24 +695,28 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
unsigned long shared = 0;
unsigned long text = 0;
unsigned long data = 0;
+ char buf[5 * LEN_UL + 9];
+ char *p = buf + sizeof(buf);

size = task_statm(mm, &shared, &text, &data, &resident);
mmput(mm);

- /*
- * For quick read, open code by putting numbers directly
- * expected format is
- * seq_printf(m, "%lu %lu %lu %lu 0 %lu 0\n",
- * size, resident, shared, text, data);
- */
- seq_put_decimal_ull(m, "", size);
- seq_put_decimal_ull(m, " ", resident);
- seq_put_decimal_ull(m, " ", shared);
- seq_put_decimal_ull(m, " ", text);
- seq_put_decimal_ull(m, " ", 0);
- seq_put_decimal_ull(m, " ", data);
- seq_put_decimal_ull(m, " ", 0);
- seq_putc(m, '\n');
+ *--p = '\n';
+ *--p = '0';
+ *--p = ' ';
+ p = _print_integer_ul(p, data);
+ *--p = ' ';
+ *--p = '0';
+ *--p = ' ';
+ p = _print_integer_ul(p, text);
+ *--p = ' ';
+ p = _print_integer_ul(p, shared);
+ *--p = ' ';
+ p = _print_integer_ul(p, resident);
+ *--p = ' ';
+ p = _print_integer_ul(p, size);
+
+ seq_write(m, p, buf + sizeof(buf) - p);
} else {
seq_write(m, "0 0 0 0 0 0 0\n", 14);
}
--
2.24.1
\
 
 \ /
  Last update: 2020-04-20 22:59    [W:0.106 / U:0.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site