mm/page-writeback.c
Source file repositories/reference/linux-study-clean/mm/page-writeback.c
File Facts
- System
- Linux kernel
- Corpus path
mm/page-writeback.c- Extension
.c- Size
- 95315 bytes
- Lines
- 3117
- Domain
- Core OS
- Bucket
- Memory Management
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/math64.hlinux/export.hlinux/spinlock.hlinux/fs.hlinux/mm.hlinux/swap.hlinux/slab.hlinux/pagemap.hlinux/writeback.hlinux/init.hlinux/backing-dev.hlinux/task_io_accounting_ops.hlinux/blkdev.hlinux/mpage.hlinux/rmap.hlinux/percpu.hlinux/smp.hlinux/sysctl.hlinux/cpu.hlinux/syscalls.hlinux/folio_batch.hlinux/timer.hlinux/sched/rt.hlinux/sched/signal.hlinux/mm_inline.hlinux/shmem_fs.htrace/events/writeback.hinternal.h
Detected Declarations
function mdtc_validfunction wb_min_max_ratiofunction mdtc_validfunction wb_min_max_ratiofunction node_dirtyable_memoryfunction highmem_dirtyable_memoryfunction for_each_node_statefunction global_dirtyable_memoryfunction domain_dirty_limitsfunction domain_dirty_limitsfunction node_dirty_limitfunction node_dirty_okfunction dirty_background_ratio_handlerfunction dirty_background_bytes_handlerfunction dirty_ratio_handlerfunction dirty_bytes_handlerfunction wp_next_timefunction wb_domain_writeout_addfunction __wb_writeout_addfunction wb_writeout_incfunction writeout_periodfunction wb_domain_initfunction wb_domain_exitfunction bdi_check_pages_limitfunction bdi_ratio_from_pagesfunction bdi_get_bytesfunction __bdi_set_min_ratiofunction __bdi_set_max_ratiofunction bdi_set_min_ratio_no_scalefunction bdi_set_max_ratio_no_scalefunction bdi_set_min_ratiofunction bdi_set_max_ratiofunction bdi_get_min_bytesfunction bdi_set_min_bytesfunction bdi_get_max_bytesfunction bdi_set_max_bytesfunction bdi_set_strict_limitfunction dirty_freerun_ceilingfunction hard_dirty_limitfunction mdtc_calc_availfunction dtc_is_globalfunction domain_dirty_availfunction balance_dirty_pagesfunction goodfunction wb_calc_threshfunction cgwb_calc_threshfunction pos_ratio_polynomfunction ratio
Annotated Snippet
if (min) {
min *= this_bw;
min = div64_ul(min, tot_bw);
}
if (max < 100 * BDI_RATIO_SCALE) {
max *= this_bw;
max = div64_ul(max, tot_bw);
}
}
*minp = min;
*maxp = max;
}
#else /* CONFIG_CGROUP_WRITEBACK */
#define GDTC_INIT(__wb) .wb = (__wb), \
.wb_completions = &(__wb)->completions
#define GDTC_INIT_NO_WB
#define MDTC_INIT(__wb, __gdtc)
static bool mdtc_valid(struct dirty_throttle_control *dtc)
{
return false;
}
static struct wb_domain *dtc_dom(struct dirty_throttle_control *dtc)
{
return &global_wb_domain;
}
static struct dirty_throttle_control *mdtc_gdtc(struct dirty_throttle_control *mdtc)
{
return NULL;
}
static struct fprop_local_percpu *wb_memcg_completions(struct bdi_writeback *wb)
{
return NULL;
}
static void wb_min_max_ratio(struct bdi_writeback *wb,
unsigned long *minp, unsigned long *maxp)
{
*minp = wb->bdi->min_ratio;
*maxp = wb->bdi->max_ratio;
}
#endif /* CONFIG_CGROUP_WRITEBACK */
/*
* In a memory zone, there is a certain amount of pages we consider
* available for the page cache, which is essentially the number of
* free and reclaimable pages, minus some zone reserves to protect
* lowmem and the ability to uphold the zone's watermarks without
* requiring writeback.
*
* This number of dirtyable pages is the base value of which the
* user-configurable dirty ratio is the effective number of pages that
* are allowed to be actually dirtied. Per individual zone, or
* globally by using the sum of dirtyable pages over all zones.
*
* Because the user is allowed to specify the dirty limit globally as
* absolute number of bytes, calculating the per-zone dirty limit can
* require translating the configured limit into a percentage of
* global dirtyable memory first.
*/
/**
* node_dirtyable_memory - number of dirtyable pages in a node
* @pgdat: the node
*
* Return: the node's number of pages potentially available for dirty
* page cache. This is the base value for the per-node dirty limits.
*/
static unsigned long node_dirtyable_memory(struct pglist_data *pgdat)
{
unsigned long nr_pages = 0;
int z;
for (z = 0; z < MAX_NR_ZONES; z++) {
struct zone *zone = pgdat->node_zones + z;
if (!populated_zone(zone))
continue;
nr_pages += zone_page_state(zone, NR_FREE_PAGES);
}
/*
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/math64.h`, `linux/export.h`, `linux/spinlock.h`, `linux/fs.h`, `linux/mm.h`, `linux/swap.h`, `linux/slab.h`.
- Detected declarations: `function mdtc_valid`, `function wb_min_max_ratio`, `function mdtc_valid`, `function wb_min_max_ratio`, `function node_dirtyable_memory`, `function highmem_dirtyable_memory`, `function for_each_node_state`, `function global_dirtyable_memory`, `function domain_dirty_limits`, `function domain_dirty_limits`.
- Atlas domain: Core OS / Memory Management.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.