cregit-Linux how code gets into the kernel

Release 4.10 fs/proc/meminfo.c

Directory: fs/proc
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/hugetlb.h>
#include <linux/mman.h>
#include <linux/mmzone.h>
#include <linux/proc_fs.h>
#include <linux/quicklist.h>
#include <linux/seq_file.h>
#include <linux/swap.h>
#include <linux/vmstat.h>
#include <linux/atomic.h>
#include <linux/vmalloc.h>
#ifdef CONFIG_CMA
#include <linux/cma.h>
#endif
#include <asm/page.h>
#include <asm/pgtable.h>
#include "internal.h"


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); }

Contributors

PersonTokensPropCommitsCommitProp
joe perchesjoe perches125100.00%1100.00%
Total125100.00%1100.00%


static int meminfo_proc_show(struct seq_file *m, void *v) { struct sysinfo i; unsigned long committed; long cached; long available; unsigned long pages[NR_LRU_LISTS]; int lru; si_meminfo(&i); si_swapinfo(&i); committed = percpu_counter_read_positive(&vm_committed_as); cached = global_node_page_state(NR_FILE_PAGES) - total_swapcache_pages() - i.bufferram; if (cached < 0) cached = 0; for (lru = LRU_BASE; lru < NR_LRU_LISTS; lru++) pages[lru] = global_node_page_state(NR_LRU_BASE + lru); available = si_mem_available(); show_val_kb(m, "MemTotal: ", i.totalram); show_val_kb(m, "MemFree: ", i.freeram); show_val_kb(m, "MemAvailable: ", available); show_val_kb(m, "Buffers: ", i.bufferram); show_val_kb(m, "Cached: ", cached); show_val_kb(m, "SwapCached: ", total_swapcache_pages()); show_val_kb(m, "Active: ", pages[LRU_ACTIVE_ANON] + pages[LRU_ACTIVE_FILE]); show_val_kb(m, "Inactive: ", pages[LRU_INACTIVE_ANON] + pages[LRU_INACTIVE_FILE]); show_val_kb(m, "Active(anon): ", pages[LRU_ACTIVE_ANON]); show_val_kb(m, "Inactive(anon): ", pages[LRU_INACTIVE_ANON]); show_val_kb(m, "Active(file): ", pages[LRU_ACTIVE_FILE]); show_val_kb(m, "Inactive(file): ", pages[LRU_INACTIVE_FILE]); show_val_kb(m, "Unevictable: ", pages[LRU_UNEVICTABLE]); show_val_kb(m, "Mlocked: ", global_page_state(NR_MLOCK)); #ifdef CONFIG_HIGHMEM show_val_kb(m, "HighTotal: ", i.totalhigh); show_val_kb(m, "HighFree: ", i.freehigh); show_val_kb(m, "LowTotal: ", i.totalram - i.totalhigh); show_val_kb(m, "LowFree: ", i.freeram - i.freehigh); #endif #ifndef CONFIG_MMU show_val_kb(m, "MmapCopy: ", (unsigned long)atomic_long_read(&mmap_pages_allocated)); #endif show_val_kb(m, "SwapTotal: ", i.totalswap); show_val_kb(m, "SwapFree: ", i.freeswap); show_val_kb(m, "Dirty: ", global_node_page_state(NR_FILE_DIRTY)); show_val_kb(m, "Writeback: ", global_node_page_state(NR_WRITEBACK)); show_val_kb(m, "AnonPages: ", global_node_page_state(NR_ANON_MAPPED)); show_val_kb(m, "Mapped: ", global_node_page_state(NR_FILE_MAPPED)); 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 show_val_kb(m, "Quicklists: ", quicklist_total_size()); #endif show_val_kb(m, "NFS_Unstable: ", global_node_page_state(NR_UNSTABLE_NFS)); show_val_kb(m, "Bounce: ", global_page_state(NR_BOUNCE)); show_val_kb(m, "WritebackTmp: ", global_node_page_state(NR_WRITEBACK_TEMP)); 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 seq_printf(m, "HardwareCorrupted: %5lu kB\n", atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)); #endif #ifdef CONFIG_TRANSPARENT_HUGEPAGE show_val_kb(m, "AnonHugePages: ", global_node_page_state(NR_ANON_THPS) * HPAGE_PMD_NR); 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 #ifdef CONFIG_CMA show_val_kb(m, "CmaTotal: ", totalcma_pages); show_val_kb(m, "CmaFree: ", global_page_state(NR_FREE_CMA_PAGES)); #endif hugetlb_report_meminfo(m); arch_report_meminfo(m); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
alexey dobriyanalexey dobriyan31944.43%14.17%
joe perchesjoe perches27838.72%14.17%
david howellsdavid howells162.23%28.33%
andi kleenandi kleen162.23%14.17%
kirill a. shutemovkirill a. shutemov152.09%14.17%
pintu kumarpintu kumar141.95%14.17%
mel gormanmel gorman121.67%416.67%
andrea arcangeliandrea arcangeli111.53%14.17%
rik van rielrik van riel111.53%14.17%
kosaki motohirokosaki motohiro91.25%312.50%
claudio scordinoclaudio scordino40.56%14.17%
rafael aquinirafael aquini30.42%14.17%
shaohua lishaohua li20.28%14.17%
linus torvaldslinus torvalds20.28%14.17%
igor redkoigor redko20.28%14.17%
jerome marchandjerome marchand20.28%14.17%
andy lutomirskiandy lutomirski10.14%14.17%
xishi qiuxishi qiu10.14%14.17%
Total718100.00%24100.00%


static int meminfo_proc_open(struct inode *inode, struct file *file) { return single_open(file, meminfo_proc_show, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
alexey dobriyanalexey dobriyan26100.00%1100.00%
Total26100.00%1100.00%

static const struct file_operations meminfo_proc_fops = { .open = meminfo_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, };
static int __init proc_meminfo_init(void) { proc_create("meminfo", 0, NULL, &meminfo_proc_fops); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
alexey dobriyanalexey dobriyan24100.00%1100.00%
Total24100.00%1100.00%

fs_initcall(proc_meminfo_init);

Overall Contributors

PersonTokensPropCommitsCommitProp
alexey dobriyanalexey dobriyan45945.90%13.57%
joe perchesjoe perches40340.30%13.57%
pintu kumarpintu kumar222.20%13.57%
kirill a. shutemovkirill a. shutemov191.90%27.14%
andi kleenandi kleen161.60%13.57%
david howellsdavid howells161.60%27.14%
mel gormanmel gorman121.20%414.29%
andrea arcangeliandrea arcangeli111.10%13.57%
rik van rielrik van riel111.10%13.57%
kosaki motohirokosaki motohiro90.90%310.71%
claudio scordinoclaudio scordino40.40%13.57%
joonsoo kimjoonsoo kim30.30%13.57%
rafael aquinirafael aquini30.30%13.57%
shaohua lishaohua li20.20%13.57%
linus torvaldslinus torvalds20.20%13.57%
igor redkoigor redko20.20%13.57%
jerome marchandjerome marchand20.20%13.57%
xishi qiuxishi qiu10.10%13.57%
arun sharmaarun sharma10.10%13.57%
andy lutomirskiandy lutomirski10.10%13.57%
paul gortmakerpaul gortmaker10.10%13.57%
Total1000100.00%28100.00%
Directory: fs/proc
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.