Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=49.212.243.145 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796027699; b=pJ+HTLWcZLQALlW/GJ2TldneTMTdARDJIVi+p1+b5NdYEPvcmw+oLhu5T+bnBimglfMJ hq1R3KwndJM3CTj8FzjkFp+02/4UYGDxQAxq4hJ6BFNA65lXYB+sP1w4oiYcXFOELMDfF eU9+ihjkRI/2DuFlOLSClaA0wc/EDWhDyvGzRU+af2yVVgKQ6dfVvtMAEceuO+srHQYeh l+rW4sEHjlDVg2OJwO0UiS8mJlVR+Ug09TLipte2wdBfz3Dq8/peaNV6V/QMlYbaL13wA DZK2Xgg+pN2MunozF+HpXJ6qw7d7Dg6N4kxItGaUpTBpI5nE0NqWbWsWTKwMop5fdNg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796027699; h=DMARC-Filter:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-Virus-Status:X-Anti-Virus-Server; bh=Q9+bjDiuHNX3IcNYIt7ZESkiPTh36T3+ySKdplcSBLE=; b=1aSnbbV6Ys2YH1lWAertlDvW/8St0N6gSmEcF2shGD9q+RnK+Jz7610mDBxZ7b2LDwAl wBhIg5Tz5I5ue3QDyFK6Y/lzYh3pJEgs3QYo3A9SzASxvYRsJirTB7nPOgUKlj74d8Hlc nLXYpDs7Zw7xsj//DMUw+JdMnW7+XLCdsuFVfVtKxWlr+0oE0KzqZwadONohyJh8iJ0tg wDFtGgVo5bFBTv4KwIT0wX7UEYk8lXa0Yrt/pEGESPQqzXXaA9qYBn3LbHDdKU1oIJbLT TebRRA/ax/PNetOCJGkfU9GWxgj8R1S+QrhzhN1jIrB1XPNp6ztucbdySPxtX0uBUBA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pisnp.net; spf=pass smtp.mailfrom=pisnp.net; dkim=pass header.d=pisnp.net header.i=@pisnp.net header.a=rsa-sha256 header.s=rs20260908 header.b=PyqJPP0z; arc=none smtp.remote-ip=49.212.243.145 Received: from www3605.sakura.ne.jp (www3605.sakura.ne.jp [49.212.243.145]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 809D6606A31C for ; Mon, 30 Nov 2026 08:34:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 809D6606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pisnp.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pisnp.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pisnp.net header.i=@pisnp.net header.a=rsa-sha256 header.s=rs20260908 header.b=PyqJPP0z Received: from www3605.sakura.ne.jp (localhost [127.0.0.1]) by www3605.sakura.ne.jp (8.16.1/8.16.1) with ESMTP id 6AU8YoM6026340; Mon, 30 Nov 2026 17:34:50 +0900 (JST) (envelope-from hiro@pisnp.net) Received: from hirotakay.c.googlers.com.com (57.134.185.35.bc.googleusercontent.com [35.185.134.57]) (authenticated bits=0) by www3605.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6AU8YbfN026202 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 30 Nov 2026 17:34:49 +0900 (JST) (envelope-from hiro@pisnp.net) DKIM-Signature: a=rsa-sha256; bh=Q9+bjDiuHNX3IcNYIt7ZESkiPTh36T3+ySKdplcSBLE=; c=relaxed/relaxed; d=pisnp.net; h=From:Message-ID:To:Subject:Date; s=rs20260908; t=1796027690; v=1; b=PyqJPP0zqwsOergsVkqEzlC8vae6iWPzHogSRQF/rARdehVuVS2PdWqJn3pzBC8n LN6EKo17JxUPi6nqp4G4k+w3ax7so1cmQXsUYC/4JrABLLJQscGhPPBX2SdytS35 /73yplUChq0dEhcXVoN/nXb5v2vREhYNDy7ZUMYBuDS2cKEs738/DskNI2mmquH/ gbI5Slvq0U+GVRxZvxZ33ILh6SeNHaKKHPWDZiQnStMvHq/5tjNjF48/BVaKpAwH G3Cub3d0FljpcLxQWY+A4g0IfC6jF38FNnSQDysax0g0dxGwcDmWvNOMSWxVPaee JQz8ACCqzCYkEwI1ujQ6JA== From: Hirotaka Yamagata To: Andrew Morton Cc: linux-api@vger.kernel.org, "Liam R. Howlett" , Lorenzo Stoakes , David Hildenbrand , Chris Li , Kairui Song , Steven Rostedt , Masami Hiramatsu , Arnd Bergmann , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-arch@vger.kernel.org, cgroups@vger.kernel.org, John Stultz , Minchan Kim , Alexandre Marciano Gimenez , Tatsuyuki Ishi Subject: [RFC PATCH v1 0/4] mm: port MADV_VOLATILE and MADV_NONVOLATILE to v7.3-rc1 Date: Mon, 30 Nov 2026 17:34:03 +0900 Message-ID: <20261130083407.2669584-1-hiro@pisnp.net> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog X-Mailing-List: linux-api@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Status: clean X-Anti-Virus-Server: fsav415.rs.sakura.ne.jp This RFC series revives and modernizes the volatile ranges patchset originally proposed by John Stultz and Minchan Kim [1]. Volatile ranges allow userspace caches holding regenerable data (such as decoded image bitmaps or other private caches) to mark private anonymous memory as safe for the kernel to discard under memory pressure, bypassing swap. Such ranges are marked via madvise(MADV_VOLATILE). Before reusing the buffer, userspace calls madvise(MADV_NONVOLATILE), which unmarks the range and returns 1 if any pages in the range were purged while volatile (or 0 if all pages remained intact). Unlike MADV_FREE, which silently zero-fills dropped pages on re-access, calling MADV_NONVOLATILE before reuse gives userspace deterministic notification of whether cached data was lost without having to touch every page. If userspace instead accesses a purged page while the range is still volatile, the fault raises SIGBUS; after MADV_NONVOLATILE, the next access to it maps a zero page. Zero-filling on fault was considered, but this series chooses SIGBUS to catch missing MADV_NONVOLATILE calls and partially purged reads instead of silently seeing zeros, and to keep the optimistic read model from earlier series possible so readers can skip per-access MADV_NONVOLATILE/MADV_VOLATILE calls. Volatile pages share the regular anon LRU, so currently they are not purged when swap is disabled or full. Two alternatives were considered, but neither was satisfactory: - Keeping volatile pages on a separate LRU: changes eviction order and creates balancing issues against page cache and swap. - Keeping a linked list of volatile pages only, in addition to the anon LRU: allows scanning for volatile pages cheaply when swap is full, but making pages volatile then requires scanning, which is expensive. As a future extension, finer-grained purge reporting could avoid regenerating an entire large buffer when only part of it was purged. Within madvise(2), up to 31 bits of a positive int return value could encode a coarse mask over N equal sub-ranges; configurable granularity or an arbitrary-length bitmap would instead call for a dedicated syscall taking an output bitmap pointer (similar to mincore(2)). Key changes from the earlier v14 series [1]: - Use PTE markers (PTE_MARKER_PURGED) instead of consuming a swap type. - Defer purging in shrink_folio_list() until after checking references (immediately before folio_alloc_swap()), allowing frequently accessed volatile pages to age normally via LRU/MGLRU. - Port VMA handling to Maple Tree and modern folio APIs. - Add a PGPURGE vmstat/memcg counter and a tracepoint. This series was evaluated with Chromium patched to back discardable memory with MADV_VOLATILE/MADV_NONVOLATILE, running the multiwindow-memory-stress benchmark from chromium/web-tests (30 tabs across 5 windows alongside 4 background Chromium instances in an 8 GiB VM with 8 GiB swap). Backing decoded image caches with volatile ranges reduced the software image decode count per run by 18.0% and total software image decode time per run by 24.9% (Renderer4.ImageDecodeTaskDurationUs.Software). Under slab_nomerge, VMA-related slab overhead (vm_area_struct, anon_vma_chain, anon_vma, maple_node) was +228 KiB mean (+1.55%, ~0.003% of ~7.2 GiB total Chromium PSS) and +76 KiB peak (+0.42%). [1] https://lore.kernel.org/lkml/1398806483-19122-1-git-send-email-john.stultz@linaro.org/ ("[PATCH 0/4] Volatile Ranges (v14 - madvise reborn edition!)") Hirotaka Yamagata (4): mm: introduce VM_VOLATILE and MADV_VOLATILE/MADV_NONVOLATILE VMA handling mm: add PTE_MARKER_PURGED and TTU_PURGE for purged volatile pages mm/volatile: purge volatile anonymous folios during reclaim mm/volatile: add PGPURGE vmstat counter and purge tracepoint MAINTAINERS | 2 + fs/proc/task_mmu.c | 1 + include/linux/leafops.h | 14 ++ include/linux/mm.h | 12 + include/linux/mm_inline.h | 5 +- include/linux/mvolatile.h | 48 ++++ include/linux/rmap.h | 1 + include/linux/swapops.h | 18 +- include/linux/vm_event_item.h | 1 + include/trace/events/mmflags.h | 7 + include/trace/events/vmscan.h | 24 ++ include/uapi/asm-generic/mman-common.h | 3 + mm/Makefile | 2 +- mm/khugepaged.c | 17 ++ mm/madvise.c | 29 +++ mm/memcontrol.c | 1 + mm/memory.c | 5 + mm/mprotect.c | 6 +- mm/mseal.c | 20 ++ mm/mvolatile.c | 311 +++++++++++++++++++++++++ mm/rmap.c | 14 ++ mm/vmscan.c | 14 ++ mm/vmstat.c | 1 + 23 files changed, 550 insertions(+), 6 deletions(-) create mode 100644 include/linux/mvolatile.h create mode 100644 mm/mvolatile.c base-commit: cee9395acd8043be0644b25c34bfa86623f2b935 -- 2.56.0.611.g1030f0b940-goog