diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2022-01-11 19:32:16 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2022-01-11 19:32:16 +0100 |
commit | 524fecf7c3496e25cca235506b2a3328cee63de8 (patch) | |
tree | 506248a3b740a5920258b03223605feb07654f62 | |
parent | ff8fda848284e82d97299806b31c196651b372a5 (diff) | |
download | busybox-w32-524fecf7c3496e25cca235506b2a3328cee63de8.tar.gz busybox-w32-524fecf7c3496e25cca235506b2a3328cee63de8.tar.bz2 busybox-w32-524fecf7c3496e25cca235506b2a3328cee63de8.zip |
nmeter: %[md] %[mw] - dirty file-backed pages, writeback pages
function old new delta
collect_mem 333 387 +54
.rodata 104369 104380 +11
packed_usage 34184 34175 -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 65/-9) Total: 56 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | procps/nmeter.c | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/procps/nmeter.c b/procps/nmeter.c index f08938654..2310e9844 100644 --- a/procps/nmeter.c +++ b/procps/nmeter.c | |||
@@ -27,6 +27,8 @@ | |||
27 | //usage: "\n (displays: S:system U:user N:niced D:iowait I:irq i:softirq)" | 27 | //usage: "\n (displays: S:system U:user N:niced D:iowait I:irq i:softirq)" |
28 | //usage: "\n %[nINTERFACE] Network INTERFACE" | 28 | //usage: "\n %[nINTERFACE] Network INTERFACE" |
29 | //usage: "\n %m Allocated memory" | 29 | //usage: "\n %m Allocated memory" |
30 | //usage: "\n %[md] Dirty file-backed memory" | ||
31 | //usage: "\n %[mw] Memory being written to storage" | ||
30 | //usage: "\n %[mf] Free memory" | 32 | //usage: "\n %[mf] Free memory" |
31 | //usage: "\n %[mt] Total memory" | 33 | //usage: "\n %[mt] Total memory" |
32 | //usage: "\n %s Allocated swap" | 34 | //usage: "\n %s Allocated swap" |
@@ -208,7 +210,7 @@ enum conv_type { | |||
208 | // Reads decimal values from line. Values start after key, for example: | 210 | // Reads decimal values from line. Values start after key, for example: |
209 | // "cpu 649369 0 341297 4336769..." - key is "cpu" here. | 211 | // "cpu 649369 0 341297 4336769..." - key is "cpu" here. |
210 | // Values are stored in vec[]. | 212 | // Values are stored in vec[]. |
211 | // posbits is a bit lit of positions we are interested in. | 213 | // posbits is a bit list of positions we are interested in. |
212 | // for example: 00100110 - we want 1st, 2nd and 5th value. | 214 | // for example: 00100110 - we want 1st, 2nd and 5th value. |
213 | // posbits.bit0 encodes conversion type. | 215 | // posbits.bit0 encodes conversion type. |
214 | static int rdval(const char* p, const char* key, ullong *vec, long posbits) | 216 | static int rdval(const char* p, const char* key, ullong *vec, long posbits) |
@@ -661,13 +663,31 @@ S_STAT_END(mem_stat) | |||
661 | //Hugepagesize: 4096 kB | 663 | //Hugepagesize: 4096 kB |
662 | static void FAST_FUNC collect_mem(mem_stat *s) | 664 | static void FAST_FUNC collect_mem(mem_stat *s) |
663 | { | 665 | { |
664 | ullong m_total = 0; | 666 | ullong m_total; |
665 | ullong m_free = 0; | 667 | ullong m_free; |
666 | ullong m_bufs = 0; | 668 | ullong m_bufs; |
667 | ullong m_cached = 0; | 669 | ullong m_cached; |
668 | ullong m_slab = 0; | 670 | ullong m_slab; |
669 | 671 | ||
670 | if (rdval(get_file(&proc_meminfo), "MemTotal:", &m_total, 1 << 1)) { | 672 | const char *meminfo = get_file(&proc_meminfo); |
673 | |||
674 | if (s->opt == 'd' /* dirty page cache */ | ||
675 | || s->opt == 'w' /* under writeback */ | ||
676 | ) { | ||
677 | m_total = 0; /* temporary reuse m_total */ | ||
678 | if (rdval(meminfo, | ||
679 | (s->opt == 'd' ? "Dirty:" : "Writeback:"), | ||
680 | &m_total, 1 << 1) | ||
681 | ) { | ||
682 | put_question_marks(4); | ||
683 | return; | ||
684 | } | ||
685 | scale(m_total << 10); | ||
686 | return; | ||
687 | } | ||
688 | |||
689 | m_total = 0; | ||
690 | if (rdval(meminfo, "MemTotal:", &m_total, 1 << 1)) { | ||
671 | put_question_marks(4); | 691 | put_question_marks(4); |
672 | return; | 692 | return; |
673 | } | 693 | } |
@@ -676,10 +696,14 @@ static void FAST_FUNC collect_mem(mem_stat *s) | |||
676 | return; | 696 | return; |
677 | } | 697 | } |
678 | 698 | ||
679 | if (rdval(proc_meminfo.file, "MemFree:", &m_free , 1 << 1) | 699 | m_free = 0; |
680 | || rdval(proc_meminfo.file, "Buffers:", &m_bufs , 1 << 1) | 700 | m_bufs = 0; |
681 | || rdval(proc_meminfo.file, "Cached:", &m_cached, 1 << 1) | 701 | m_cached = 0; |
682 | || rdval(proc_meminfo.file, "Slab:", &m_slab , 1 << 1) | 702 | m_slab = 0; |
703 | if (rdval(meminfo, "MemFree:", &m_free , 1 << 1) | ||
704 | || rdval(meminfo, "Buffers:", &m_bufs , 1 << 1) | ||
705 | || rdval(meminfo, "Cached:", &m_cached, 1 << 1) | ||
706 | || rdval(meminfo, "Slab:", &m_slab , 1 << 1) | ||
683 | ) { | 707 | ) { |
684 | put_question_marks(4); | 708 | put_question_marks(4); |
685 | return; | 709 | return; |