Linux Kernel
3.7.1
|
#include <linux/kernel.h>
#include <linux/export.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 <linux/timer.h>
#include <trace/events/writeback.h>
Go to the source code of this file.
Macros | |
#define | MAX_PAUSE max(HZ/5, 1) |
#define | DIRTY_POLL_THRESH (128 >> (PAGE_SHIFT - 10)) |
#define | BANDWIDTH_INTERVAL max(HZ/5, 1) |
#define | RATELIMIT_CALC_SHIFT 10 |
#define | VM_COMPLETIONS_PERIOD_LEN (3*HZ) |
#define | WRITEBACK_TAG_BATCH 4096 |
Variables | |
int | dirty_background_ratio = 10 |
unsigned long | dirty_background_bytes |
int | vm_highmem_is_dirtyable |
int | vm_dirty_ratio = 20 |
unsigned long | vm_dirty_bytes |
unsigned int | dirty_writeback_interval = 5 * 100 |
unsigned int | dirty_expire_interval = 30 * 100 |
int | block_dump |
int | laptop_mode |
unsigned long | global_dirty_limit |
Definition at line 54 of file page-writeback.c.
#define DIRTY_POLL_THRESH (128 >> (PAGE_SHIFT - 10)) |
Definition at line 49 of file page-writeback.c.
Definition at line 43 of file page-writeback.c.
#define RATELIMIT_CALC_SHIFT 10 |
Definition at line 56 of file page-writeback.c.
#define VM_COMPLETIONS_PERIOD_LEN (3*HZ) |
Definition at line 152 of file page-writeback.c.
#define WRITEBACK_TAG_BATCH 4096 |
void __bdi_update_bandwidth | ( | struct backing_dev_info * | bdi, |
unsigned long | thresh, | ||
unsigned long | bg_thresh, | ||
unsigned long | dirty, | ||
unsigned long | bdi_thresh, | ||
unsigned long | bdi_dirty, | ||
unsigned long | start_time | ||
) |
Definition at line 1012 of file page-writeback.c.
Definition at line 1958 of file page-writeback.c.
Definition at line 2009 of file page-writeback.c.
void account_page_dirtied | ( | struct page * | page, |
struct address_space * | mapping | ||
) |
Definition at line 1969 of file page-writeback.c.
Definition at line 2045 of file page-writeback.c.
Definition at line 1988 of file page-writeback.c.
void balance_dirty_pages_ratelimited_nr | ( | struct address_space * | mapping, |
unsigned long | nr_pages_dirtied | ||
) |
balance_dirty_pages_ratelimited_nr - balance dirty memory state : address_space which was dirtied : number of pages which the caller has just dirtied
Processes which are dirtying memory should call in here once for each page which was newly dirtied. The function will periodically check the system's dirty state and will initiate writeback if needed.
On really big machines, get_writeback_state is expensive, so try to avoid calling it too often (ratelimiting). But once we're over the dirty memory limit we decrease the ratelimiting by a lot, to prevent individual processes from overshooting the limit by (ratelimit_pages) each.
Definition at line 1452 of file page-writeback.c.
unsigned long bdi_dirty_limit | ( | struct backing_dev_info * | bdi, |
unsigned long | dirty | ||
) |
bdi_dirty_limit - 's share of dirty throttling threshold : the backing_dev_info to query : global dirty limit in pages
Returns 's dirty limit in pages. The term "dirty" in the context of dirty balancing includes all PG_dirty, PG_writeback and NFS unstable pages.
Note that balance_dirty_pages() will only seriously take it as a hard limit when sleeping max_pause per page is not enough to keep the dirty pages under control. For example, when the device is completely stalled due to some error conditions, or when there are 1000 dd tasks writing to a slow 10MB/s USB key. In the other normal situations, it acts more gently by throttling the tasks more (rather than completely block them) when the bdi dirty pages go high.
It allocates high/low dirty limits to fast/slow devices, in order to prevent
The bdi's share of dirty limit will be adapting to its throughput and bounded by the bdi->min_ratio and/or bdi->max_ratio parameters, if set.
Definition at line 547 of file page-writeback.c.
int bdi_set_max_ratio | ( | struct backing_dev_info * | bdi, |
unsigned | max_ratio | ||
) |
Definition at line 494 of file page-writeback.c.
int bdi_set_min_ratio | ( | struct backing_dev_info * | bdi, |
unsigned int | min_ratio | ||
) |
Definition at line 473 of file page-writeback.c.
void bdi_writeout_inc | ( | struct backing_dev_info * | bdi | ) |
Definition at line 424 of file page-writeback.c.
Definition at line 2146 of file page-writeback.c.
|
pure virtual |
int dirty_background_bytes_handler | ( | struct ctl_table * | table, |
int | write, | ||
void __user * | buffer, | ||
size_t * | lenp, | ||
loff_t * | ppos | ||
) |
Definition at line 351 of file page-writeback.c.
int dirty_background_ratio_handler | ( | struct ctl_table * | table, |
int | write, | ||
void __user * | buffer, | ||
size_t * | lenp, | ||
loff_t * | ppos | ||
) |
Definition at line 339 of file page-writeback.c.
int dirty_bytes_handler | ( | struct ctl_table * | table, |
int | write, | ||
void __user * | buffer, | ||
size_t * | lenp, | ||
loff_t * | ppos | ||
) |
Definition at line 378 of file page-writeback.c.
int dirty_ratio_handler | ( | struct ctl_table * | table, |
int | write, | ||
void __user * | buffer, | ||
size_t * | lenp, | ||
loff_t * | ppos | ||
) |
Definition at line 363 of file page-writeback.c.
int dirty_writeback_centisecs_handler | ( | ctl_table * | table, |
int | write, | ||
void __user * | buffer, | ||
size_t * | length, | ||
loff_t * | ppos | ||
) |
Definition at line 1531 of file page-writeback.c.
int do_writepages | ( | struct address_space * | mapping, |
struct writeback_control * | wbc | ||
) |
Definition at line 1903 of file page-writeback.c.
EXPORT_SYMBOL | ( | laptop_mode | ) |
EXPORT_SYMBOL | ( | bdi_set_max_ratio | ) |
EXPORT_SYMBOL | ( | balance_dirty_pages_ratelimited_nr | ) |
EXPORT_SYMBOL | ( | tag_pages_for_writeback | ) |
EXPORT_SYMBOL | ( | write_cache_pages | ) |
EXPORT_SYMBOL | ( | generic_writepages | ) |
EXPORT_SYMBOL | ( | write_one_page | ) |
EXPORT_SYMBOL | ( | account_page_dirtied | ) |
EXPORT_SYMBOL | ( | account_page_writeback | ) |
EXPORT_SYMBOL | ( | __set_page_dirty_nobuffers | ) |
EXPORT_SYMBOL | ( | account_page_redirty | ) |
EXPORT_SYMBOL | ( | redirty_page_for_writepage | ) |
EXPORT_SYMBOL | ( | set_page_dirty | ) |
EXPORT_SYMBOL | ( | set_page_dirty_lock | ) |
EXPORT_SYMBOL | ( | clear_page_dirty_for_io | ) |
EXPORT_SYMBOL | ( | test_set_page_writeback | ) |
EXPORT_SYMBOL | ( | mapping_tagged | ) |
EXPORT_SYMBOL_GPL | ( | dirty_writeback_interval | ) |
EXPORT_SYMBOL_GPL | ( | bdi_writeout_inc | ) |
int generic_writepages | ( | struct address_space * | mapping, |
struct writeback_control * | wbc | ||
) |
generic_writepages - walk the list of dirty pages of the given address space and writepage() all of them. : address space structure to write : subtract the number of written pages from *->nr_to_write
This is a library function, which implements the writepages() address_space_operation.
Definition at line 1885 of file page-writeback.c.
Definition at line 243 of file page-writeback.c.
int mapping_tagged | ( | struct address_space * | mapping, |
int | tag | ||
) |
Definition at line 2273 of file page-writeback.c.
Definition at line 1642 of file page-writeback.c.
int redirty_page_for_writepage | ( | struct writeback_control * | wbc, |
struct page * | page | ||
) |
Definition at line 2061 of file page-writeback.c.
Definition at line 2080 of file page-writeback.c.
Definition at line 1410 of file page-writeback.c.
Definition at line 2121 of file page-writeback.c.
void tag_pages_for_writeback | ( | struct address_space * | mapping, |
pgoff_t | start, | ||
pgoff_t | end | ||
) |
tag_pages_for_writeback - tag pages to be written by write_cache_pages : address space structure to write : starting page index : ending page index (inclusive)
This function scans the page range from to (inclusive) and tags all pages that have DIRTY tag set with a special TOWRITE tag. The idea is that write_cache_pages (or whoever calls this function) will then use TOWRITE tag to identify pages eligible for writeback. This mechanism is used to avoid livelocking of writeback by a process steadily creating new dirty pages in the file (thus it is important for this function to be quick so that it can tag pages faster than a dirtying process can create them).
Definition at line 1667 of file page-writeback.c.
Definition at line 2202 of file page-writeback.c.
Definition at line 2233 of file page-writeback.c.
Definition at line 1498 of file page-writeback.c.
int write_cache_pages | ( | struct address_space * | mapping, |
struct writeback_control * | wbc, | ||
writepage_t | writepage, | ||
void * | data | ||
) |
write_cache_pages - walk the list of dirty pages of the given address space and write all of them. : address space structure to write : subtract the number of written pages from *->nr_to_write : function called for each page : data passed to writepage function
If a page is already under I/O, write_cache_pages() skips it, even if it's dirty. This is desirable behaviour for memory-cleaning writeback, but it is INCORRECT for data-integrity system calls such as fsync(). fsync() and msync() need to guarantee that all the data which was dirty at the time the call was made get new I/O started against them. If wbc->sync_mode is WB_SYNC_ALL then we were called for data integrity and we must wait for existing IO to complete.
To avoid livelocks (when other process dirties new pages), we first tag pages which should be written back with TOWRITE tag and only then start writing them. For data-integrity sync we have to be careful so that we do not miss some pages (e.g., because some other process has cleared TOWRITE tag we set). The rule we follow is that TOWRITE tag can be cleared only by the process clearing the DIRTY tag (and submitting the page for IO).
Definition at line 1708 of file page-writeback.c.
Definition at line 1925 of file page-writeback.c.
Definition at line 1593 of file page-writeback.c.
int block_dump |
Definition at line 109 of file page-writeback.c.
unsigned long dirty_background_bytes |
Definition at line 75 of file page-writeback.c.
int dirty_background_ratio = 10 |
Definition at line 69 of file page-writeback.c.
unsigned int dirty_expire_interval = 30 * 100 |
Definition at line 104 of file page-writeback.c.
unsigned int dirty_writeback_interval = 5 * 100 |
Definition at line 97 of file page-writeback.c.
unsigned long global_dirty_limit |
Definition at line 121 of file page-writeback.c.
int laptop_mode |
Definition at line 115 of file page-writeback.c.
unsigned long vm_dirty_bytes |
Definition at line 92 of file page-writeback.c.
int vm_dirty_ratio = 20 |
Definition at line 86 of file page-writeback.c.
int vm_highmem_is_dirtyable |
Definition at line 81 of file page-writeback.c.