mm/page_reporting.c
Source file repositories/reference/linux-study-clean/mm/page_reporting.c
File Facts
- System
- Linux kernel
- Corpus path
mm/page_reporting.c- Extension
.c- Size
- 12020 bytes
- Lines
- 419
- 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/mm.hlinux/mmzone.hlinux/page_reporting.hlinux/gfp.hlinux/export.hlinux/module.hlinux/delay.hlinux/scatterlist.hpage_reporting.hinternal.h
Detected Declarations
function page_order_update_notifyfunction __page_reporting_requestfunction __page_reporting_notifyfunction page_reporting_drainfunction page_reporting_cyclefunction page_reporting_process_zonefunction page_reporting_processfunction for_each_zonefunction page_reporting_registerfunction lockdep_is_heldfunction page_reporting_unregisterexport page_reporting_orderexport page_reporting_registerexport page_reporting_unregister
Annotated Snippet
if (budget < 0) {
atomic_set(&prdev->state, PAGE_REPORTING_REQUESTED);
next = page;
break;
}
/* Attempt to pull page from list and place in scatterlist */
if (*offset) {
if (!__isolate_free_page(page, order)) {
next = page;
break;
}
/* Add page to scatter list */
--(*offset);
sg_set_page(&sgl[*offset], page, page_len, 0);
continue;
}
/*
* Make the first non-reported page in the free list
* the new head of the free list before we release the
* zone lock.
*/
if (!list_is_first(&page->lru, list))
list_rotate_to_front(&page->lru, list);
/* release lock before waiting on report processing */
spin_unlock_irq(&zone->lock);
/* begin processing pages in local list */
err = prdev->report(prdev, sgl, PAGE_REPORTING_CAPACITY);
/* reset offset since the full list was reported */
*offset = PAGE_REPORTING_CAPACITY;
/* update budget to reflect call to report function */
budget--;
/* reacquire zone lock and resume processing */
spin_lock_irq(&zone->lock);
/* flush reported pages from the sg list */
page_reporting_drain(prdev, sgl, PAGE_REPORTING_CAPACITY, !err);
/*
* Reset next to first entry, the old next isn't valid
* since we dropped the lock to report the pages
*/
next = list_first_entry(list, struct page, lru);
/* exit on error */
if (err)
break;
}
/* Rotate any leftover pages to the head of the freelist */
if (!list_entry_is_head(next, list, lru) && !list_is_first(&next->lru, list))
list_rotate_to_front(&next->lru, list);
spin_unlock_irq(&zone->lock);
return err;
}
static int
page_reporting_process_zone(struct page_reporting_dev_info *prdev,
struct scatterlist *sgl, struct zone *zone)
{
unsigned int order, mt, leftover, offset = PAGE_REPORTING_CAPACITY;
unsigned long watermark;
int err = 0;
/* Generate minimum watermark to be able to guarantee progress */
watermark = low_wmark_pages(zone) +
(PAGE_REPORTING_CAPACITY << page_reporting_order);
/*
* Cancel request if insufficient free memory or if we failed
* to allocate page reporting statistics for the zone.
*/
if (!zone_watermark_ok(zone, 0, watermark, 0, ALLOC_CMA))
return err;
/* Process each free list starting from lowest order/mt */
for (order = page_reporting_order; order < NR_PAGE_ORDERS; order++) {
for (mt = 0; mt < MIGRATE_TYPES; mt++) {
/* We do not pull pages from the isolate free list */
if (is_migrate_isolate(mt))
Annotation
- Immediate include surface: `linux/mm.h`, `linux/mmzone.h`, `linux/page_reporting.h`, `linux/gfp.h`, `linux/export.h`, `linux/module.h`, `linux/delay.h`, `linux/scatterlist.h`.
- Detected declarations: `function page_order_update_notify`, `function __page_reporting_request`, `function __page_reporting_notify`, `function page_reporting_drain`, `function page_reporting_cycle`, `function page_reporting_process_zone`, `function page_reporting_process`, `function for_each_zone`, `function page_reporting_register`, `function lockdep_is_held`.
- 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.