aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
Diffstat (limited to 'procps')
-rw-r--r--procps/nmeter.c46
-rw-r--r--procps/powertop.c5
2 files changed, 36 insertions, 15 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.
214static int rdval(const char* p, const char* key, ullong *vec, long posbits) 216static 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
662static void FAST_FUNC collect_mem(mem_stat *s) 664static 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;
diff --git a/procps/powertop.c b/procps/powertop.c
index 24c2b320f..18ddaa3ec 100644
--- a/procps/powertop.c
+++ b/procps/powertop.c
@@ -506,12 +506,9 @@ static void cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx,
506{ 506{
507 /* EAX value specifies what information to return */ 507 /* EAX value specifies what information to return */
508 asm ( 508 asm (
509 " pushl %%ebx\n" /* Save EBX */
510 " cpuid\n" 509 " cpuid\n"
511 " movl %%ebx, %1\n" /* Save content of EBX */
512 " popl %%ebx\n" /* Restore EBX */
513 : "=a"(*eax), /* Output */ 510 : "=a"(*eax), /* Output */
514 "=r"(*ebx), 511 "=b"(*ebx),
515 "=c"(*ecx), 512 "=c"(*ecx),
516 "=d"(*edx) 513 "=d"(*edx)
517 : "0"(*eax), /* Input */ 514 : "0"(*eax), /* Input */