[PATCH v3 0/4] mm: introduce snapshot_page()

Luiz Capitulino posted 4 patches 2 months, 3 weeks ago
fs/proc/page.c          | 50 +++++++++++++++-----------
include/linux/huge_mm.h | 12 ++++++-
include/linux/mm.h      | 19 ++++++++++
mm/debug.c              | 42 +++-------------------
mm/memory.c             |  2 +-
mm/util.c               | 79 +++++++++++++++++++++++++++++++++++++++++
6 files changed, 144 insertions(+), 60 deletions(-)
[PATCH v3 0/4] mm: introduce snapshot_page()
Posted by Luiz Capitulino 2 months, 3 weeks ago
Hi,

The series introduction will follow the changelog. This is against bc9ff192a6c9 .

Changelog
=========

v2 -> v3
  - Small snapshot_page() refactor to simplify and fix stack-out-of-bugs bug
    reported by Harry Yoo
  - Use clear_compound_head() in snapshot_page() (Shivank)
  - Read head pointer from ps->page_snapshot() for tail page case (Shivank)
  - Improve comments and macro name in snapshot_page() (David)

v1 -> v2
  - Include is_huge_zero_pfn() patch and use it (David)
  - Move free page detection to snapshot_page() (David)
  - Changelog improvements (Shivank)
  - Added Acked-bys

RFC -> v1
  - Include <linux/page_idle.h> to avoid build error on sh arch

Introduction
============

This series introduces snapshot_page(), a helper function that can be used
to create a snapshot of a struct page and its associated struct folio.

This function is intended to help callers with a consistent view of a
a folio while reducing the chance of encountering partially updated or
inconsistent state, such as during folio splitting which could lead to
crashes and BUG_ON()s being triggered.

David Hildenbrand (1):
  mm/memory: introduce is_huge_zero_pfn() and use it in
    vm_normal_page_pmd()

Luiz Capitulino (3):
  mm/util: introduce snapshot_page()
  proc: kpagecount: use snapshot_page()
  fs: stable_page_flags(): use snapshot_page()

 fs/proc/page.c          | 50 +++++++++++++++-----------
 include/linux/huge_mm.h | 12 ++++++-
 include/linux/mm.h      | 19 ++++++++++
 mm/debug.c              | 42 +++-------------------
 mm/memory.c             |  2 +-
 mm/util.c               | 79 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 144 insertions(+), 60 deletions(-)

-- 
2.50.0
Re: [PATCH v3 0/4] mm: introduce snapshot_page()
Posted by Harry Yoo 2 months, 3 weeks ago
On Mon, Jul 14, 2025 at 09:16:50AM -0400, Luiz Capitulino wrote:
> Hi,
> 
> The series introduction will follow the changelog. This is against bc9ff192a6c9 .
> 
> Changelog
> =========
> 
> v2 -> v3
>   - Small snapshot_page() refactor to simplify and fix stack-out-of-bugs bug
>     reported by Harry Yoo
>   - Use clear_compound_head() in snapshot_page() (Shivank)
>   - Read head pointer from ps->page_snapshot() for tail page case (Shivank)
>   - Improve comments and macro name in snapshot_page() (David)
> 
> v1 -> v2
>   - Include is_huge_zero_pfn() patch and use it (David)
>   - Move free page detection to snapshot_page() (David)
>   - Changelog improvements (Shivank)
>   - Added Acked-bys
> 
> RFC -> v1
>   - Include <linux/page_idle.h> to avoid build error on sh arch
> 
> Introduction
> ============
> 
> This series introduces snapshot_page(), a helper function that can be used
> to create a snapshot of a struct page and its associated struct folio.
> 
> This function is intended to help callers with a consistent view of a
> a folio while reducing the chance of encountering partially updated or
> inconsistent state, such as during folio splitting which could lead to
> crashes and BUG_ON()s being triggered.
> 
> David Hildenbrand (1):
>   mm/memory: introduce is_huge_zero_pfn() and use it in
>     vm_normal_page_pmd()
> 
> Luiz Capitulino (3):
>   mm/util: introduce snapshot_page()
>   proc: kpagecount: use snapshot_page()
>   fs: stable_page_flags(): use snapshot_page()
> 
>  fs/proc/page.c          | 50 +++++++++++++++-----------
>  include/linux/huge_mm.h | 12 ++++++-
>  include/linux/mm.h      | 19 ++++++++++
>  mm/debug.c              | 42 +++-------------------
>  mm/memory.c             |  2 +-
>  mm/util.c               | 79 +++++++++++++++++++++++++++++++++++++++++
>  6 files changed, 144 insertions(+), 60 deletions(-)
> 
> --

Haha, I was waiting for this!

The previously reported KASAN splats have completely disappeared on my
testbed.

Please feel free to add,
Tested-by: Harry Yoo <harry.yoo@oracle.com>

-- 
Cheers,
Harry / Hyeonggon
Re: [PATCH v3 0/4] mm: introduce snapshot_page()
Posted by Shivank Garg 2 months, 3 weeks ago

On 7/14/2025 6:46 PM, Luiz Capitulino wrote:
> Hi,
> 
> The series introduction will follow the changelog. This is against bc9ff192a6c9 .
> 
> Changelog
> =========
> 
> v2 -> v3
>   - Small snapshot_page() refactor to simplify and fix stack-out-of-bugs bug
>     reported by Harry Yoo
>   - Use clear_compound_head() in snapshot_page() (Shivank)
>   - Read head pointer from ps->page_snapshot() for tail page case (Shivank)
>   - Improve comments and macro name in snapshot_page() (David)
> 
> v1 -> v2
>   - Include is_huge_zero_pfn() patch and use it (David)
>   - Move free page detection to snapshot_page() (David)
>   - Changelog improvements (Shivank)
>   - Added Acked-bys
> 
> RFC -> v1
>   - Include <linux/page_idle.h> to avoid build error on sh arch
> 
> Introduction
> ============
> 
> This series introduces snapshot_page(), a helper function that can be used
> to create a snapshot of a struct page and its associated struct folio.
> 
> This function is intended to help callers with a consistent view of a
> a folio while reducing the chance of encountering partially updated or
> inconsistent state, such as during folio splitting which could lead to
> crashes and BUG_ON()s being triggered.
> 
> David Hildenbrand (1):
>   mm/memory: introduce is_huge_zero_pfn() and use it in
>     vm_normal_page_pmd()
> 
> Luiz Capitulino (3):
>   mm/util: introduce snapshot_page()
>   proc: kpagecount: use snapshot_page()
>   fs: stable_page_flags(): use snapshot_page()
> 
>  fs/proc/page.c          | 50 +++++++++++++++-----------
>  include/linux/huge_mm.h | 12 ++++++-
>  include/linux/mm.h      | 19 ++++++++++
>  mm/debug.c              | 42 +++-------------------
>  mm/memory.c             |  2 +-
>  mm/util.c               | 79 +++++++++++++++++++++++++++++++++++++++++
>  6 files changed, 144 insertions(+), 60 deletions(-)
> 

The changes look good to me.
Thanks for addressing the feedback.

Reviewed-by: Shivank Garg <shivankg@amd.com>