Skip to contentSkip to conversation

Unit mismatch (Slab/SReclaimable/SUnreclaim) in meminfo

PATCH In review Hyeonggon Yoo 1 participant 3 messages Oct 16, 2021 – Oct 17, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Unit mismatch (Slab/SReclaimable/SUnreclaim) in meminfo

Hello, it seems there's mismatch in unit (byte and kB) in meminfo. Would something like this will be acceptable?

commit d42f3245c7e2 ("mm: memcg: convert vmstat slab counters to bytes") changed it to bytes but proc seems to print everything in kilobytes.

---
 fs/proc/meminfo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/proc/meminfo.c +2 -2
index 6fa761c9cc78..182376582076 100644
@@ -52,8 +52,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
 		pages[lru] = global_node_page_state(NR_LRU_BASE + lru);
 
 	available = si_mem_available();
-	sreclaimable = global_node_page_state_pages(NR_SLAB_RECLAIMABLE_B);
-	sunreclaim = global_node_page_state_pages(NR_SLAB_UNRECLAIMABLE_B);
+	sreclaimable = global_node_page_state_pages(NR_SLAB_RECLAIMABLE_B) / 1024;
+	sunreclaim = global_node_page_state_pages(NR_SLAB_UNRECLAIMABLE_B) / 1024;
 
 	show_val_kb(m, "MemTotal:       ", i.totalram);
 	show_val_kb(m, "MemFree:        ", i.freeram);
Signature · 1 line
2.27.0
#1 lore raw

Not [PATCH] :)

Quoted 7 lines · Hyeonggon Yoo

Hello, it seems there's mismatch in unit (byte and kB) in meminfo. Would something like this will be acceptable?

commit d42f3245c7e2 ("mm: memcg: convert vmstat slab counters to bytes") changed it to bytes but proc seems to print everything in kilobytes.

This is not actually patch - I'll send you a patch if this is not my misunderstanding :)

Thanks,
Hyeonggon.

Quoted 22 lines
---
 fs/proc/meminfo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/proc/meminfo.c +2 -2
index 6fa761c9cc78..182376582076 100644
@@ -52,8 +52,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
 		pages[lru] = global_node_page_state(NR_LRU_BASE + lru);
 
 	available = si_mem_available();
-	sreclaimable = global_node_page_state_pages(NR_SLAB_RECLAIMABLE_B);
-	sunreclaim = global_node_page_state_pages(NR_SLAB_UNRECLAIMABLE_B);
+	sreclaimable = global_node_page_state_pages(NR_SLAB_RECLAIMABLE_B) / 1024;
+	sunreclaim = global_node_page_state_pages(NR_SLAB_UNRECLAIMABLE_B) / 1024;
 
 	show_val_kb(m, "MemTotal:       ", i.totalram);
 	show_val_kb(m, "MemFree:        ", i.freeram);
Signature · 1 line
2.27.0
#2 lore raw
In reply to Hyeonggon Yoo
Quoted 7 lines · Hyeonggon Yoo

Hello, it seems there's mismatch in unit (byte and kB) in meminfo. Would something like this will be acceptable?

commit d42f3245c7e2 ("mm: memcg: convert vmstat slab counters to bytes") changed it to bytes but proc seems to print everything in kilobytes.

Ignore this.

this was my misunderstanding of code :(
It internally converts to kilobytes when updating its data.

Quoted 22 lines
---
 fs/proc/meminfo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/proc/meminfo.c +2 -2
index 6fa761c9cc78..182376582076 100644
@@ -52,8 +52,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
 		pages[lru] = global_node_page_state(NR_LRU_BASE + lru);
 
 	available = si_mem_available();
-	sreclaimable = global_node_page_state_pages(NR_SLAB_RECLAIMABLE_B);
-	sunreclaim = global_node_page_state_pages(NR_SLAB_UNRECLAIMABLE_B);
+	sreclaimable = global_node_page_state_pages(NR_SLAB_RECLAIMABLE_B) / 1024;
+	sunreclaim = global_node_page_state_pages(NR_SLAB_UNRECLAIMABLE_B) / 1024;
 
 	show_val_kb(m, "MemTotal:       ", i.totalram);
 	show_val_kb(m, "MemFree:        ", i.freeram);
Signature · 1 line
2.27.0