# mincore: private COW versus file-cache residency

## Result and interpretation
Two captures, five new self-owned files each, on Linux 6.8.0-147-generic:
after file-range POSIX_FADV_DONTNEED, the locked private copy returned residency
bit 1 and an untouched mapping of the same file offset returned 0. Reading the
untouched mapping returned A and its next residency query returned 1. The private
copy still contained B; pread returned A. After unlocking and MADV_DONTNEED on
the private mapping, its next read returned A.

These are sequential API observations, not an atomic snapshot, performance
benchmark, physical-I/O measurement, durability test or side-channel reproduction.
The successful advisory call does not guarantee eviction on another host.
The filesystem magic 0xef53 identifies the ext family, not its version.

## Reproduce
Keep probe.c and run.py together. From a writable test directory:
```sh
python3 -B run.py --output new-results.json
```
Requires Linux, a C compiler, Python 3, POSIX_FADV_DONTNEED, and permission to
mlock one page. No elevated privilege or global cache-drop operation is used.
Each trial immediately unlinks its own temporary file; mappings and descriptors
are released. The runner removes its temporary compiler output and refuses to
overwrite an existing capture. An unsupported call or failed content control
exits unsuccessfully rather than inventing measurements.

The runner compiles with -std=c11 -Wall -Wextra -Werror -O2 and runs five fresh
processes. Each creates one page of A bytes, fsyncs the file, makes two private
mappings, changes only the first mapping to B and locks that private page. Both
residency queries occur before fresh[0] or pread; touching the fresh mapping
earlier would change the observation. Only the defined low bit is retained.
The file and COW-discard controls test which bytes each object exposes.
results.json and repeat.json retain the full captures and source SHA-256 hashes.

The publication tests lock the historical captures to their recorded values;
run.py accepts valid outcomes on other hosts without promising identical eviction.
Do not interpret five repetitions as independent machines or fleet statistics.

## Source review
- Linux v6.17 mm/mincore.c: mincore_pte_range reports a present PTE as one;
  __mincore_unmapped_range consults the file mapping for absent PTEs.
  https://raw.githubusercontent.com/torvalds/linux/v6.17/mm/mincore.c
- mmap(2), Linux man-pages 6.19: MAP_PRIVATE changes are private and do not
  update the underlying file.
  https://man7.org/linux/man-pages/man2/mmap.2.html
- mincore(2), Linux man-pages 6.19: mapped-address range, low-bit definition
  and snapshot caveat.
  https://man7.org/linux/man-pages/man2/mincore.2.html
- Gruss et al., Page Cache Attacks, CCS 2019; DOI 10.1145/3319535.3339809.
  Section 2.2 distinguishes shared unmodified pages from private written copies;
  sections 5 and 9 discuss observation and mitigation. This experiment checks
  mapping semantics only, not that paper's attack or performance results.
  https://gruss.cc/files/pagecacheattacks.pdf

API/source review: 2026-11-09 Europe/Warsaw. Implementation reasoning is pinned
to v6.17; native captures report their actual older distribution kernel.
