/* * mm/page-writeback.c * * Copyright (C) 2002, Linus Torvalds. * Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com> * * Contains functions related to writing back dirty pages at the * address_space level. * * 10Apr2002 Andrew Morton * Initial version */#include<linux/kernel.h>#include<linux/module.h>#include<linux/spinlock.h>#include<linux/fs.h>#include<linux/mm.h>#include<linux/swap.h>#include<linux/slab.h>#include<linux/pagemap.h>#include<linux/writeback.h>#include<linux/init.h>#include<linux/backing-dev.h>#include<linux/task_io_accounting_ops.h>#include<linux/blkdev.h>#include<linux/mpage.h>#include<linux/rmap.h>#include<linux/percpu.h>#include<linux/notifier.h>#include<linux/smp.h>#include<linux/sysctl.h>#include<linux/cpu.h>#include<linux/syscalls.h>#include<linux/buffer_head.h>#include<linux/pagevec.h>#include<trace/events/writeback.h>/* * After a CPU has dirtied this many pages, balance_dirty_pages_ratelimited * will look to see if it needs to force writeback or throttling. */staticlongratelimit_pages=32;/* * When balance_dirty_pages decides that the caller needs to perform some * non-background writeback, this is how many pages it will attempt to write. * It should be somewhat larger than dirtied pages to ensure that reasonably * large amounts of I/O are submitted. */staticinlinelongsync_writeback_pages(unsignedlongdirtied){if(dirtied<ratelimit_pages)dirtied=ratelimit_pages;returndirtied+dirtied/2;}/* The following parameters are exported via /proc/sys/vm *//* * Start background writeback (via writeback threads) at this percentage */intdirty_background_ratio=10;/* * dirty_background_bytes starts at 0 (disabled) so that it is a function of * dirty_background_ratio * the amount of dirtyable memory */unsignedlongdirty_background_bytes;/* * free highmem will not be subtracted from the total free memory * for calculating free ratios if vm_highmem_is_dirtyable is true */intvm_highmem_is_dirtyable;/* * The generator of dirty data starts writeback at this percentage */intvm_dirty_ratio=20;/* * vm_dirty_bytes starts at 0 (disabled) so that it is a function of * vm_dirty_ratio * the amount of dirtyable memory */unsignedlongvm_dirty_bytes;/* * The interval between `kupdate'-style writebacks */unsignedintdirty_writeback_interval=5*100;/* centiseconds *//* * The longest time for which data is allowed to remain dirty */unsignedintdirty_expire_interval=30*100;/* centiseconds *//* * Flag that makes the machine dump writes/reads and block dirtyings. */intblock_dump;/* * Flag that puts the machine in "laptop mode". Doubles as a ti