mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 12:00:58 +07:00
meminfo: break apart a very long seq_printf with #ifdefs
Use a specific routine to emit most lines so that the code is easier to read and maintain. akpm: text data bss dec hex filename 2976 8 0 2984 ba8 fs/proc/meminfo.o before 2669 8 0 2677 a75 fs/proc/meminfo.o after Link: http://lkml.kernel.org/r/8fce7fdef2ba081a4ef531594e97da8a9feebb58.1470810406.git.joe@perches.com Signed-off-by: Joe Perches <joe@perches.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
75ba1d07fd
commit
e16e2d8e14
@ -23,6 +23,25 @@ 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)
|
||||||
|
{
|
||||||
|
char v[32];
|
||||||
|
static const char blanks[7] = {' ', ' ', ' ', ' ',' ', ' ', ' '};
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = num_to_str(v, sizeof(v), num << (PAGE_SHIFT - 10));
|
||||||
|
|
||||||
|
seq_write(m, s, 16);
|
||||||
|
|
||||||
|
if (len > 0) {
|
||||||
|
if (len < 8)
|
||||||
|
seq_write(m, blanks, 8 - len);
|
||||||
|
|
||||||
|
seq_write(m, v, len);
|
||||||
|
}
|
||||||
|
seq_write(m, " kB\n", 4);
|
||||||
|
}
|
||||||
|
|
||||||
static int meminfo_proc_show(struct seq_file *m, void *v)
|
static int meminfo_proc_show(struct seq_file *m, void *v)
|
||||||
{
|
{
|
||||||
struct sysinfo i;
|
struct sysinfo i;
|
||||||
@ -32,10 +51,6 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
|
|||||||
unsigned long pages[NR_LRU_LISTS];
|
unsigned long pages[NR_LRU_LISTS];
|
||||||
int lru;
|
int lru;
|
||||||
|
|
||||||
/*
|
|
||||||
* display in kilobytes.
|
|
||||||
*/
|
|
||||||
#define K(x) ((x) << (PAGE_SHIFT - 10))
|
|
||||||
si_meminfo(&i);
|
si_meminfo(&i);
|
||||||
si_swapinfo(&i);
|
si_swapinfo(&i);
|
||||||
committed = percpu_counter_read_positive(&vm_committed_as);
|
committed = percpu_counter_read_positive(&vm_committed_as);
|
||||||
@ -50,136 +65,100 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
|
|||||||
|
|
||||||
available = si_mem_available();
|
available = si_mem_available();
|
||||||
|
|
||||||
/*
|
show_val_kb(m, "MemTotal: ", i.totalram);
|
||||||
* Tagged format, for easy grepping and expansion.
|
show_val_kb(m, "MemFree: ", i.freeram);
|
||||||
*/
|
show_val_kb(m, "MemAvailable: ", available);
|
||||||
seq_printf(m,
|
show_val_kb(m, "Buffers: ", i.bufferram);
|
||||||
"MemTotal: %8lu kB\n"
|
show_val_kb(m, "Cached: ", cached);
|
||||||
"MemFree: %8lu kB\n"
|
show_val_kb(m, "SwapCached: ", total_swapcache_pages());
|
||||||
"MemAvailable: %8lu kB\n"
|
show_val_kb(m, "Active: ", pages[LRU_ACTIVE_ANON] +
|
||||||
"Buffers: %8lu kB\n"
|
pages[LRU_ACTIVE_FILE]);
|
||||||
"Cached: %8lu kB\n"
|
show_val_kb(m, "Inactive: ", pages[LRU_INACTIVE_ANON] +
|
||||||
"SwapCached: %8lu kB\n"
|
pages[LRU_INACTIVE_FILE]);
|
||||||
"Active: %8lu kB\n"
|
show_val_kb(m, "Active(anon): ", pages[LRU_ACTIVE_ANON]);
|
||||||
"Inactive: %8lu kB\n"
|
show_val_kb(m, "Inactive(anon): ", pages[LRU_INACTIVE_ANON]);
|
||||||
"Active(anon): %8lu kB\n"
|
show_val_kb(m, "Active(file): ", pages[LRU_ACTIVE_FILE]);
|
||||||
"Inactive(anon): %8lu kB\n"
|
show_val_kb(m, "Inactive(file): ", pages[LRU_INACTIVE_FILE]);
|
||||||
"Active(file): %8lu kB\n"
|
show_val_kb(m, "Unevictable: ", pages[LRU_UNEVICTABLE]);
|
||||||
"Inactive(file): %8lu kB\n"
|
show_val_kb(m, "Mlocked: ", global_page_state(NR_MLOCK));
|
||||||
"Unevictable: %8lu kB\n"
|
|
||||||
"Mlocked: %8lu kB\n"
|
|
||||||
#ifdef CONFIG_HIGHMEM
|
#ifdef CONFIG_HIGHMEM
|
||||||
"HighTotal: %8lu kB\n"
|
show_val_kb(m, "HighTotal: ", i.totalhigh);
|
||||||
"HighFree: %8lu kB\n"
|
show_val_kb(m, "HighFree: ", i.freehigh);
|
||||||
"LowTotal: %8lu kB\n"
|
show_val_kb(m, "LowTotal: ", i.totalram - i.totalhigh);
|
||||||
"LowFree: %8lu kB\n"
|
show_val_kb(m, "LowFree: ", i.freeram - i.freehigh);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_MMU
|
#ifndef CONFIG_MMU
|
||||||
"MmapCopy: %8lu kB\n"
|
show_val_kb(m, "MmapCopy: ",
|
||||||
|
(unsigned long)atomic_long_read(&mmap_pages_allocated));
|
||||||
#endif
|
#endif
|
||||||
"SwapTotal: %8lu kB\n"
|
|
||||||
"SwapFree: %8lu kB\n"
|
show_val_kb(m, "SwapTotal: ", i.totalswap);
|
||||||
"Dirty: %8lu kB\n"
|
show_val_kb(m, "SwapFree: ", i.freeswap);
|
||||||
"Writeback: %8lu kB\n"
|
show_val_kb(m, "Dirty: ",
|
||||||
"AnonPages: %8lu kB\n"
|
global_node_page_state(NR_FILE_DIRTY));
|
||||||
"Mapped: %8lu kB\n"
|
show_val_kb(m, "Writeback: ",
|
||||||
"Shmem: %8lu kB\n"
|
global_node_page_state(NR_WRITEBACK));
|
||||||
"Slab: %8lu kB\n"
|
show_val_kb(m, "AnonPages: ",
|
||||||
"SReclaimable: %8lu kB\n"
|
global_node_page_state(NR_ANON_MAPPED));
|
||||||
"SUnreclaim: %8lu kB\n"
|
show_val_kb(m, "Mapped: ",
|
||||||
"KernelStack: %8lu kB\n"
|
global_node_page_state(NR_FILE_MAPPED));
|
||||||
"PageTables: %8lu kB\n"
|
show_val_kb(m, "Shmem: ", i.sharedram);
|
||||||
|
show_val_kb(m, "Slab: ",
|
||||||
|
global_page_state(NR_SLAB_RECLAIMABLE) +
|
||||||
|
global_page_state(NR_SLAB_UNRECLAIMABLE));
|
||||||
|
|
||||||
|
show_val_kb(m, "SReclaimable: ",
|
||||||
|
global_page_state(NR_SLAB_RECLAIMABLE));
|
||||||
|
show_val_kb(m, "SUnreclaim: ",
|
||||||
|
global_page_state(NR_SLAB_UNRECLAIMABLE));
|
||||||
|
seq_printf(m, "KernelStack: %8lu kB\n",
|
||||||
|
global_page_state(NR_KERNEL_STACK_KB));
|
||||||
|
show_val_kb(m, "PageTables: ",
|
||||||
|
global_page_state(NR_PAGETABLE));
|
||||||
#ifdef CONFIG_QUICKLIST
|
#ifdef CONFIG_QUICKLIST
|
||||||
"Quicklists: %8lu kB\n"
|
show_val_kb(m, "Quicklists: ", quicklist_total_size());
|
||||||
#endif
|
#endif
|
||||||
"NFS_Unstable: %8lu kB\n"
|
|
||||||
"Bounce: %8lu kB\n"
|
show_val_kb(m, "NFS_Unstable: ",
|
||||||
"WritebackTmp: %8lu kB\n"
|
global_node_page_state(NR_UNSTABLE_NFS));
|
||||||
"CommitLimit: %8lu kB\n"
|
show_val_kb(m, "Bounce: ",
|
||||||
"Committed_AS: %8lu kB\n"
|
global_page_state(NR_BOUNCE));
|
||||||
"VmallocTotal: %8lu kB\n"
|
show_val_kb(m, "WritebackTmp: ",
|
||||||
"VmallocUsed: %8lu kB\n"
|
global_node_page_state(NR_WRITEBACK_TEMP));
|
||||||
"VmallocChunk: %8lu kB\n"
|
show_val_kb(m, "CommitLimit: ", vm_commit_limit());
|
||||||
|
show_val_kb(m, "Committed_AS: ", committed);
|
||||||
|
seq_printf(m, "VmallocTotal: %8lu kB\n",
|
||||||
|
(unsigned long)VMALLOC_TOTAL >> 10);
|
||||||
|
show_val_kb(m, "VmallocUsed: ", 0ul);
|
||||||
|
show_val_kb(m, "VmallocChunk: ", 0ul);
|
||||||
|
|
||||||
#ifdef CONFIG_MEMORY_FAILURE
|
#ifdef CONFIG_MEMORY_FAILURE
|
||||||
"HardwareCorrupted: %5lu kB\n"
|
seq_printf(m, "HardwareCorrupted: %5lu kB\n",
|
||||||
|
atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
||||||
"AnonHugePages: %8lu kB\n"
|
show_val_kb(m, "AnonHugePages: ",
|
||||||
"ShmemHugePages: %8lu kB\n"
|
global_node_page_state(NR_ANON_THPS) * HPAGE_PMD_NR);
|
||||||
"ShmemPmdMapped: %8lu kB\n"
|
show_val_kb(m, "ShmemHugePages: ",
|
||||||
|
global_node_page_state(NR_SHMEM_THPS) * HPAGE_PMD_NR);
|
||||||
|
show_val_kb(m, "ShmemPmdMapped: ",
|
||||||
|
global_node_page_state(NR_SHMEM_PMDMAPPED) * HPAGE_PMD_NR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_CMA
|
#ifdef CONFIG_CMA
|
||||||
"CmaTotal: %8lu kB\n"
|
show_val_kb(m, "CmaTotal: ", totalcma_pages);
|
||||||
"CmaFree: %8lu kB\n"
|
show_val_kb(m, "CmaFree: ",
|
||||||
|
global_page_state(NR_FREE_CMA_PAGES));
|
||||||
#endif
|
#endif
|
||||||
,
|
|
||||||
K(i.totalram),
|
|
||||||
K(i.freeram),
|
|
||||||
K(available),
|
|
||||||
K(i.bufferram),
|
|
||||||
K(cached),
|
|
||||||
K(total_swapcache_pages()),
|
|
||||||
K(pages[LRU_ACTIVE_ANON] + pages[LRU_ACTIVE_FILE]),
|
|
||||||
K(pages[LRU_INACTIVE_ANON] + pages[LRU_INACTIVE_FILE]),
|
|
||||||
K(pages[LRU_ACTIVE_ANON]),
|
|
||||||
K(pages[LRU_INACTIVE_ANON]),
|
|
||||||
K(pages[LRU_ACTIVE_FILE]),
|
|
||||||
K(pages[LRU_INACTIVE_FILE]),
|
|
||||||
K(pages[LRU_UNEVICTABLE]),
|
|
||||||
K(global_page_state(NR_MLOCK)),
|
|
||||||
#ifdef CONFIG_HIGHMEM
|
|
||||||
K(i.totalhigh),
|
|
||||||
K(i.freehigh),
|
|
||||||
K(i.totalram-i.totalhigh),
|
|
||||||
K(i.freeram-i.freehigh),
|
|
||||||
#endif
|
|
||||||
#ifndef CONFIG_MMU
|
|
||||||
K((unsigned long) atomic_long_read(&mmap_pages_allocated)),
|
|
||||||
#endif
|
|
||||||
K(i.totalswap),
|
|
||||||
K(i.freeswap),
|
|
||||||
K(global_node_page_state(NR_FILE_DIRTY)),
|
|
||||||
K(global_node_page_state(NR_WRITEBACK)),
|
|
||||||
K(global_node_page_state(NR_ANON_MAPPED)),
|
|
||||||
K(global_node_page_state(NR_FILE_MAPPED)),
|
|
||||||
K(i.sharedram),
|
|
||||||
K(global_page_state(NR_SLAB_RECLAIMABLE) +
|
|
||||||
global_page_state(NR_SLAB_UNRECLAIMABLE)),
|
|
||||||
K(global_page_state(NR_SLAB_RECLAIMABLE)),
|
|
||||||
K(global_page_state(NR_SLAB_UNRECLAIMABLE)),
|
|
||||||
global_page_state(NR_KERNEL_STACK_KB),
|
|
||||||
K(global_page_state(NR_PAGETABLE)),
|
|
||||||
#ifdef CONFIG_QUICKLIST
|
|
||||||
K(quicklist_total_size()),
|
|
||||||
#endif
|
|
||||||
K(global_node_page_state(NR_UNSTABLE_NFS)),
|
|
||||||
K(global_page_state(NR_BOUNCE)),
|
|
||||||
K(global_node_page_state(NR_WRITEBACK_TEMP)),
|
|
||||||
K(vm_commit_limit()),
|
|
||||||
K(committed),
|
|
||||||
(unsigned long)VMALLOC_TOTAL >> 10,
|
|
||||||
0ul, // used to be vmalloc 'used'
|
|
||||||
0ul // used to be vmalloc 'largest_chunk'
|
|
||||||
#ifdef CONFIG_MEMORY_FAILURE
|
|
||||||
, atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
|
||||||
, K(global_node_page_state(NR_ANON_THPS) * HPAGE_PMD_NR)
|
|
||||||
, K(global_node_page_state(NR_SHMEM_THPS) * HPAGE_PMD_NR)
|
|
||||||
, K(global_node_page_state(NR_SHMEM_PMDMAPPED) * HPAGE_PMD_NR)
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_CMA
|
|
||||||
, K(totalcma_pages)
|
|
||||||
, K(global_page_state(NR_FREE_CMA_PAGES))
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
hugetlb_report_meminfo(m);
|
hugetlb_report_meminfo(m);
|
||||||
|
|
||||||
arch_report_meminfo(m);
|
arch_report_meminfo(m);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#undef K
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int meminfo_proc_open(struct inode *inode, struct file *file)
|
static int meminfo_proc_open(struct inode *inode, struct file *file)
|
||||||
|
Loading…
Reference in New Issue
Block a user