reclaim_submit_bench: the fragmenting mapping takes all the free memory but 1 GiB, so no high order is left

With 6 GiB the fragmenting took the free blocks of the lower orders and left every order-10 block
(1109 of them, 4.3 GiB, potluck 10420's buddyinfo), so a 64 MiB block's pages came without
compaction (compact_stall 0). The mapping now takes all of MemFree but 1 GiB, at most 14 GiB.

(cherry picked from commit 2b8744b3264ff66a96368ab0a97ca5d0aba10ed9)
This commit is contained in:
Anees Iqbal committed 2026-11-09 01:44:38 -08:00
1 parent 8890d6504c
commit 2c16ca47a5
1 file changed
+14 -7
@@ -11,9 +11,10 @@
//! Each arm submits small command buffers for [`QUIET`] with nothing else running and for
//! [`PRESSED`] once the host's memory is fragmented, as a desktop's is after its builds: half of
//! it read into the page cache from a sparse file (holes, so nothing is written to disk), and
//! [`FRAGMENT_BYTES`] of private anonymous memory, every page written, of which every other page
//! is then given back (`MADV_DONTNEED`), so that much of the free memory lies in single pages
//! between pages in use, `MemAvailable` staying high; beside the phase a thread maps private
//! private anonymous memory of all the host's free memory but [`FRAGMENT_SPARE_BYTES`] (at most
//! [`FRAGMENT_MOST_BYTES`]), every page written, so that the free blocks of every order are taken,
//! of which every other page is then given back (`MADV_DONTNEED`), so that the free memory lies in
//! single pages between pages in use, `MemAvailable` staying high; beside the phase a thread maps private
//! anonymous memory advised for huge pages in pieces of [`PIECE_BYTES`], every page written, up
//! to [`ANON_HIGH_BYTES`] while the host's `MemAvailable` stays above [`FLOOR_BYTES`], drops every
//! other piece down to [`ANON_LOW_BYTES`] and reads the file again. Each command buffer copies [`COPY_BYTES`] from a no-copy buffer over
@@ -80,8 +81,10 @@ const QUIET: Duration = Duration::from_secs(10);
const PRESSED: Duration = Duration::from_secs(20);
/// The gap between submissions.
const EVERY: Duration = Duration::from_millis(1);
/// The anonymous memory written and then given back page by page, every other page kept.
const FRAGMENT_BYTES: u64 = 6 * GIB;
/// The free memory the fragmenting mapping leaves, and its most: written, then given back page
/// by page, every other page kept.
const FRAGMENT_SPARE_BYTES: u64 = GIB;
const FRAGMENT_MOST_BYTES: u64 = 14 * GIB;
/// The anonymous memory the pressing thread holds between these bounds.
const ANON_HIGH_BYTES: u64 = 5 * GIB;
const ANON_LOW_BYTES: u64 = 2 * GIB;
@@ -213,8 +216,12 @@ impl Pressing {
let stop = Arc::new(AtomicBool::new(false));
let heat = Heat::new(meminfo("MemTotal") / 2);
heat.read(&stop);
let fragments = Anonymous::new(FRAGMENT_BYTES, false);
for page in (0..FRAGMENT_BYTES / PAGE).step_by(2) {
let length = (meminfo("MemFree").saturating_sub(FRAGMENT_SPARE_BYTES))
.min(FRAGMENT_MOST_BYTES)
/ PAGE
* PAGE;
let fragments = Anonymous::new(length, false);
for page in (0..length / PAGE).step_by(2) {
// SAFETY: a page of the bench's own mapping, which nothing else uses: given back, it
// reads as zeros if touched again.
unsafe {