内存管理-31-系统内存统计-3-/proc/zoneinfo
基于msm-5.4
一、概述
/proc/zoneinfo 节点包含当前系统所有内存管理区的信息。
1. 打印内容
# cat /proc/zoneinfo Node 0, zone Normal //Normal内存区 /* 第(1)部分,打印的是全局变量 vm_node_stat[i] 的值 */ per-node stats nr_inactive_anon 152477 nr_active_anon 749181 nr_inactive_file 1028670 nr_active_file 143843 nr_unevictable 826 nr_slab_reclaimable 50752 nr_slab_unreclaimable 190516 nr_isolated_anon 0 nr_isolated_file 0 workingset_nodes 29087 workingset_refault 1824839 workingset_activate 16816 workingset_restore 204 workingset_nodereclaim 0 nr_anon_pages 883523 nr_mapped 361497 nr_file_pages 1205571 nr_dirty 133 nr_writeback 0 nr_writeback_temp 0 nr_shmem 18356 nr_shmem_hugepages 0 nr_shmem_pmdmapped 0 nr_file_hugepages 0 nr_file_pmdmapped 0 nr_anon_transparent_hugepages 0 nr_unstable 0 nr_vmscan_write 51492 nr_vmscan_immediate_reclaim 18 nr_dirtied 3002641 nr_written 2886401 nr_kernel_misc_reclaimable 47191 nr_unreclaimable_pages 206956 /* 第(2)部分 */ pages free 171227 //zone->vm_stat[NR_FREE_PAGES] min 32363 //zone->_watermark[WMARK_MIN] + zone->watermark_boost 单位: pages low 46813 //zone->_watermark[WMARK_LOW] + zone->watermark_boost high 47742 //zone->_watermark[WMARK_HIGH] + zone->watermark_boost spanned 8164351 //zone->spanned_pages present 3556807 //zone->present_pages managed 3463695 //zone->managed_pages protection: (0, 0) //zone->lowmem_reserve[0], zone->lowmem_reserve[1] /* 第(3)部分, 打印的是 zone->vm_stat[item] 的值 */ nr_free_pages 171227 nr_zone_inactive_anon 152477 nr_zone_active_anon 749181 nr_zone_inactive_file 1028670 nr_zone_active_file 143843 nr_zone_unevictable 826 nr_zone_write_pending 73 nr_mlock 826 nr_page_table_pages 28872 nr_kernel_stack 62736 nr_shadow_call_stack_bytes 16072704 nr_bounce 0 nr_zspages 7759 nr_free_cma 1 /* 第(4)部分, 打印每cpu成员 zone->pageset 中部分成员的值 */ pagesets cpu: 0 //cpu id count: 131 //zone->pageset->pcp.count high: 378 //zone->pageset->pcp.high batch: 63 //zone->pageset->pcp.batch vm stats threshold: 64 //zone->pageset->stat_threshold cpu: 1 count: 46 high: 378 batch: 63 vm stats threshold: 64 cpu: 2 count: 10 high: 378 batch: 63 vm stats threshold: 64 cpu: 3 count: 102 high: 378 batch: 63 vm stats threshold: 64 cpu: 4 count: 129 high: 378 batch: 63 vm stats threshold: 64 cpu: 5 count: 150 high: 378 batch: 63 vm stats threshold: 64 cpu: 6 count: 320 high: 378 batch: 63 vm stats threshold: 64 cpu: 7 count: 33 high: 378 batch: 63 vm stats threshold: 64 /* 第(5)部分 */ node_unreclaimable: 0 //pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES(16) 的比较结果 start_pfn: 716033 //zone->zone_start_pfn /* 第(6)部分, 打印另一个zone的信息 */ Node 0, zone Movable //Movable内存区 pages free 0 min 0 low 0 high 0 spanned 0 present 0 managed 0 protection: (0, 0) //往下没有打印了,说明Movable zone->present_pages为0,即此zone没有物理内存
部分成员介绍:
pages free: 打印的是 zone->vm_stat[NR_FREE_PAGES],表示这个内存管理区中空闲页面的数量。
min: 打印的是 zone->_watermark[WMARK_MIN] + zone->watermark_boost,表示这个内存管理区中处于最低警戒水位的页面的数量。详见 __setup_per_zone_wmarks()
low: 打印的是 zone->_watermark[WMARK_LOW] + zone->watermark_boost,表示这个内存管理区中处于低水位的页面的数量。
high: 打印的是 zone->_watermark[WMARK_HIGH] + zone->watermark_boost,表示这个内存管理区中处于高水位的页面的数量。
spanned: 打印的是 zone->spanned_pages,表示这个管理区跨越的页面数量,包含空洞。
present: 打印的是 zone->present_pages,表示这个管理区中实际页面的数量。
managed: 打印的是 zone->managed_pages,表示这个管理区中被伙伴系统管理的页面数量。
protection: 打印的是(zone->lowmem_reserve[0], zone->lowmem_reserve[1]), 表示这个管理区预留的内存的数量。
start_pfn: 打印的是 zone->zone_start_pfn, 表示此zone的起始页帧号。
二、打印位置
void __init init_mm_internals(void) //vmstat.c proc_create_seq("zoneinfo", 0444, NULL, &zoneinfo_op); } static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat, struct zone *zone) //vmstat.c { int i; seq_printf(m, "Node %d, zone %8s", pgdat->node_id, zone->name); /* 找到第一个存在物理页面的zone */ if (is_zone_first_populated(pgdat, zone)) { /* 打印第(1)部分 */ seq_printf(m, "\n per-node stats"); /* 打印的是全局数组变量 vm_node_stat[i] 的值 */ for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) { //NR_VM_NUMA_STAT_ITEMS 是0 seq_printf(m, "\n %-12s %lu", vmstat_text[i + NR_VM_ZONE_STAT_ITEMS + NR_VM_NUMA_STAT_ITEMS], node_page_state(pgdat, i)); } } /* 打印第(2)部分信息 */ seq_printf(m, "\n pages free %lu" "\n min %lu" "\n low %lu" "\n high %lu" "\n spanned %lu" "\n present %lu" "\n managed %lu", zone_page_state(zone, NR_FREE_PAGES), //zone->vm_stat[NR_FREE_PAGES] min_wmark_pages(zone), //zone->_watermark[WMARK_MIN] + zone->watermark_boost low_wmark_pages(zone), //zone->_watermark[WMARK_LOW] + zone->watermark_boost high_wmark_pages(zone), //zone->_watermark[WMARK_HIGH] + zone->watermark_boost zone->spanned_pages, zone->present_pages, zone_managed_pages(zone)); //zone->managed_pages seq_printf(m, "\n protection: (%ld", zone->lowmem_reserve[0]); for (i = 1; i < ARRAY_SIZE(zone->lowmem_reserve); i++) //2 seq_printf(m, ", %ld", zone->lowmem_reserve[i]); seq_putc(m, ')'); /* If unpopulated, no other information is useful */ if (!populated_zone(zone)) { //若 zone->present_pages 为0,则不打印了,Moveable zone将从则从这里退出 seq_putc(m, '\n'); return; } /* 打印第(3)部分信息,打印的是 zone->vm_stat[item] 的值 */ for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) seq_printf(m, "\n %-12s %lu", vmstat_text[i], zone_page_state(zone, i)); /* 打印第第(4)部分, 打印每cpu成员 zone->pageset 中部分成员的值 */ seq_printf(m, "\n pagesets"); for_each_online_cpu(i) { struct per_cpu_pageset *pageset; pageset = per_cpu_ptr(zone->pageset, i); seq_printf(m, "\n cpu: %i" "\n count: %i" "\n high: %i" "\n batch: %i", i, pageset->pcp.count, pageset->pcp.high, pageset->pcp.batch); #ifdef CONFIG_SMP seq_printf(m, "\n vm stats threshold: %d", pageset->stat_threshold); #endif } /* 打印第(5)部分信息 */ seq_printf(m, "\n node_unreclaimable: %u" "\n start_pfn: %lu", pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES, zone->zone_start_pfn); seq_putc(m, '\n'); }
posted on 2024-08-27 21:32 Hello-World3 阅读(102) 评论(0) 编辑 收藏 举报