fs/drop_caches.c
Source file repositories/reference/linux-study-clean/fs/drop_caches.c
File Facts
- System
- Linux kernel
- Corpus path
fs/drop_caches.c- Extension
.c- Size
- 2403 bytes
- Lines
- 99
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pagemap.hlinux/kernel.hlinux/mm.hlinux/fs.hlinux/writeback.hlinux/sysctl.hlinux/gfp.hlinux/swap.hinternal.h
Detected Declarations
function drop_pagecache_sbfunction drop_caches_sysctl_handlerfunction init_vm_drop_caches_sysctlsmodule init init_vm_drop_caches_sysctls
Annotated Snippet
if (sysctl_drop_caches & 1) {
lru_add_drain_all();
iterate_supers(drop_pagecache_sb, NULL);
count_vm_event(DROP_PAGECACHE);
}
if (sysctl_drop_caches & 2) {
drop_slab();
count_vm_event(DROP_SLAB);
}
if (!stfu) {
pr_info("%s (%d): drop_caches: %d\n",
current->comm, task_pid_nr(current),
sysctl_drop_caches);
}
stfu |= sysctl_drop_caches & 4;
}
return 0;
}
static const struct ctl_table drop_caches_table[] = {
{
.procname = "drop_caches",
.data = &sysctl_drop_caches,
.maxlen = sizeof(int),
.mode = 0200,
.proc_handler = drop_caches_sysctl_handler,
.extra1 = SYSCTL_ONE,
.extra2 = SYSCTL_FOUR,
},
};
static int __init init_vm_drop_caches_sysctls(void)
{
register_sysctl_init("vm", drop_caches_table);
return 0;
}
fs_initcall(init_vm_drop_caches_sysctls);
Annotation
- Immediate include surface: `linux/pagemap.h`, `linux/kernel.h`, `linux/mm.h`, `linux/fs.h`, `linux/writeback.h`, `linux/sysctl.h`, `linux/gfp.h`, `linux/swap.h`.
- Detected declarations: `function drop_pagecache_sb`, `function drop_caches_sysctl_handler`, `function init_vm_drop_caches_sysctls`, `module init init_vm_drop_caches_sysctls`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.