Zoned VM counters V4
Subsystems (19)
cover Zoned VM counters V4
NOTE: ZVC are *not* the lightweight event counters. ZVCs are reliable whereas event counters do not need to be.
Zone based VM statistics are necessary to be able to determine what the state of memory in one zone is. In a NUMA system this can be helpful for local reclaim and other memory optimizations that may be able to shift VM load in order to get more balanced memory use.
It is also useful to know how the computing load affects the memory allocations on various zones. This patchset allows the retrieval of that data from userspace.
The patchset introduces a framework for counters that is a cross between the existing page_stats --which are simply global counters split per cpu-- and the approach of deferred incremental updates implemented for nr_pagecache.
Small per cpu 8 bit counters are added to struct zone. If the counter exceeds certain thresholds then the counters are accumulated in an array of atomic_long in the zone and in a global array that sums up all zone values. The small 8 bit counters are next to the per cpu page pointers and so they will be in high in the cpu cache when pages are allocated and freed.
Access to VM counter information for a zone and for the whole machine is then possible by simply indexing an array (Thanks to Nick Piggin for pointing out that approach). The access to the total number of pages of various types does no longer require the summing up of all per cpu counters.
Benefits of this patchset right now:
- Ability for UP and SMP configuration to determine how memory is balanced between the DMA, NORMAL and HIGHMEM zones.
- loops over all processors are avoided in writeback and reclaim paths. We can avoid caching the writeback information because the needed information is directly accessible.
- Special handling for nr_pagecache removed.
- zone_reclaim_interval vanishes since VM stats can now determine when it is worth to do local reclaim.
- Fast inline per node page state determination.
- Accurate counters in /sys/devices/system/node/node*/meminfo. Current counters are counting simply which processor allocated a page somewhere and guestimate based on that. So the counters were not useful to show the actual distribution of page use on a specific zone.
- The swap_prefetch patch requires per node statistics in order to figure out when processors of a node can prefetch. This patch provides some of the needed numbers.
- Detailed VM counters available in more /proc and /sys status files.
References to earlier discussions:
V1 http://marc.theaimsgroup.com/?l=linux-kernel&m=113511649910826&w=2
V2 http://marc.theaimsgroup.com/?l=linux-kernel&m=114980851924230&w=2
V3 http://marc.theaimsgroup.com/?l=linux-kernel&m=115014697910351&w=2
Performance tests with AIM7 did not show any regressions. Seems to be a tad faster even. Tested on ia64/NUMA. Builds fine on i386, SMP / UP. Includes fixes for s390/arm/uml arch code.
Changelog
V1->V2:
- Cleanup code, resequence and base patches on 2.6.17-rc6-mm1
- Reduce interrupt holdoffs
- Add zone reclaim interval removal patch
V2->V3:
- Against temp tree by Andrew. (2.6.17-rc6-mm2 - old patches) Temp patch at http://www.zip.com.au/~akpm/linux/patches/stuff/cl.bz2
- Incorporate additional fixes for arch code.
- Create vmstat.c/h from pieces of page_alloc.c.
- Do the swap prefetch support patches the right way.
- Reorganize patchset so that the tree compiles after each patch (However, swap prefetch/reiser4 patches are separate. So if a swap prefetch patch follows then two patches must be applied for the kernel to compile again).
- Do various prescribed tests. Make sure that there is no remaining reference to page state in some arch code.
- Optimize the node_page_state function so that it can be used inline.
V3->V4:
- nr_pagecache definition was not cleaned up in V3.
- Fix nfs issues with NR_UNSTABLE where the page reference was not valid and with NR_DIRTY.
- Update swap_prefetch patches after feedback from Colin.
- Rename NR_STAT_ITEMS to NR_VM_ZONE_STAT_ITEMS.
- IA64: Make CONFIG_DMA_IS_NORMAL depend on SGI_SN2. Others may be added in the future.
- Fix order issues with vmstat
- Limit crossposting
The patchset consists of 21 patches that are following this one and is
against a temp patch against 2.6.17-rc6 at
http://www.zip.com.au/~akpm/linux/patches/stuff/cl.bz2
plus a small fix from http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blobdiff_plain;h=440a733fe2e9ea3d1374d4fd72e7bba60e268e05;hp=4649a63a8cb6f9c3892e92538b394f754295a90e
PATCH 1/21 Create vmstat.c/.h from page_alloc.c/.h
Move counter code from page_alloc.c/page-flags.h to vmstat.c/h.
Create vmstat.c/vmstat.h by separating the counter code and the proc functions.
Move the vm_stat_text array before zoneinfo_show.
include/linux/page-flags.h +1 -133
@@ -5,11 +5,7 @@#ifndef PAGE_FLAGS_H #define PAGE_FLAGS_H -#include <linux/percpu.h> -#include <linux/cache.h> -#include <linux/types.h> - -#include <asm/pgtable.h> +#include <linux/vmstat.h> /* * Various page->flags bits:
@@ -105,134 +101,6 @@#endif /* -* Global page accounting. One instance per CPU. Only unsigned longs are -* allowed. -* -* - Fields can be modified with xxx_page_state and xxx_page_state_zone at -* any time safely (which protects the instance from modification by -* interrupt. -* - The __xxx_page_state variants can be used safely when interrupts are -* disabled. -* - The __xxx_page_state variants can be used if the field is only -* modified from process context and protected from preemption, or only -* modified from interrupt context. In this case, the field should be -* commented here. -*/ -struct page_state { -unsigned long nr_dirty;/* Dirty writeable pages */ -unsigned long nr_writeback;/* Pages under writeback */ -unsigned long nr_unstable;/* NFS unstable pages */ -unsigned long nr_page_table_pages;/* Pages used for pagetables */ -unsigned long nr_mapped;/* mapped into pagetables. -* only modified from process context */ -unsigned long nr_slab;/* In slab */ -#define GET_PAGE_STATE_LAST nr_slab - -/* -* The below are zeroed by get_page_state(). Use get_full_page_state() -* to add up all these. -*/ -unsigned long pgpgin;/* Disk reads */ -unsigned long pgpgout;/* Disk writes */ -unsigned long pswpin;/* swap reads */ -unsigned long pswpout;/* swap writes */ - -unsigned long pgalloc_high;/* page allocations */ -unsigned long pgalloc_normal; -unsigned long pgalloc_dma32; -unsigned long pgalloc_dma; - -unsigned long pgfree;/* page freeings */ -unsigned long pgactivate;/* pages moved inactive->active */ -unsigned long pgdeactivate;/* pages moved active->inactive */ - -unsigned long pgfault;/* faults (major+minor) */ -unsigned long pgmajfault;/* faults (major only) */ - -unsigned long pgrefill_high;/* inspected in refill_inactive_zone */ -unsigned long pgrefill_normal; -unsigned long pgrefill_dma32; -unsigned long pgrefill_dma; - -unsigned long pgsteal_high;/* total highmem pages reclaimed */ -unsigned long pgsteal_normal; -unsigned long pgsteal_dma32; -unsigned long pgsteal_dma; - -unsigned long pgscan_kswapd_high;/* total highmem pages scanned */ -unsigned long pgscan_kswapd_normal; -unsigned long pgscan_kswapd_dma32; -unsigned long pgscan_kswapd_dma; - -unsigned long pgscan_direct_high;/* total highmem pages scanned */ -unsigned long pgscan_direct_normal; -unsigned long pgscan_direct_dma32; -unsigned long pgscan_direct_dma; - -unsigned long pginodesteal;/* pages reclaimed via inode freeing */ -unsigned long slabs_scanned;/* slab objects scanned */ -unsigned long kswapd_steal;/* pages reclaimed by kswapd */ -unsigned long kswapd_inodesteal;/* reclaimed via kswapd inode freeing */ -unsigned long pageoutrun;/* kswapd's calls to page reclaim */ -unsigned long allocstall;/* direct reclaim calls */ - -unsigned long pgrotated;/* pages rotated to tail of the LRU */ -unsigned long nr_bounce;/* pages for bounce buffers */ -}; - -extern void get_page_state (struct page_state *ret); -extern void get_page_state_node (struct page_state *ret,int node); -extern void get_full_page_state (struct page_state *ret); -extern unsigned long read_page_state_offset (unsigned long offset); -extern void mod_page_state_offset (unsigned long offset,unsigned long delta); -extern void __mod_page_state_offset (unsigned long offset,unsigned long delta); - -#define read_page_state (member) \ - read_page_state_offset(offsetof(struct page_state, member)) - -#define mod_page_state (member, delta) \ - mod_page_state_offset(offsetof(struct page_state, member), (delta)) - -#define __mod_page_state (member, delta) \ - __mod_page_state_offset(offsetof(struct page_state, member), (delta)) - -#define inc_page_state (member) mod_page_state(member, 1UL) -#define dec_page_state (member) mod_page_state(member, 0UL - 1) -#define add_page_state (member,delta) mod_page_state(member, (delta)) -#define sub_page_state (member,delta) mod_page_state(member, 0UL - (delta)) - -#define __inc_page_state (member) __mod_page_state(member, 1UL) -#define __dec_page_state (member) __mod_page_state(member, 0UL - 1) -#define __add_page_state (member,delta) __mod_page_state(member, (delta)) -#define __sub_page_state (member,delta) __mod_page_state(member, 0UL - (delta)) - -#define page_state (member) (*__page_state(offsetof(struct page_state, member))) - -#define state_zone_offset (zone, member) \ -({ \ - unsigned offset; \ - if (is_highmem(zone)) \ - offset = offsetof(struct page_state, member##_high); \ - else if (is_normal(zone)) \ - offset = offsetof(struct page_state, member##_normal); \ - else if (is_dma32(zone)) \ - offset = offsetof(struct page_state, member##_dma32); \ - else \ - offset = offsetof(struct page_state, member##_dma); \ - offset; \ -}) - -#define __mod_page_state_zone (zone, member, delta) \ - do { \ - __mod_page_state_offset(state_zone_offset(zone, member), (delta)); \ - } while (0) - -#define mod_page_state_zone (zone, member, delta) \ - do { \ - mod_page_state_offset(state_zone_offset(zone, member), (delta)); \ - } while (0) - -/* * Manipulation of page state flags */ #define PageLocked (page) \
mm/Makefile +1 -1
@@ -10,7 +10,7 @@ mmu-$(CONFIG_MMU) := fremap.o highmem.o obj-y := bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \ page_alloc.o page-writeback.o pdflush.o \ readahead.o swap.o truncate.o vmscan.o \ - prio_tree.o util.o mmzone.o $(mmu-y) + prio_tree.o util.o mmzone.o vmstat.o $(mmu-y) obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o thrash.o obj-$(CONFIG_SWAP_PREFETCH) += swap_prefetch.o
include/linux/mm.h +1 -1
@@ -4,6 +4,7 @@#include <linux/sched.h> #include <linux/errno.h> #include <linux/capability.h> +#include <linux/vmstat.h> #ifdef __KERNEL__
@@ -37,7 +38,6 @@ extern int sysctl_legacy_va_layout;#include <asm/page.h> #include <asm/pgtable.h> #include <asm/processor.h> -#include <asm/atomic.h> #define nth_page (page,n) pfn_to_page(page_to_pfn((page)) + (n))
include/linux/vmstat.h new file +135 -0
135 lines not on this page · raw message
mm/vmstat.c new file +417 -0
417 lines not on this page · raw message
mm/page_alloc.c +0 -407
419 lines not on this page · raw message
PATCH 2/21 Basic ZVC (zoned vm counter) implementation
In reply to Christoph LameterSubject: zoned vm counters: per zone counter functionality
From: Christoph Lameter <[email protected]>
Per zone counter infrastructure
The counters that we currently have for the VM are split per processor. The processor however has not much to do with the zone these pages belong to. We cannot tell f.e. how many ZONE_DMA pages are dirty.
So we are blind to potentially inbalances in the usage of memory in various zones. F.e. in a NUMA system we cannot tell how many pages are dirty on a particular node. If we knew then we could put measures into the VM to balance the use of memory between different zones and different nodes in a NUMA system. For example it would be possible to limit the dirty pages per node so that fast local memory is kept available even if a process is dirtying huge amounts of pages.
Another example is zone reclaim. We do not know how many unmapped pages exist per zone. So we just have to try to reclaim. If it is not working then we pause and try again later. It would be better if we knew when it makes sense to reclaim unmapped pages from a zone. This patchset allows the determination of the number of unmapped pages per zone. We can remove the zone reclaim interval with the counters introduced here.
Futhermore the ability to have various usage statistics available will allow the development of new NUMA balancing algorithms that may be able to improve the decision making in the scheduler of when to move a process to another node and hopefully will also enable automatic page migration through a user space program that can analyse the memory load distribution and then rebalance memory use in order to increase performance.
The counter framework here implements differential counters for each processor in struct zone. The differential counters are consolidated when a threshold is exceeded (like done in the current implementation for nr_pageache), when slab reaping occurs or when a consolidation function is called.
Consolidation uses atomic operations and accumulates counters per zone in the zone structure and also globally in the vm_stat array. VM functions can access the counts by simply indexing a global or zone specific array.
The arrangement of counters in an array also simplifies processing when output has to be generated for /proc/*.
Counters can be updated by calling inc/dec_zone_page_state or _inc/dec_zone_page_state analogous to *_page_state. The second group of functions can be called if it is known that interrupts are disabled.
Special optimized increment and decrement functions are provided. These can avoid certain checks and use increment or decrement instructions that an architecture may provide.
We also add a new CONFIG_DMA_IS_NORMAL that signifies that an architecture can do DMA to all memory and therefore ZONE_NORMAL will not be populated. This is only currently set for IA64 SGI SN2 and currently only affects node_page_state(). In the best case node_page_state can be reduced to retrieving a single counter for the one zone on the node.
include/linux/mmzone.h +9 -0
@@ -46,6 +46,9 @@ struct zone_padding {#define ZONE_PADDING (name)#endif +enum zone_stat_item { +NR_VM_ZONE_STAT_ITEMS }; +struct per_cpu_pages {int count;/* number of pages in the list */ int high;/* high watermark, emptying needed */
@@ -55,6 +58,10 @@ struct per_cpu_pages {struct per_cpu_pageset {struct per_cpu_pages pcp[2 ];/* 0: hot. 1: cold */ +#ifdef CONFIG_SMP +s8 vm_stat_diff[NR_VM_ZONE_STAT_ITEMS ]; +#endif +#ifdef CONFIG_NUMA unsigned long numa_hit;/* allocated in intended node */ unsigned long numa_miss;/* allocated in non intended node */
@@ -170,6 +177,8 @@ struct zone {/* A count of how many reclaimers are scanning this zone */ atomic_t reclaim_in_progress; +/* Zone statistics */ +atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS ];/* * timestamp (in jiffies) of the last zone reclaim that did not * result in freeing of pages. This is used to avoid repeated scans
mm/page_alloc.c +2 -0
@@ -2143,6 +2143,7 @@ static void __meminit free_area_init_cor zone->nr_scan_inactive =0 ; zone->nr_active =0 ; zone->nr_inactive =0 ; +zap_zone_vm_stats (zone);atomic_set (&zone->reclaim_in_progress,0 );if (!size)continue ;
@@ -2254,6 +2255,7 @@ static int page_alloc_cpu_notify(struct }local_irq_enable (); +refresh_cpu_vm_stats (cpu); }return NOTIFY_OK ; }
mm/slab.c +1 -0
@@ -3826,6 +3826,7 @@ next:check_irq_on ();mutex_unlock (&cache_chain_mutex);next_reap_node (); +refresh_cpu_vm_stats (smp_processor_id ());/* Set up the next iteration */ schedule_delayed_work (&__get_cpu_var (reap_work),REAPTIMEOUT_CPUC ); }
include/linux/vmstat.h +82 -0
93 lines not on this page · raw message
arch/ia64/Kconfig +5 -0
@@ -70,6 +70,11 @@ config DMA_IS_DMA32 bool default y +config DMA_IS_NORMAL + bool + depends on IA64_SGI_SN2 + default y + choice prompt "System type" default IA64_GENERIC
mm/vmstat.c +276 -4
323 lines not on this page · raw message
PATCH 3/21 Convert nr_mapped to per zone counter
In reply to Christoph LameterSubject: zoned vm counters: conversion of nr_mapped to per zone counter
From: Christoph Lameter <[email protected]>
nr_mapped is important because it allows a determination of how many pages of a zone are not mapped, which would allow a more efficient means of determining when we need to reclaim memory in a zone.
We take the nr_mapped field out of the page state structure and define a new per zone counter named NR_MAPPED.
We replace the use of nr_mapped in various kernel locations. This avoids the looping over all processors in try_to_free_pages(), writeback, reclaim (swap + zone reclaim).
arch/i386/mm/pgtable.c +1 -1
@@ -61,7 +61,7 @@ void show_mem(void)get_page_state (&ps);printk (KERN_INFO "%lu pages dirty\n" , ps.nr_dirty);printk (KERN_INFO "%lu pages writeback\n" , ps.nr_writeback); -printk (KERN_INFO "%lu pages mapped\n" , ps.nr_mapped); +printk (KERN_INFO "%lu pages mapped\n" ,global_page_state (NR_MAPPED ));printk (KERN_INFO "%lu pages slab\n" , ps.nr_slab);printk (KERN_INFO "%lu pages pagetables\n" , ps.nr_page_table_pages); }
drivers/base/node.c +1 -3
@@ -54,8 +54,6 @@ static ssize_t node_read_meminfo(struct ps.nr_dirty =0 ;if ((long )ps.nr_writeback <0 ) ps.nr_writeback =0 ; -if ((long )ps.nr_mapped <0 ) - ps.nr_mapped =0 ;if ((long )ps.nr_slab <0 ) ps.nr_slab =0 ;
@@ -84,7 +82,7 @@ static ssize_t node_read_meminfo(struct nid,K (i.freeram - i.freehigh), nid,K (ps.nr_dirty), nid,K (ps.nr_writeback), - nid,K (ps.nr_mapped), + nid,K (node_page_state (nid,NR_MAPPED )), nid, K(ps.nr_slab)); n +=hugetlb_report_node_meminfo (nid, buf + n);return n;
fs/proc/proc_misc.c +1 -1
@@ -190,7 +190,7 @@ static int meminfo_read_proc(char *page,K (i.freeswap),K (ps.nr_dirty),K (ps.nr_writeback), -K (ps.nr_mapped), +K (global_page_state (NR_MAPPED )),K (ps.nr_slab),K (allowed), K(committed),
include/linux/mmzone.h +3 -0
@@ -47,6 +47,9 @@ struct zone_padding {#endif enum zone_stat_item { +NR_MAPPED ,/* mapped into pagetables. +only modified from process context */ +NR_VM_ZONE_STAT_ITEMS };struct per_cpu_pages {
mm/page_alloc.c +1 -1
@@ -1409,7 +1409,7 @@ void show_free_areas(void) ps.nr_unstable,nr_free_pages (), ps.nr_slab, - ps.nr_mapped, +global_page_state (NR_MAPPED ), ps.nr_page_table_pages);for_each_zone (zone) {
mm/page-writeback.c +1 -1
@@ -111,7 +111,7 @@ static void get_writeback_state(struct w { wbs->nr_dirty =read_page_state (nr_dirty); wbs->nr_unstable =read_page_state (nr_unstable); - wbs->nr_mapped =read_page_state (nr_mapped); + wbs->nr_mapped =global_page_state (NR_MAPPED ); wbs->nr_writeback =read_page_state (nr_writeback); }
mm/rmap.c +3 -3
@@ -455,7 +455,7 @@ static void __page_set_anon_rmap(struct* nr_mapped state can be updated without turning off * interrupts because it is not modified via interrupt. */ -__inc_page_state (nr_mapped); +__inc_zone_page_state (page,NR_MAPPED ); }/**
@@ -499,7 +499,7 @@ void page_add_new_anon_rmap(struct pagevoid page_add_file_rmap (struct page *page) {if (atomic_inc_and_test (&page->_mapcount)) -__inc_page_state (nr_mapped); +__inc_zone_page_state (page,NR_MAPPED ); }/**
@@ -531,7 +531,7 @@ void page_remove_rmap(struct page *page)*/ if (page_test_and_clear_dirty (page))set_page_dirty (page); -__dec_page_state (nr_mapped); +__dec_zone_page_state (page,NR_MAPPED ); } }
mm/vmscan.c +4 -4
@@ -996,7 +996,7 @@ unsigned long try_to_free_pages(struct z }for (priority =DEF_PRIORITY ; priority >=0 ; priority--) { - sc.nr_mapped =read_page_state (nr_mapped); + sc.nr_mapped =global_page_state (NR_MAPPED ); sc.nr_scanned =0 ;if (!priority)disable_swap_token ();
@@ -1081,7 +1081,7 @@ loop_again: total_scanned =0 ; nr_reclaimed =0 ; sc.may_writepage = !laptop_mode; - sc.nr_mapped =read_page_state (nr_mapped); + sc.nr_mapped =global_page_state (NR_MAPPED );inc_page_state (pageoutrun);
@@ -1416,7 +1416,7 @@ unsigned long shrink_all_memory(unsignedfor (prio =DEF_PRIORITY ; prio >=0 ; prio--) {unsigned long nr_to_scan = nr_pages - ret; - sc.nr_mapped =read_page_state (nr_mapped); + sc.nr_mapped =global_page_state (NR_MAPPED ); sc.nr_scanned =0 ; ret +=shrink_all_zones (nr_to_scan, prio, pass, &sc);
@@ -1558,7 +1558,7 @@ static int __zone_reclaim(struct zone *zstruct scan_control sc = { .may_writepage = !!(zone_reclaim_mode &RECLAIM_WRITE ), .may_swap = !!(zone_reclaim_mode &RECLAIM_SWAP ), - .nr_mapped =read_page_state (nr_mapped), + .nr_mapped =global_page_state (NR_MAPPED ), .swap_cluster_max = max_t(unsigned long, nr_pages,SWAP_CLUSTER_MAX ), .gfp_mask = gfp_mask,
mm/vmstat.c +1 -1
@@ -463,13 +463,13 @@ struct seq_operations fragmentation_op =static char *vmstat_text[] = {/* Zoned VM counters */ +"nr_mapped" ,/* Page state */ "nr_dirty" ,"nr_writeback" ,"nr_unstable" ,"nr_page_table_pages" , -"nr_mapped" ,"nr_slab" ,"pgpgin" ,
PATCH 4/21 swap_prefetch: Convert nr_mapped to ZVC
In reply to Christoph Lameterswap_prefetch: nr_mapped conversion
This is separate on request by Andrew.
mm/swap_prefetch.c +2 -1
@@ -394,7 +394,8 @@ static int prefetch_suitable(void)* even if the slab is being allocated on a remote node. This * would be expensive to fix and not of great significance. */ - limit = ps.nr_mapped + ps.nr_slab + ps.nr_dirty + + limit =node_page_state (node,NR_MAPPED ) + + ps.nr_slab + ps.nr_dirty + ps.nr_unstable + total_swapcache_pages;if (limit > ns->prefetch_watermark) {node_clear (node, sp_stat.prefetch_nodes);
PATCH 5/21 Conversion of nr_pagecache to per zone counter
In reply to Christoph LameterSubject: zoned vm counters: conversion of nr_pagecache to per zone counter
From: Christoph Lameter <[email protected]>
Currently a single atomic variable is used to establish the size of the page cache in the whole machine. The zoned VM counters have the same method of implementation as the nr_pagecache code but also allow the determination of the pagecache size per zone.
Remove the special implementation for nr_pagecache and make it a zoned counter.
Updates of the page cache counters are always performed with interrupts off. We can therefore use the __ variant here.
arch/sparc64/kernel/sys_sunos32.c +1 -1
@@ -155,7 +155,7 @@ asmlinkage int sunos_brk(u32 baddr)* simple, it hopefully works in most obvious cases.. Easy to * fool it, but this should catch most mistakes. */ - freepages =get_page_cache_size (); + freepages =global_page_state (NR_PAGECACHE ); freepages >>=1 ; freepages +=nr_free_pages (); freepages += nr_swap_pages;
arch/sparc/kernel/sys_sunos.c +1 -1
@@ -196,7 +196,7 @@ asmlinkage int sunos_brk(unsigned long b* simple, it hopefully works in most obvious cases.. Easy to * fool it, but this should catch most mistakes. */ - freepages =get_page_cache_size (); + freepages =global_page_state (NR_PAGECACHE ); freepages >>=1 ; freepages +=nr_free_pages (); freepages += nr_swap_pages;
fs/proc/proc_misc.c +2 -1
@@ -142,7 +142,8 @@ static int meminfo_read_proc(char *page, allowed = ((totalram_pages -hugetlb_total_pages ()) * sysctl_overcommit_ratio /100 ) + total_swap_pages; - cached =get_page_cache_size () - total_swapcache_pages - i.bufferram; + cached =global_page_state (NR_PAGECACHE ) - + total_swapcache_pages - i.bufferram;if (cached <0 ) cached =0 ;
include/linux/pagemap.h +0 -45
51 lines not on this page · raw message
mm/filemap.c +2 -2
@@ -126,7 +126,7 @@ void __remove_from_page_cache(struct pagradix_tree_delete (&mapping->page_tree, page->index); page->mapping =NULL ; mapping->nrpages--; -pagecache_acct (-1 ); +__dec_zone_page_state (page,NR_PAGECACHE ); }EXPORT_SYMBOL (__remove_from_page_cache);
@@ -424,7 +424,7 @@ int add_to_page_cache(struct page *page, page->mapping = mapping; page->index = offset; mapping->nrpages++; -pagecache_acct (1 ); +__inc_zone_page_state (page,NR_PAGECACHE ); }write_unlock_irq (&mapping->tree_lock);radix_tree_preload_end ();
mm/mmap.c +1 -1
@@ -96,7 +96,7 @@ int __vm_enough_memory(long pages, int cif (sysctl_overcommit_memory ==OVERCOMMIT_GUESS ) {unsigned long n; - free =get_page_cache_size (); + free =global_page_state (NR_PAGECACHE ); free += nr_swap_pages;/*
mm/nommu.c +1 -1
@@ -1122,7 +1122,7 @@ int __vm_enough_memory(long pages, int cif (sysctl_overcommit_memory ==OVERCOMMIT_GUESS ) {unsigned long n; - free =get_page_cache_size (); + free =global_page_state (NR_PAGECACHE ); free += nr_swap_pages;/*
mm/page_alloc.c +0 -5
@@ -2231,16 +2231,11 @@ static int page_alloc_cpu_notify(struct unsigned long action, void *hcpu) { int cpu = (unsigned long)hcpu; -long *count;unsigned long *src, *dest;if (action ==CPU_DEAD ) {int i; -/* Drain local pagecache count. */ - count = &per_cpu (nr_pagecache_local, cpu); -atomic_add (*count, &nr_pagecache); - *count =0 ;local_irq_disable ();__drain_pages (cpu);
mm/swap_state.c +2 -2
@@ -89,7 +89,7 @@ static int __add_to_swap_cache(struct paSetPageSwapCache (page);set_page_private (page, entry.val); total_swapcache_pages++; -pagecache_acct (1 ); +__inc_zone_page_state (page,NR_PAGECACHE ); }write_unlock_irq (&swapper_space.tree_lock);radix_tree_preload_end ();
@@ -135,7 +135,7 @@ void __delete_from_swap_cache(struct pagset_page_private (page,0 );ClearPageSwapCache (page); total_swapcache_pages--; -pagecache_acct (-1 ); +__dec_zone_page_state (page,NR_PAGECACHE );INC_CACHE_INFO (del_total); }
include/linux/mmzone.h +1 -1
@@ -49,7 +49,7 @@ struct zone_padding {enum zone_stat_item {NR_MAPPED ,/* mapped into pagetables. only modified from process context */ - +NR_PAGECACHE ,NR_VM_ZONE_STAT_ITEMS };struct per_cpu_pages {
arch/s390/appldata/appldata_mem.c +2 -1
@@ -130,7 +130,8 @@ static void appldata_get_mem_data(void * mem_data->totalhigh =P2K (val.totalhigh); mem_data->freehigh =P2K (val.freehigh); mem_data->bufferram =P2K (val.bufferram); - mem_data->cached =P2K (atomic_read (&nr_pagecache) - val.bufferram); + mem_data->cached =P2K (global_page_state (NR_PAGECACHE ) + - val.bufferram);si_swapinfo (&val); mem_data->totalswap =P2K (val.totalswap);
drivers/base/node.c +2 -0
@@ -69,6 +69,7 @@ static ssize_t node_read_meminfo(struct"Node %d LowFree: %8lu kB\n" "Node %d Dirty: %8lu kB\n" "Node %d Writeback: %8lu kB\n" +"Node %d PageCache: %8lu kB\n" "Node %d Mapped: %8lu kB\n" "Node %d Slab: %8lu kB\n" , nid, K(i.totalram),
@@ -82,6 +83,7 @@ static ssize_t node_read_meminfo(struct nid,K (i.freeram - i.freehigh), nid,K (ps.nr_dirty), nid,K (ps.nr_writeback), + nid,K (node_page_state (nid,NR_PAGECACHE )), nid,K (node_page_state (nid,NR_MAPPED )), nid, K(ps.nr_slab)); n +=hugetlb_report_node_meminfo (nid, buf + n);
mm/vmstat.c +1 -6
@@ -20,12 +20,6 @@*/ static DEFINE_PER_CPU(struct page_state, page_states) = {0}; -atomic_t nr_pagecache =ATOMIC_INIT (0 ); -EXPORT_SYMBOL (nr_pagecache); -#ifdef CONFIG_SMP -DEFINE_PER_CPU (long, nr_pagecache_local) =0 ; -#endif -static void __get_page_state (struct page_state *ret,int nr,cpumask_t *cpumask) {unsigned cpu;
@@ -464,6 +458,7 @@ struct seq_operations fragmentation_op =static char *vmstat_text[] = {/* Zoned VM counters */ "nr_mapped" , +"nr_pagecache" ,/* Page state */ "nr_dirty" ,
PATCH 6/21 Remove nr_mapped from scan controls structure
In reply to Christoph LameterSubject: zoned VM stats: Remove nr_mapped from scan control
From: Christoph Lameter <[email protected]>
We can now access the number of pages in a mapped state in an inexpensive way in shrink_active_list. So drop the nr_mapped field from scan_control.
mm/vmscan.c +2 -8
@@ -48,8 +48,6 @@ struct scan_control {/* Incremented by the number of inactive pages that were scanned */ unsigned long nr_scanned; -unsigned long nr_mapped;/* From page_state */ -/* This context's GFP mask */ gfp_t gfp_mask;
@@ -749,7 +747,8 @@ static void shrink_active_list(unsigned* how much memory * is mapped. */ - mapped_ratio = (sc->nr_mapped *100 ) / vm_total_pages; + mapped_ratio = (global_page_state (NR_MAPPED ) *100 ) / + vm_total_pages;/* * Now decide how much we really want to unmap some pages. The
@@ -996,7 +995,6 @@ unsigned long try_to_free_pages(struct z }for (priority =DEF_PRIORITY ; priority >=0 ; priority--) { - sc.nr_mapped =global_page_state (NR_MAPPED ); sc.nr_scanned =0 ;if (!priority)disable_swap_token ();
@@ -1081,8 +1079,6 @@ loop_again: total_scanned =0 ; nr_reclaimed =0 ; sc.may_writepage = !laptop_mode; - sc.nr_mapped =global_page_state (NR_MAPPED ); -inc_page_state (pageoutrun);for (i =0 ; i < pgdat->nr_zones; i++) {
@@ -1416,7 +1412,6 @@ unsigned long shrink_all_memory(unsignedfor (prio =DEF_PRIORITY ; prio >=0 ; prio--) {unsigned long nr_to_scan = nr_pages - ret; - sc.nr_mapped =global_page_state (NR_MAPPED ); sc.nr_scanned =0 ; ret +=shrink_all_zones (nr_to_scan, prio, pass, &sc);
@@ -1558,7 +1553,6 @@ static int __zone_reclaim(struct zone *zstruct scan_control sc = { .may_writepage = !!(zone_reclaim_mode &RECLAIM_WRITE ), .may_swap = !!(zone_reclaim_mode &RECLAIM_SWAP ), - .nr_mapped =global_page_state (NR_MAPPED ), .swap_cluster_max = max_t(unsigned long, nr_pages,SWAP_CLUSTER_MAX ), .gfp_mask = gfp_mask,
PATCH 7/21 Split NR_ANON off from NR_MAPPED
In reply to Christoph LameterSubject: zoned VM stats: Add NR_ANON
From: Christoph Lameter <[email protected]>
The current NR_MAPPED is used by zone reclaim and the dirty load calculation as the number of mapped pagecache pages. However, that is not true. NR_MAPPED includes the mapped anonymous pages. This patch separates those and therefore allows an accurate tracking of the anonymous pages per zone.
It then becomes possible to determine the number of unmapped pages per zone and we can avoid scanning for unmapped pages if there are none.
Also it may now be possible to determine the mapped/unmapped ratio in get_dirty_limit. Isnt the number of anonymous pages irrelevant in that calculation?
Note that this will change the meaning of the number of mapped pages reported in /proc/vmstat /proc/meminfo and in the per node statistics. This may affect user space tools that monitor these counters! NR_MAPPED works like NR_DIRTY. It is only valid for pagecache pages.
fs/proc/proc_misc.c +2 -0
@@ -168,6 +168,7 @@ static int meminfo_read_proc(char *page,"SwapFree: %8lu kB\n" "Dirty: %8lu kB\n" "Writeback: %8lu kB\n" +"Anonymous: %8lu kB\n" "Mapped: %8lu kB\n" "Slab: %8lu kB\n" "CommitLimit: %8lu kB\n"
@@ -191,6 +192,7 @@ static int meminfo_read_proc(char *page,K (i.freeswap),K (ps.nr_dirty),K (ps.nr_writeback), +K (global_page_state (NR_ANON )),K (global_page_state (NR_MAPPED )),K (ps.nr_slab), K(allowed),
include/linux/mmzone.h +2 -1
@@ -47,7 +47,8 @@ struct zone_padding {#endif enum zone_stat_item { -NR_MAPPED ,/* mapped into pagetables. +NR_ANON ,/* Mapped anonymous pages */ +NR_MAPPED ,/* pagecache pages mapped into pagetables. only modified from process context */ NR_PAGECACHE ,NR_VM_ZONE_STAT_ITEMS };
mm/rmap.c +3 -2
@@ -455,7 +455,7 @@ static void __page_set_anon_rmap(struct* nr_mapped state can be updated without turning off * interrupts because it is not modified via interrupt. */ -__inc_zone_page_state (page,NR_MAPPED ); +__inc_zone_page_state (page,NR_ANON ); }/**
@@ -531,7 +531,8 @@ void page_remove_rmap(struct page *page)*/ if (page_test_and_clear_dirty (page))set_page_dirty (page); -__dec_zone_page_state (page,NR_MAPPED ); +__dec_zone_page_state (page, +PageAnon (page) ?NR_ANON :NR_MAPPED ); } }
mm/vmscan.c +2 -1
@@ -747,7 +747,8 @@ static void shrink_active_list(unsigned* how much memory * is mapped. */ - mapped_ratio = (global_page_state (NR_MAPPED ) *100 ) / + mapped_ratio = ((global_page_state (NR_MAPPED ) + +global_page_state (NR_ANON )) *100 ) / vm_total_pages;/*
drivers/base/node.c +2 -0
@@ -71,6 +71,7 @@ static ssize_t node_read_meminfo(struct"Node %d Writeback: %8lu kB\n" "Node %d PageCache: %8lu kB\n" "Node %d Mapped: %8lu kB\n" +"Node %d Anonymous: %8lu kB\n" "Node %d Slab: %8lu kB\n" , nid,K (i.totalram), nid, K(i.freeram),
@@ -85,6 +86,7 @@ static ssize_t node_read_meminfo(struct nid,K (ps.nr_writeback), nid,K (node_page_state (nid,NR_PAGECACHE )), nid,K (node_page_state (nid,NR_MAPPED )), + nid,K (node_page_state (nid,NR_ANON )), nid, K(ps.nr_slab)); n +=hugetlb_report_node_meminfo (nid, buf + n);return n;
mm/page-writeback.c +2 -1
@@ -111,7 +111,8 @@ static void get_writeback_state(struct w { wbs->nr_dirty =read_page_state (nr_dirty); wbs->nr_unstable =read_page_state (nr_unstable); - wbs->nr_mapped =global_page_state (NR_MAPPED ); + wbs->nr_mapped =global_page_state (NR_MAPPED ) + +global_page_state (NR_ANON ); wbs->nr_writeback =read_page_state (nr_writeback); }
mm/vmstat.c +1 -0
@@ -457,6 +457,7 @@ struct seq_operations fragmentation_op =static char *vmstat_text[] = {/* Zoned VM counters */ +"nr_anon" ,"nr_mapped" ,"nr_pagecache" ,
PATCH 8/21 swap_prefetch: Split NR_ANON off NR_MAPPED
In reply to Christoph Lameterswap_prefetch: add NR_ANON
Separated out by request from Andrew.
mm/swap_prefetch.c +1 -0
@@ -395,6 +395,7 @@ static int prefetch_suitable(void)* would be expensive to fix and not of great significance. */ limit =node_page_state (node,NR_MAPPED ) + +node_page_state (node,NR_ANON ) + ps.nr_slab + ps.nr_dirty + ps.nr_unstable + total_swapcache_pages;if (limit > ns->prefetch_watermark) {
PATCH 9/21 zone_reclaim: remove /proc/sys/vm/zone_reclaim_interval
In reply to Christoph LameterSubject: zoned vm counters: use per zone counters to remove zone_reclaim_interval
From: Christoph Lameter <[email protected]>
The zone_reclaim_interval was necessary because we were not able to determine how many unmapped pages exist in a zone. Therefore we had to scan in intervals to figure out if any pages were unmapped.
With the zoned counters and NR_ANON we now know the number of pagecache pages and the number of mapped pages in a zone. So we can simply skip the reclaim if there is an insufficient number of unmapped pages. We use SWAP_CLUSTER_MAX as the boundary.
Drop all support for /proc/sys/vm/zone_reclaim_interval.
include/linux/mmzone.h +0 -6
@@ -183,12 +183,6 @@ struct zone {/* Zone statistics */ atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS ]; -/* -* timestamp (in jiffies) of the last zone reclaim that did not -* result in freeing of pages. This is used to avoid repeated scans -* if all memory in the zone is in use. -*/ -unsigned long last_unsuccessful_zone_reclaim;/* * prev_priority holds the scanning priority for this zone. It is
include/linux/swap.h +0 -1
@@ -190,7 +190,6 @@ extern long vm_total_pages;#ifdef CONFIG_NUMA extern int zone_reclaim_mode; -extern int zone_reclaim_interval;extern int zone_reclaim (struct zone *,gfp_t ,unsigned int );#else #define zone_reclaim_mode 0
include/linux/sysctl.h +0 -1
@@ -191,7 +191,6 @@ enumVM_DROP_PAGECACHE =29 ,/* int: nuke lots of pagecache */ VM_PERCPU_PAGELIST_FRACTION =30 ,/* int: fraction of pages in each percpu_pagelist */ VM_ZONE_RECLAIM_MODE =31 ,/* reclaim local zone memory before going off node */ -VM_ZONE_RECLAIM_INTERVAL =32 ,/* time period to wait after reclaim failure */ VM_PANIC_ON_OOM =33 ,/* panic at out-of-memory */ VM_VDSO_ENABLED =34 ,/* map VDSO into new processes? */ VM_SWAP_PREFETCH=35, /* swap prefetch */
kernel/sysctl.c +0 -9
@@ -1015,15 +1015,6 @@ static ctl_table vm_table[] = { .strategy = &sysctl_intvec, .extra1 = &zero, }, - { - .ctl_name = VM_ZONE_RECLAIM_INTERVAL, - .procname = "zone_reclaim_interval", - .data = &zone_reclaim_interval, - .maxlen = sizeof(zone_reclaim_interval), - .mode = 0644, - .proc_handler = &proc_dointvec_jiffies, - .strategy = &sysctl_jiffies, - },#endif #ifdef CONFIG_X86_32 {
mm/vmscan.c +10 -21
@@ -1529,11 +1529,6 @@ int zone_reclaim_mode __read_mostly;#define RECLAIM_SLAB (1<<3)/* Do a global slab shrink if the zone is out of memory */ /* -* Mininum time between zone reclaim scans -*/ -int zone_reclaim_interval__read_mostly =30 *HZ ; - -/* * Priority for ZONE_RECLAIM. This determines the fraction of pages * of a node considered for each zone_reclaim. 4 scans 1/16th of * a zone.
@@ -1598,16 +1593,6 @@ static int __zone_reclaim(struct zone *z p->reclaim_state =NULL ; current->flags &= ~(PF_MEMALLOC |PF_SWAPWRITE ); - -if (nr_reclaimed ==0 ) { -/* -* We were unable to reclaim enough pages to stay on node. We -* now allow off node accesses for a certain time period before -* trying again to reclaim pages from the local zone. -*/ - zone->last_unsuccessful_zone_reclaim = jiffies; - } -return nr_reclaimed >= nr_pages; }
@@ -1617,13 +1602,17 @@ int zone_reclaim(struct zone *zone, gfp_int node_id;/* -* Do not reclaim if there was a recent unsuccessful attempt at zone -* reclaim. In that case we let allocations go off node for the -* zone_reclaim_interval. Otherwise we would scan for each off-node -* page allocation. +* Do not reclaim if there are not enough reclaimable pages in this +* zone that would satify this allocations. +* +* All unmapped pagecache pages are reclaimable. +* +* Both counters may be temporarily off a bit so we use +* SWAP_CLUSTER_MAX as the boundary. It may also be good to +* leave a few frequently used unmapped pagecache pages around. */ -if (time_before (jiffies, - zone->last_unsuccessful_zone_reclaim + zone_reclaim_interval)) +if (zone_page_state (zone,NR_PAGECACHE ) - +zone_page_state (zone,NR_MAPPED ) <SWAP_CLUSTER_MAX )return 0 ;/*
Documentation/sysctl/vm.txt +0 -13
@@ -28,7 +28,6 @@ Currently, these files are in /proc/sys/ - block_dump - drop-caches - zone_reclaim_mode -- zone_reclaim_interval - panic_on_oom - swap_prefetch - readahead_ratio
@@ -172,18 +171,6 @@ in all nodes of the system. ================================================================ -zone_reclaim_interval: - -The time allowed for off node allocations after zone reclaim -has failed to reclaim enough pages to allow a local allocation. - -Time is set in seconds and set by default to 30 seconds. - -Reduce the interval if undesired off node allocations occur. However, too -frequent scans will have a negative impact onoff node allocation performance. - -============================================================= - panic_on_oom This enables or disables panic on out-of-memory feature. If this is set to 1,
PATCH 10/21 Conversion of nr_slab to per zone counter
In reply to Christoph LameterSubject: zoned vm counters: conversion of nr_slab to per zone counter
From: Christoph Lameter <[email protected]>
- Allows reclaim to access counter without looping over processor counts.
- Allows accurate statistics on how many pages are used in a zone by the slab. This may become useful to balance slab allocations over various zones.
arch/i386/mm/pgtable.c +1 -1
@@ -62,7 +62,7 @@ void show_mem(void)printk (KERN_INFO "%lu pages dirty\n" , ps.nr_dirty);printk (KERN_INFO "%lu pages writeback\n" , ps.nr_writeback);printk (KERN_INFO "%lu pages mapped\n" ,global_page_state (NR_MAPPED )); -printk (KERN_INFO "%lu pages slab\n" , ps.nr_slab); +printk (KERN_INFO "%lu pages slab\n" ,global_page_state (NR_SLAB ));printk (KERN_INFO "%lu pages pagetables\n" , ps.nr_page_table_pages); }
drivers/base/node.c +1 -3
@@ -54,8 +54,6 @@ static ssize_t node_read_meminfo(struct ps.nr_dirty =0 ;if ((long )ps.nr_writeback <0 ) ps.nr_writeback =0 ; -if ((long )ps.nr_slab <0 ) - ps.nr_slab =0 ; n =sprintf (buf,"\n" "Node %d MemTotal: %8lu kB\n"
@@ -87,7 +85,7 @@ static ssize_t node_read_meminfo(struct nid,K (node_page_state (nid,NR_PAGECACHE )), nid,K (node_page_state (nid,NR_MAPPED )), nid,K (node_page_state (nid,NR_ANON )), - nid, K(ps.nr_slab)); + nid, K(node_page_state(nid, NR_SLAB))); n +=hugetlb_report_node_meminfo (nid, buf + n);return n; }
fs/proc/proc_misc.c +1 -1
@@ -194,7 +194,7 @@ static int meminfo_read_proc(char *page,K (ps.nr_writeback),K (global_page_state (NR_ANON )),K (global_page_state (NR_MAPPED )), -K (ps.nr_slab), +K (global_page_state (NR_SLAB )),K (allowed),K (committed), K(ps.nr_page_table_pages),
include/linux/mmzone.h +1 -0
@@ -51,6 +51,7 @@ enum zone_stat_item {NR_MAPPED ,/* pagecache pages mapped into pagetables. only modified from process context */ NR_PAGECACHE , +NR_SLAB ,/* Pages used by slab allocator */ NR_VM_ZONE_STAT_ITEMS }; struct per_cpu_pages {
mm/page_alloc.c +1 -1
@@ -1408,7 +1408,7 @@ void show_free_areas(void) ps.nr_writeback, ps.nr_unstable,nr_free_pages (), - ps.nr_slab, +global_page_state (NR_SLAB ),global_page_state (NR_MAPPED ), ps.nr_page_table_pages);
mm/slab.c +2 -2
@@ -1525,7 +1525,7 @@ static void *kmem_getpages(struct kmem_c nr_pages = (1 << cachep->gfporder);if (cachep->flags &SLAB_RECLAIM_ACCOUNT )atomic_add (nr_pages, &slab_reclaim_pages); -add_page_state (nr_slab, nr_pages); +add_zone_page_state (page_zone (page),NR_SLAB , nr_pages);for (i =0 ; i < nr_pages; i++)__SetPageSlab (page + i);return page_address (page);
@@ -1545,7 +1545,7 @@ static void kmem_freepages(struct kmem_c__ClearPageSlab (page); page++; } -sub_page_state (nr_slab, nr_freed); +sub_zone_page_state (page_zone (page),NR_SLAB , nr_freed);if (current->reclaim_state) current->reclaim_state->reclaimed_slab += nr_freed;free_pages ((unsigned long )addr, cachep->gfporder);
mm/vmscan.c +1 -1
@@ -1371,7 +1371,7 @@ unsigned long shrink_all_memory(unsignedfor_each_zone (zone) lru_pages += zone->nr_active + zone->nr_inactive; - nr_slab =read_page_state (nr_slab); + nr_slab =global_page_state (NR_SLAB );/* If slab caches are huge, it's better to hit them first */ while (nr_slab >= lru_pages) { reclaim_state.reclaimed_slab =0 ;
mm/vmstat.c +1 -1
@@ -460,13 +460,13 @@ static char *vmstat_text[] = {"nr_anon" ,"nr_mapped" ,"nr_pagecache" , +"nr_slab" ,/* Page state */ "nr_dirty" ,"nr_writeback" ,"nr_unstable" ,"nr_page_table_pages" , -"nr_slab" ,"pgpgin" , "pgpgout",
PATCH 11/21 swap_prefetch: Conversion of nr_slab to ZVC
In reply to Christoph Lameterswap_prefetch: Use NR_SLAB
This removes a potential problem for swap_prefetch. Use NR_SLAB and remove the comment stating the problem.
mm/swap_prefetch.c +2 -5
@@ -389,14 +389,11 @@ static int prefetch_suitable(void)/* * >2/3 of the ram on this node is mapped, slab, swapcache or * dirty, we need to leave some free for pagecache. -* Note that currently nr_slab is innacurate on numa because -* nr_slab is incremented on the node doing the accounting -* even if the slab is being allocated on a remote node. This -* would be expensive to fix and not of great significance. */ limit =node_page_state (node,NR_MAPPED ) +node_page_state (node,NR_ANON ) + - ps.nr_slab + ps.nr_dirty + +node_page_state (node,NR_SLAB ) + + ps.nr_dirty + ps.nr_unstable + total_swapcache_pages;if (limit > ns->prefetch_watermark) {node_clear (node, sp_stat.prefetch_nodes);
PATCH 12/21 Conversion of nr_pagetables to per zone counter
In reply to Christoph LameterSubject: zoned vm counters: conversion of nr_pagetable to per zone counter
From: Christoph Lameter <[email protected]>
Conversion of nr_page_table_pages to a per zone counter
arch/i386/mm/pgtable.c +2 -1
@@ -63,7 +63,8 @@ void show_mem(void)printk (KERN_INFO "%lu pages writeback\n" , ps.nr_writeback);printk (KERN_INFO "%lu pages mapped\n" ,global_page_state (NR_MAPPED ));printk (KERN_INFO "%lu pages slab\n" ,global_page_state (NR_SLAB )); -printk (KERN_INFO "%lu pages pagetables\n" , ps.nr_page_table_pages); +printk (KERN_INFO "%lu pages pagetables\n" , +global_page_state (NR_PAGETABLE )); }/*
fs/proc/proc_misc.c +2 -2
@@ -171,9 +171,9 @@ static int meminfo_read_proc(char *page,"Anonymous: %8lu kB\n" "Mapped: %8lu kB\n" "Slab: %8lu kB\n" +"PageTables: %8lu kB\n" "CommitLimit: %8lu kB\n" "Committed_AS: %8lu kB\n" -"PageTables: %8lu kB\n" "VmallocTotal: %8lu kB\n" "VmallocUsed: %8lu kB\n" "VmallocChunk: %8lu kB\n",
@@ -195,9 +195,9 @@ static int meminfo_read_proc(char *page,K (global_page_state (NR_ANON )),K (global_page_state (NR_MAPPED )),K (global_page_state (NR_SLAB )), +K (global_page_state (NR_PAGETABLE )),K (allowed),K (committed), -K (ps.nr_page_table_pages), (unsigned long )VMALLOC_TOTAL >>10 , vmi.used >>10 , vmi.largest_chunk >>10
include/linux/mmzone.h +1 -0
@@ -52,6 +52,7 @@ enum zone_stat_item {only modified from process context */ NR_PAGECACHE ,NR_SLAB ,/* Pages used by slab allocator */ +NR_PAGETABLE ,/* used for pagetables */ NR_VM_ZONE_STAT_ITEMS }; struct per_cpu_pages {
mm/memory.c +2 -2
@@ -127,7 +127,7 @@ static void free_pte_range(struct mmu_gapmd_clear (pmd);pte_lock_deinit (page);pte_free_tlb (tlb, page); -dec_page_state (nr_page_table_pages); +dec_zone_page_state (page,NR_PAGETABLE ); tlb->mm->nr_ptes--; }
@@ -312,7 +312,7 @@ int __pte_alloc(struct mm_struct *mm, pmpte_free (new); }else { mm->nr_ptes++; -inc_page_state (nr_page_table_pages); +inc_zone_page_state (new,NR_PAGETABLE );pmd_populate (mm, pmd, new); }spin_unlock (&mm->page_table_lock);
mm/page_alloc.c +1 -1
@@ -1410,7 +1410,7 @@ void show_free_areas(void)nr_free_pages (),global_page_state (NR_SLAB ),global_page_state (NR_MAPPED ), - ps.nr_page_table_pages); + global_page_state(NR_PAGETABLE));for_each_zone (zone) {int i;
drivers/base/node.c +2 -0
@@ -70,6 +70,7 @@ static ssize_t node_read_meminfo(struct"Node %d PageCache: %8lu kB\n" "Node %d Mapped: %8lu kB\n" "Node %d Anonymous: %8lu kB\n" +"Node %d PageTables: %8lu kB\n" "Node %d Slab: %8lu kB\n" , nid,K (i.totalram), nid, K(i.freeram),
@@ -85,6 +86,7 @@ static ssize_t node_read_meminfo(struct nid,K (node_page_state (nid,NR_PAGECACHE )), nid,K (node_page_state (nid,NR_MAPPED )), nid,K (node_page_state (nid,NR_ANON )), + nid,K (node_page_state (nid,NR_PAGETABLE )), nid, K(node_page_state(nid, NR_SLAB))); n +=hugetlb_report_node_meminfo (nid, buf + n);return n;
arch/um/kernel/skas/mmu.c +1 -1
@@ -152,7 +152,7 @@ void destroy_context_skas(struct mm_strufree_page (mmu->id.stack);pte_lock_deinit (virt_to_page (mmu->last_page_table));pte_free_kernel ((pte_t *) mmu->last_page_table); -dec_page_state (nr_page_table_pages); +dec_zone_page_state (virt_to_page (mmu->last_page_table),NR_PAGETABLE );#ifdef CONFIG_3_LEVEL_PGTABLES pmd_free ((pmd_t *) mmu->last_pmd);#endif
arch/arm/mm/mm-armv.c +1 -1
@@ -227,7 +227,7 @@ void free_pgd_slow(pgd_t *pgd) pte =pmd_page (*pmd);pmd_clear (pmd); -dec_page_state (nr_page_table_pages); +dec_zone_page_state (virt_to_page ((unsigned long *)pgd),NR_PAGETABLE );pte_lock_deinit (pte);pte_free (pte);pmd_free (pmd);
mm/vmstat.c +1 -1
@@ -461,12 +461,12 @@ static char *vmstat_text[] = {"nr_mapped" ,"nr_pagecache" ,"nr_slab" , +"nr_page_table_pages" ,/* Page state */ "nr_dirty" ,"nr_writeback" ,"nr_unstable" , -"nr_page_table_pages" ,"pgpgin" , "pgpgout",
PATCH 13/21 Conversion of nr_dirty to per zone counter
In reply to Christoph LameterSubject: zoned vm counters: conversion of nr_dirty to per zone counter
From: Christoph Lameter <[email protected]>
This makes nr_dirty a per zone counter. Looping over all processors is avoided during writeback state determination.
The counter aggregation for nr_dirty had to be undone in the NFS layer since we summed up the page counts from multiple zones. Someone more familiar with NFS should probably review what I have done.
arch/i386/mm/pgtable.c +1 -1
@@ -59,7 +59,7 @@ void show_mem(void)printk (KERN_INFO "%d pages swap cached\n" , cached);get_page_state (&ps); -printk (KERN_INFO "%lu pages dirty\n" , ps.nr_dirty); +printk (KERN_INFO "%lu pages dirty\n" ,global_page_state (NR_DIRTY ));printk (KERN_INFO "%lu pages writeback\n" , ps.nr_writeback);printk (KERN_INFO "%lu pages mapped\n" ,global_page_state (NR_MAPPED ));printk (KERN_INFO "%lu pages slab\n" ,global_page_state (NR_SLAB ));
drivers/base/node.c +1 -3
@@ -50,8 +50,6 @@ static ssize_t node_read_meminfo(struct__get_zone_counts (&active, &inactive, &free,NODE_DATA (nid));/* Check for negative values in these approximate counters */ -if ((long )ps.nr_dirty <0 ) - ps.nr_dirty =0 ;if ((long )ps.nr_writeback <0 ) ps.nr_writeback =0 ;
@@ -81,7 +79,7 @@ static ssize_t node_read_meminfo(struct nid,K (i.freehigh), nid,K (i.totalram - i.totalhigh), nid,K (i.freeram - i.freehigh), - nid,K (ps.nr_dirty), + nid,K (node_page_state (nid,NR_DIRTY )), nid,K (ps.nr_writeback), nid,K (node_page_state (nid,NR_PAGECACHE )), nid, K(node_page_state(nid, NR_MAPPED)),
fs/buffer.c +1 -1
@@ -854,7 +854,7 @@ int __set_page_dirty_buffers(struct pagewrite_lock_irq (&mapping->tree_lock);if (page->mapping) {/* Race with truncate? */ if (mapping_cap_account_dirty (mapping)) -inc_page_state (nr_dirty); +__inc_zone_page_state (page,NR_DIRTY );radix_tree_tag_set (&mapping->page_tree,page_index (page),PAGECACHE_TAG_DIRTY );
fs/fs-writeback.c +1 -1
@@ -472,7 +472,7 @@ void sync_inodes_sb(struct super_block * .range_start = 0, .range_end = LLONG_MAX, }; -unsigned long nr_dirty =read_page_state (nr_dirty); +unsigned long nr_dirty =global_page_state (NR_DIRTY );unsigned long nr_unstable =read_page_state (nr_unstable); wbc.nr_to_write = nr_dirty + nr_unstable +
fs/nfs/pagelist.c +1 -0
@@ -315,6 +315,7 @@ nfs_scan_lock_dirty(struct nfs_inode *nf req->wb_index, NFS_PAGE_TAG_DIRTY);nfs_list_remove_request (req);nfs_list_add_request (req, dst); +dec_zone_page_state (req->wb_page,NR_DIRTY ); res++; } }
fs/nfs/write.c +1 -2
@@ -497,7 +497,7 @@ nfs_mark_request_dirty(struct nfs_page *nfs_list_add_request (req, &nfsi->dirty); nfsi->ndirty++;spin_unlock (&nfsi->req_lock); -inc_page_state (nr_dirty); +inc_zone_page_state (req->wb_page,NR_DIRTY );mark_inode_dirty (inode); }
@@ -598,7 +598,6 @@ nfs_scan_dirty(struct inode *inode, struif (nfsi->ndirty !=0 ) { res =nfs_scan_lock_dirty (nfsi, dst, idx_start, npages); nfsi->ndirty -= res; -sub_page_state (nr_dirty,res);if ((nfsi->ndirty ==0 ) !=list_empty (&nfsi->dirty))printk (KERN_ERR "NFS: desynchronized value of nfs_i.ndirty.\n" ); }
fs/proc/proc_misc.c +1 -1
@@ -190,7 +190,7 @@ static int meminfo_read_proc(char *page,K (i.freeram-i.freehigh),K (i.totalswap),K (i.freeswap), -K (ps.nr_dirty), +K (global_page_state (NR_DIRTY )),K (ps.nr_writeback),K (global_page_state (NR_ANON )), K(global_page_state(NR_MAPPED)),
include/linux/mmzone.h +1 -0
@@ -53,6 +53,7 @@ enum zone_stat_item {NR_PAGECACHE ,NR_SLAB ,/* Pages used by slab allocator */ NR_PAGETABLE ,/* used for pagetables */ +NR_DIRTY , NR_VM_ZONE_STAT_ITEMS }; struct per_cpu_pages {
mm/page_alloc.c +1 -1
@@ -1404,7 +1404,7 @@ void show_free_areas(void)"unstable:%lu free:%u slab:%lu mapped:%lu pagetables:%lu\n" , active, inactive, - ps.nr_dirty, +global_page_state (NR_DIRTY ), ps.nr_writeback, ps.nr_unstable, nr_free_pages(),
mm/page-writeback.c +5 -5
@@ -109,7 +109,7 @@ struct writeback_statestatic void get_writeback_state (struct writeback_state *wbs) { - wbs->nr_dirty =read_page_state (nr_dirty); + wbs->nr_dirty =global_page_state (NR_DIRTY ); wbs->nr_unstable =read_page_state (nr_unstable); wbs->nr_mapped =global_page_state (NR_MAPPED ) +global_page_state (NR_ANON );
@@ -641,7 +641,7 @@ int __set_page_dirty_nobuffers(struct paif (mapping2) {/* Race with truncate? */ BUG_ON (mapping2 != mapping);if (mapping_cap_account_dirty (mapping)) -inc_page_state (nr_dirty); +__inc_zone_page_state (page,NR_DIRTY );radix_tree_tag_set (&mapping->page_tree,page_index (page),PAGECACHE_TAG_DIRTY ); }
@@ -728,9 +728,9 @@ int test_clear_page_dirty(struct page *pradix_tree_tag_clear (&mapping->page_tree,page_index (page),PAGECACHE_TAG_DIRTY ); -write_unlock_irqrestore (&mapping->tree_lock, flags);if (mapping_cap_account_dirty (mapping)) -dec_page_state (nr_dirty); +__dec_zone_page_state (page,NR_DIRTY ); +write_unlock_irqrestore (&mapping->tree_lock, flags);return 1 ; }write_unlock_irqrestore (&mapping->tree_lock, flags);
@@ -761,7 +761,7 @@ int clear_page_dirty_for_io(struct pageif (mapping) {if (TestClearPageDirty (page)) {if (mapping_cap_account_dirty (mapping)) -dec_page_state (nr_dirty); +dec_zone_page_state (page,NR_DIRTY );return 1 ; }return 0 ;
mm/vmstat.c +1 -1
@@ -462,9 +462,9 @@ static char *vmstat_text[] = {"nr_pagecache" ,"nr_slab" ,"nr_page_table_pages" , +"nr_dirty" ,/* Page state */ -"nr_dirty" ,"nr_writeback" , "nr_unstable",
PATCH 14/21 swap_prefetch: Conversion of nr_dirty to ZVC
In reply to Christoph Lameterswap_prefetch: Convert nr_dirty to zone count
mm/swap_prefetch.c +1 -1
@@ -393,7 +393,7 @@ static int prefetch_suitable(void) limit =node_page_state (node,NR_MAPPED ) +node_page_state (node,NR_ANON ) +node_page_state (node,NR_SLAB ) + - ps.nr_dirty + +node_page_state (node,NR_DIRTY ) + ps.nr_unstable + total_swapcache_pages;if (limit > ns->prefetch_watermark) {node_clear (node, sp_stat.prefetch_nodes);
PATCH 15/21 reiser4: Conversiion of nr_dirty to ZVC
In reply to Christoph LameterSubject: reiser4: conversion of nr_dirty to per zone counter
From: Christoph Lameter <[email protected]>
Conversion of nr_dirty to a per zone counter
Requested by Andrew.
fs/reiser4/as_ops.c +1 -1
@@ -83,7 +83,7 @@ int reiser4_set_page_dirty(struct page *if (page->mapping) {assert ("vs-1652" , page->mapping == mapping);if (mapping_cap_account_dirty (mapping)) -inc_page_state (nr_dirty); +__inc_zone_page_state (page,NR_DIRTY );radix_tree_tag_set (&mapping->page_tree, page->index,PAGECACHE_TAG_REISER4_MOVED );
fs/reiser4/page_cache.c +1 -1
@@ -464,7 +464,7 @@ int set_page_dirty_internal(struct pageif (!TestSetPageDirty (page)) {if (mapping_cap_account_dirty (mapping)) -inc_page_state (nr_dirty); +inc_zone_page_state (page,NR_DIRTY );__mark_inode_dirty (mapping->host,I_DIRTY_PAGES ); }
PATCH 16/21 Conversion of nr_writeback to per zone counter
In reply to Christoph LameterSubject: zoned vm counters: conversion of nr_writeback to per zone counter
From: Christoph Lameter <[email protected]>
Conversion of nr_writeback to per zone counter.
This removes the last page_state counter from arch/i386/mm/pgtable.c so we drop the page_state from there.
arch/i386/mm/pgtable.c +2 -3
@@ -30,7 +30,6 @@ void show_mem(void)struct page *page;pg_data_t *pgdat;unsigned long i; -struct page_state ps;unsigned long flags;printk (KERN_INFO "Mem-info:\n" );
@@ -58,9 +57,9 @@ void show_mem(void)printk (KERN_INFO "%d pages shared\n" , shared);printk (KERN_INFO "%d pages swap cached\n" , cached); -get_page_state (&ps);printk (KERN_INFO "%lu pages dirty\n" ,global_page_state (NR_DIRTY )); -printk (KERN_INFO "%lu pages writeback\n" , ps.nr_writeback); +printk (KERN_INFO "%lu pages writeback\n" , +global_page_state (NR_WRITEBACK ));printk (KERN_INFO "%lu pages mapped\n" ,global_page_state (NR_MAPPED ));printk (KERN_INFO "%lu pages slab\n" ,global_page_state (NR_SLAB )); printk(KERN_INFO "%lu pages pagetables\n",
drivers/base/node.c +1 -4
@@ -49,9 +49,6 @@ static ssize_t node_read_meminfo(structget_page_state_node (&ps, nid);__get_zone_counts (&active, &inactive, &free,NODE_DATA (nid)); -/* Check for negative values in these approximate counters */ -if ((long )ps.nr_writeback <0 ) - ps.nr_writeback =0 ; n =sprintf (buf,"\n" "Node %d MemTotal: %8lu kB\n"
@@ -80,7 +77,7 @@ static ssize_t node_read_meminfo(struct nid,K (i.totalram - i.totalhigh), nid,K (i.freeram - i.freehigh), nid,K (node_page_state (nid,NR_DIRTY )), - nid,K (ps.nr_writeback), + nid,K (node_page_state (nid,NR_WRITEBACK )), nid,K (node_page_state (nid,NR_PAGECACHE )), nid,K (node_page_state (nid,NR_MAPPED )), nid, K(node_page_state(nid, NR_ANON)),
fs/proc/proc_misc.c +1 -1
@@ -191,7 +191,7 @@ static int meminfo_read_proc(char *page,K (i.totalswap),K (i.freeswap),K (global_page_state (NR_DIRTY )), -K (ps.nr_writeback), +K (global_page_state (NR_WRITEBACK )),K (global_page_state (NR_ANON )),K (global_page_state (NR_MAPPED )), K(global_page_state(NR_SLAB)),
include/linux/mmzone.h +1 -0
@@ -54,6 +54,7 @@ enum zone_stat_item {NR_SLAB ,/* Pages used by slab allocator */ NR_PAGETABLE ,/* used for pagetables */ NR_DIRTY , +NR_WRITEBACK , NR_VM_ZONE_STAT_ITEMS }; struct per_cpu_pages {
include/linux/page-flags.h +4 -4
@@ -176,7 +176,7 @@do { \if (!test_and_set_bit (PG_writeback, \ &(page)->flags)) \ -inc_page_state (nr_writeback); \ +inc_zone_page_state (page,NR_WRITEBACK ); \ } while (0)#define TestSetPageWriteback (page) \ ({ \
@@ -184,14 +184,14 @@ ret =test_and_set_bit (PG_writeback, \ &(page)->flags); \if (!ret) \ -inc_page_state (nr_writeback); \ +inc_zone_page_state (page,NR_WRITEBACK ); \ ret; \ })#define ClearPageWriteback (page) \ do { \ if (test_and_clear_bit(PG_writeback, \ &(page)->flags)) \ - dec_page_state(nr_writeback); \ + dec_zone_page_state(page, NR_WRITEBACK); \ } while (0)#define TestClearPageWriteback (page) \ ({ \
@@ -199,7 +199,7 @@ ret =test_and_clear_bit (PG_writeback, \ &(page)->flags); \if (ret) \ -dec_page_state (nr_writeback); \ +dec_zone_page_state (page,NR_WRITEBACK ); \ ret; \ })
mm/page_alloc.c +1 -1
@@ -1405,7 +1405,7 @@ void show_free_areas(void) active, inactive,global_page_state (NR_DIRTY ), - ps.nr_writeback, +global_page_state (NR_WRITEBACK ), ps.nr_unstable,nr_free_pages (), global_page_state(NR_SLAB),
mm/page-writeback.c +1 -1
@@ -113,7 +113,7 @@ static void get_writeback_state(struct w wbs->nr_unstable =read_page_state (nr_unstable); wbs->nr_mapped =global_page_state (NR_MAPPED ) +global_page_state (NR_ANON ); - wbs->nr_writeback =read_page_state (nr_writeback); + wbs->nr_writeback =global_page_state (NR_WRITEBACK ); }/*
mm/vmstat.c +1 -1
@@ -463,9 +463,9 @@ static char *vmstat_text[] = {"nr_slab" ,"nr_page_table_pages" ,"nr_dirty" , +"nr_writeback" ,/* Page state */ -"nr_writeback" ,"nr_unstable" , "pgpgin",
PATCH 17/21 swap_prefetch: Conversion of nr_writeback to ZVC
In reply to Christoph LameterSubject: swap_prefetch: conversion of nr_writeback to per zone counter
From: Christoph Lameter <[email protected]>
Conversion of nr_writeback to per zone counter
mm/swap_prefetch.c +1 -1
@@ -381,7 +381,7 @@ static int prefetch_suitable(void)get_page_state_node (&ps, node);/* We shouldn't prefetch when we are doing writeback */ -if (ps.nr_writeback) { +if (node_page_state (node,NR_WRITEBACK )) {node_clear (node, sp_stat.prefetch_nodes);continue ; }
PATCH 18/21 Conversion of nr_unstable to per zone counter
In reply to Christoph LameterSubject: zoned vm counters: conversion of nr_unstable to per zone counter
From: Christoph Lameter <[email protected]>
Conversion of nr_unstable to a per zone counter
We need to do some special modifications to the nfs code since there are multiple cases of disposition and we need to have a page ref for proper accounting. Needs to be reviewed by one familiar with NFS.
This converts the last critical page state of the VM and therefore we need to remove several functions that were depending on GET_PAGE_STATE_LAST in order to make the kernel compile again. We are only left with event type counters in page state.
drivers/base/node.c +2 -2
@@ -40,13 +40,11 @@ static ssize_t node_read_meminfo(structint n;int nid = dev->id;struct sysinfo i; -struct page_state ps;unsigned long inactive;unsigned long active;unsigned long free;si_meminfo_node (&i, nid); -get_page_state_node (&ps, nid);__get_zone_counts (&active, &inactive, &free,NODE_DATA (nid));
@@ -66,6 +64,7 @@ static ssize_t node_read_meminfo(struct"Node %d Mapped: %8lu kB\n" "Node %d Anonymous: %8lu kB\n" "Node %d PageTables: %8lu kB\n" +"Node %d Unstable: %8lu kB\n" "Node %d Slab: %8lu kB\n" , nid,K (i.totalram), nid, K(i.freeram),
@@ -82,6 +81,7 @@ static ssize_t node_read_meminfo(struct nid,K (node_page_state (nid,NR_MAPPED )), nid,K (node_page_state (nid,NR_ANON )), nid,K (node_page_state (nid,NR_PAGETABLE )), + nid,K (node_page_state (nid,NR_UNSTABLE )), nid, K(node_page_state(nid, NR_SLAB))); n +=hugetlb_report_node_meminfo (nid, buf + n);return n;
fs/fs-writeback.c +1 -1
@@ -473,7 +473,7 @@ void sync_inodes_sb(struct super_block * .range_end = LLONG_MAX, };unsigned long nr_dirty =global_page_state (NR_DIRTY ); -unsigned long nr_unstable =read_page_state (nr_unstable); +unsigned long nr_unstable =global_page_state (NR_UNSTABLE ); wbc.nr_to_write = nr_dirty + nr_unstable + (inodes_stat.nr_inodes - inodes_stat.nr_unused) +
fs/nfs/write.c +3 -4
@@ -525,7 +525,7 @@ nfs_mark_request_commit(struct nfs_pagenfs_list_add_request (req, &nfsi->commit); nfsi->ncommit++;spin_unlock (&nfsi->req_lock); -inc_page_state (nr_unstable); +inc_zone_page_state (req->wb_page,NR_UNSTABLE ); mark_inode_dirty(inode); }#endif
@@ -1382,7 +1382,6 @@ static void nfs_commit_done(struct rpc_t {struct nfs_write_data *data = calldata;struct nfs_page *req; -int res =0 ;dprintk ("NFS: %4d nfs_commit_done (status %d)\n" , task->tk_pid, task->tk_status);
@@ -1419,10 +1418,10 @@ static void nfs_commit_done(struct rpc_tdprintk (" mismatch\n" );nfs_mark_request_dirty (req); next: +if (req->wb_page) +dec_zone_page_state (req->wb_page,NR_UNSTABLE );nfs_clear_page_writeback (req); - res++; } -sub_page_state (nr_unstable,res); }static const struct rpc_call_ops nfs_commit_ops = {
include/linux/mmzone.h +1 -0
@@ -55,6 +55,7 @@ enum zone_stat_item {NR_PAGETABLE ,/* used for pagetables */ NR_DIRTY ,NR_WRITEBACK , +NR_UNSTABLE ,/* NFS unstable pages */ NR_VM_ZONE_STAT_ITEMS }; struct per_cpu_pages {
mm/page_alloc.c +1 -3
@@ -1361,7 +1361,6 @@ void si_meminfo_node(struct sysinfo *val*/ void show_free_areas (void ) { -struct page_state ps;int cpu, temperature;unsigned long active;unsigned long inactive;
@@ -1393,7 +1392,6 @@ void show_free_areas(void) } } -get_page_state (&ps);get_zone_counts (&active, &inactive, &free); printk("Free pages: %11ukB (%ukB HighMem)\n",
@@ -1406,7 +1404,7 @@ void show_free_areas(void) inactive,global_page_state (NR_DIRTY ),global_page_state (NR_WRITEBACK ), - ps.nr_unstable, +global_page_state (NR_UNSTABLE ),nr_free_pages (),global_page_state (NR_SLAB ), global_page_state(NR_MAPPED),
mm/page-writeback.c +1 -1
@@ -110,7 +110,7 @@ struct writeback_statestatic void get_writeback_state (struct writeback_state *wbs) { wbs->nr_dirty =global_page_state (NR_DIRTY ); - wbs->nr_unstable =read_page_state (nr_unstable); + wbs->nr_unstable =global_page_state (NR_UNSTABLE ); wbs->nr_mapped =global_page_state (NR_MAPPED ) +global_page_state (NR_ANON ); wbs->nr_writeback =global_page_state (NR_WRITEBACK );
fs/proc/proc_misc.c +2 -2
@@ -120,7 +120,6 @@ static int meminfo_read_proc(char *page, {struct sysinfo i;int len; -struct page_state ps;unsigned long inactive;unsigned long active;unsigned long free;
@@ -129,7 +128,6 @@ static int meminfo_read_proc(char *page,struct vmalloc_info vmi;long cached; -get_page_state (&ps);get_zone_counts (&active, &inactive, &free);/*
@@ -172,6 +170,7 @@ static int meminfo_read_proc(char *page,"Mapped: %8lu kB\n" "Slab: %8lu kB\n" "PageTables: %8lu kB\n" +"Unstable: %8lu kB\n" "CommitLimit: %8lu kB\n" "Committed_AS: %8lu kB\n" "VmallocTotal: %8lu kB\n"
@@ -196,6 +195,7 @@ static int meminfo_read_proc(char *page,K (global_page_state (NR_MAPPED )),K (global_page_state (NR_SLAB )),K (global_page_state (NR_PAGETABLE )), +K (global_page_state (NR_UNSTABLE )),K (allowed),K (committed), (unsigned long)VMALLOC_TOTAL >> 10,
mm/vmstat.c +1 -2
@@ -464,10 +464,9 @@ static char *vmstat_text[] = {"nr_page_table_pages" ,"nr_dirty" ,"nr_writeback" , - -/* Page state */ "nr_unstable" , +/* Event counters */ "pgpgin" ,"pgpgout" , "pswpin",
fs/nfs/pagelist.c +1 -0
@@ -154,6 +154,7 @@ void nfs_clear_request(struct nfs_page * {struct page *page = req->wb_page;if (page !=NULL ) { +dec_zone_page_state (page,NR_UNSTABLE );page_cache_release (page); req->wb_page =NULL ; }
PATCH 19/21 swap_prefetch: Conversion of nr_unstable to ZVC
In reply to Christoph LameterSubject: swap_prefetch: conversion of nr_unstable to per zone counter
From: Christoph Lameter <[email protected]>
The determination of the vm state is now not that expensive anymore after we remove the use of the page state. Change the logic to avoid the expensive checks.
mm/swap_prefetch.c +7 -14
@@ -298,7 +298,7 @@ static int prefetch_suitable(void) {unsigned long limit;struct zone *z; -int node, ret =0 , test_pagestate =0 ; +int node, ret =0 ;/* Purposefully racy */ if (test_bit (0 , &swapped.busy)) {
@@ -307,17 +307,15 @@ static int prefetch_suitable(void) }/* -* get_page_state and above_background_load are expensive so we only -* perform them every SWAP_CLUSTER_MAX prefetched_pages. +* above_background_load() is expensive so we only perform +* it every SWAP_CLUSTER_MAX prefetched_pages. * We test to see if we're above_background_load as disk activity * even at low priority can cause interrupt induced scheduling * latencies. */ -if (!(sp_stat.prefetched_pages %SWAP_CLUSTER_MAX )) { -if (above_background_load ()) +if ((!(sp_stat.prefetched_pages %SWAP_CLUSTER_MAX )) && +above_background_load ()) goto out; - test_pagestate =1 ; - }clear_current_prefetch_free ();
@@ -357,7 +355,6 @@ static int prefetch_suitable(void)*/ for_each_node_mask (node, sp_stat.prefetch_nodes) {struct node_stats *ns = &sp_stat.node[node]; -struct page_state ps;/* * We check to see that pages are not being allocated
@@ -375,11 +372,6 @@ static int prefetch_suitable(void) }else ns->last_free = ns->current_free; -if (!test_pagestate) -continue ; - -get_page_state_node (&ps, node); -/* We shouldn't prefetch when we are doing writeback */ if (node_page_state (node,NR_WRITEBACK )) {node_clear (node, sp_stat.prefetch_nodes);
@@ -394,7 +386,8 @@ static int prefetch_suitable(void)node_page_state (node,NR_ANON ) +node_page_state (node,NR_SLAB ) +node_page_state (node,NR_DIRTY ) + - ps.nr_unstable + total_swapcache_pages; +node_page_state (node,NR_UNSTABLE ) + + total_swapcache_pages;if (limit > ns->prefetch_watermark) {node_clear (node, sp_stat.prefetch_nodes);continue ;
PATCH 20/21 Conversion of nr_bounce to per zone counter
In reply to Christoph LameterSubject: zoned vm counters: conversion of nr_bounce to per zone counter
From: Christoph Lameter <[email protected]>
Conversion of nr_bounce to a per zone counter
nr_bounce is only used for proc output. So it could be left as an event counter. However, the event counters are not accurate and nr_bounce is categorizing types of pages in a zone. So we really need this to also be a per zone counter.
drivers/base/node.c +2 -0
@@ -65,6 +65,7 @@ static ssize_t node_read_meminfo(struct"Node %d Anonymous: %8lu kB\n" "Node %d PageTables: %8lu kB\n" "Node %d Unstable: %8lu kB\n" +"Node %d Bounce: %8lu kB\n" "Node %d Slab: %8lu kB\n" , nid,K (i.totalram), nid, K(i.freeram),
@@ -82,6 +83,7 @@ static ssize_t node_read_meminfo(struct nid,K (node_page_state (nid,NR_ANON )), nid,K (node_page_state (nid,NR_PAGETABLE )), nid,K (node_page_state (nid,NR_UNSTABLE )), + nid,K (node_page_state (nid,NR_BOUNCE )), nid, K(node_page_state(nid, NR_SLAB))); n +=hugetlb_report_node_meminfo (nid, buf + n);return n;
include/linux/mmzone.h +1 -0
@@ -56,6 +56,7 @@ enum zone_stat_item {NR_DIRTY ,NR_WRITEBACK ,NR_UNSTABLE ,/* NFS unstable pages */ +NR_BOUNCE , NR_VM_ZONE_STAT_ITEMS }; struct per_cpu_pages {
mm/highmem.c +2 -2
@@ -316,7 +316,7 @@ static void bounce_end_io(struct bio *bicontinue ;mempool_free (bvec->bv_page, pool); -dec_page_state (nr_bounce); +dec_zone_page_state (bvec->bv_page,NR_BOUNCE ); }bio_endio (bio_orig, bio_orig->bi_size, err);
@@ -397,7 +397,7 @@ static void __blk_queue_bounce(request_q to->bv_page =mempool_alloc (pool, q->bounce_gfp); to->bv_len = from->bv_len; to->bv_offset = from->bv_offset; -inc_page_state (nr_bounce); +inc_zone_page_state (to->bv_page,NR_BOUNCE );if (rw ==WRITE ) {char *vto, *vfrom;
mm/vmstat.c +1 -1
@@ -465,6 +465,7 @@ static char *vmstat_text[] = {"nr_dirty" ,"nr_writeback" ,"nr_unstable" , +"nr_bounce" ,/* Event counters */ "pgpgin",
@@ -512,7 +513,6 @@ static char *vmstat_text[] = {"allocstall" , "pgrotated", - "nr_bounce", };/*
fs/proc/proc_misc.c +2 -0
@@ -171,6 +171,7 @@ static int meminfo_read_proc(char *page,"Slab: %8lu kB\n" "PageTables: %8lu kB\n" "Unstable: %8lu kB\n" +"Bounce: %8lu kB\n" "CommitLimit: %8lu kB\n" "Committed_AS: %8lu kB\n" "VmallocTotal: %8lu kB\n"
@@ -196,6 +197,7 @@ static int meminfo_read_proc(char *page,K (global_page_state (NR_SLAB )),K (global_page_state (NR_PAGETABLE )),K (global_page_state (NR_UNSTABLE )), +K (global_page_state (NR_BOUNCE )),K (allowed),K (committed), (unsigned long)VMALLOC_TOTAL >> 10,
PATCH 21/21 Remove useless struct wbs
In reply to Christoph LameterSubject: zoned vm counters: remove useless writeback structure
From: Christoph Lameter <[email protected]>
Remove writeback state
We can remove some functions now that were needed to calculate the page state for writeback control since these statistics are now directly available.
mm/page-writeback.c +34 -51
@@ -99,23 +99,6 @@ EXPORT_SYMBOL(laptop_mode);static void background_writeout (unsigned long _min_pages); -struct writeback_state -{ -unsigned long nr_dirty; -unsigned long nr_unstable; -unsigned long nr_mapped; -unsigned long nr_writeback; -}; - -static void get_writeback_state (struct writeback_state *wbs) -{ - wbs->nr_dirty =global_page_state (NR_DIRTY ); - wbs->nr_unstable =global_page_state (NR_UNSTABLE ); - wbs->nr_mapped =global_page_state (NR_MAPPED ) + -global_page_state (NR_ANON ); - wbs->nr_writeback =global_page_state (NR_WRITEBACK ); -} -/* * Work out the current dirty-memory clamping and background writeout * thresholds.
@@ -134,8 +117,8 @@ static void get_writeback_state(struct w* clamping level. */ static void -get_dirty_limits (struct writeback_state *wbs,long *pbackground,long *pdirty, -struct address_space *mapping) +get_dirty_limits (long *pbackground,long *pdirty, +struct address_space *mapping) {int background_ratio;/* Percentages */ int dirty_ratio;
@@ -145,8 +128,6 @@ get_dirty_limits(struct writeback_stateunsigned long available_memory = total_pages;struct task_struct *tsk; -get_writeback_state (wbs); -#ifdef CONFIG_HIGHMEM /* * If this mapping can only allocate from low memory,
@@ -157,7 +138,9 @@ get_dirty_limits(struct writeback_state#endif - unmapped_ratio =100 - (wbs->nr_mapped *100 ) / total_pages; + unmapped_ratio =100 - ((global_page_state (NR_MAPPED ) + +global_page_state (NR_ANON )) *100 ) / + total_pages; dirty_ratio = vm_dirty_ratio;if (dirty_ratio > unmapped_ratio /2 )
@@ -190,7 +173,6 @@ get_dirty_limits(struct writeback_state*/ static void balance_dirty_pages (struct address_space *mapping) { -struct writeback_state wbs;long nr_reclaimable;long background_thresh;long dirty_thresh;
@@ -208,11 +190,12 @@ static void balance_dirty_pages(struct a .range_cyclic = 1, }; -get_dirty_limits (&wbs, &background_thresh, - &dirty_thresh, mapping); - nr_reclaimable = wbs.nr_dirty + wbs.nr_unstable; -if (nr_reclaimable + wbs.nr_writeback <= dirty_thresh) -break ; +get_dirty_limits (&background_thresh, &dirty_thresh, mapping); + nr_reclaimable =global_page_state (NR_DIRTY ) + +global_page_state (NR_UNSTABLE ); +if (nr_reclaimable +global_page_state (NR_WRITEBACK ) <= + dirty_thresh) +break ;if (!dirty_exceeded) dirty_exceeded =1 ;
@@ -225,11 +208,14 @@ static void balance_dirty_pages(struct a*/ if (nr_reclaimable) {writeback_inodes (&wbc); -get_dirty_limits (&wbs, &background_thresh, - &dirty_thresh, mapping); - nr_reclaimable = wbs.nr_dirty + wbs.nr_unstable; -if (nr_reclaimable + wbs.nr_writeback <= dirty_thresh) -break ; +get_dirty_limits (&background_thresh, + &dirty_thresh, mapping); + nr_reclaimable =global_page_state (NR_DIRTY ) + +global_page_state (NR_UNSTABLE ); +if (nr_reclaimable + +global_page_state (NR_WRITEBACK ) + <= dirty_thresh) +break ; pages_written += write_chunk - wbc.nr_to_write;if (pages_written >= write_chunk)break ;/* We've done our duty */
@@ -237,8 +223,9 @@ static void balance_dirty_pages(struct ablk_congestion_wait (WRITE ,HZ /10 ); } -if (nr_reclaimable + wbs.nr_writeback <= dirty_thresh && dirty_exceeded) - dirty_exceeded =0 ; +if (nr_reclaimable +global_page_state (NR_WRITEBACK ) + <= dirty_thresh && dirty_exceeded) + dirty_exceeded =0 ;if (writeback_in_progress (bdi))return ;/* pdflush is already working this queue */
@@ -300,12 +287,11 @@ EXPORT_SYMBOL(balance_dirty_pages_ratelivoid throttle_vm_writeout (void ) { -struct writeback_state wbs;long background_thresh;long dirty_thresh;for ( ; ; ) { -get_dirty_limits (&wbs, &background_thresh, &dirty_thresh,NULL ); +get_dirty_limits (&background_thresh, &dirty_thresh,NULL );/* * Boost the allowable dirty threshold a bit for page
@@ -313,8 +299,9 @@ void throttle_vm_writeout(void)*/ dirty_thresh += dirty_thresh /10 ;/* wheeee... */ -if (wbs.nr_unstable + wbs.nr_writeback <= dirty_thresh) -break ; +if (global_page_state (NR_UNSTABLE ) + +global_page_state (NR_WRITEBACK ) <= dirty_thresh) +break ;blk_congestion_wait (WRITE ,HZ /10 ); } }
@@ -337,12 +324,12 @@ static void background_writeout(unsigned };for ( ; ; ) { -struct writeback_state wbs;long background_thresh;long dirty_thresh; -get_dirty_limits (&wbs, &background_thresh, &dirty_thresh,NULL ); -if (wbs.nr_dirty + wbs.nr_unstable < background_thresh +get_dirty_limits (&background_thresh, &dirty_thresh,NULL ); +if (global_page_state (NR_DIRTY ) + +global_page_state (NR_UNSTABLE ) < background_thresh && min_pages <=0 )break ; wbc.encountered_congestion =0 ;
@@ -366,12 +353,9 @@ static void background_writeout(unsigned*/ int wakeup_pdflush (long nr_pages) { -if (nr_pages ==0 ) { -struct writeback_state wbs; - -get_writeback_state (&wbs); - nr_pages = wbs.nr_dirty + wbs.nr_unstable; - } +if (nr_pages ==0 ) + nr_pages =global_page_state (NR_DIRTY ) + +global_page_state (NR_UNSTABLE );return pdflush_operation (background_writeout, nr_pages); }
@@ -402,7 +386,6 @@ static void wb_kupdate(unsigned long argunsigned long start_jif;unsigned long next_jif;long nr_to_write; -struct writeback_state wbs;struct writeback_control wbc = { .bdi =NULL , .sync_mode =WB_SYNC_NONE ,
@@ -415,11 +398,11 @@ static void wb_kupdate(unsigned long argsync_supers (); -get_writeback_state (&wbs); oldest_jif = jiffies - dirty_expire_interval; start_jif = jiffies; next_jif = start_jif + dirty_writeback_interval; - nr_to_write = wbs.nr_dirty + wbs.nr_unstable + + nr_to_write =global_page_state (NR_DIRTY ) + +global_page_state (NR_UNSTABLE ) + (inodes_stat.nr_inodes - inodes_stat.nr_unused);while (nr_to_write >0 ) { wbc.encountered_congestion =0 ;