linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Luiz Capitulino <luizcap@redhat.com>
Cc: david@redhat.com, willy@infradead.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	lcapitulino@gmail.com, shivankg@amd.com
Subject: Re: [PATCH 1/3] mm: introduce snapshot_page()
Date: Thu, 26 Jun 2025 14:39:29 -0700	[thread overview]
Message-ID: <20250626143929.a7f2bcbb8e90290f23af452e@linux-foundation.org> (raw)
In-Reply-To: <4a9745dd2989f7d5bf5bc69c37fc3e3cfda37e87.1750961812.git.luizcap@redhat.com>

On Thu, 26 Jun 2025 14:16:51 -0400 Luiz Capitulino <luizcap@redhat.com> wrote:

> This commit refactors __dump_page() into snapshot_page().
> 
> snapshot_page() tries to take a faithful snapshot of a page and its
> folio representation. The snapshot is returned in the struct
> page_snapshot parameter along with additional flags that are best
> retrieved at snapshot creation time to reduce race windows.
> 
> This function is intended to be used by callers that need a stable
> representation of a struct page and struct folio so that pointers
> or page information doesn't change while working on a page.
> 
> The idea and original implemenetation of snapshot_page() comes from

tpyo!

> Matthew Wilcox with suggestions for improvements from David Hildenbrand.
> All bugs and misconceptions are mine.
>
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -4184,4 +4184,24 @@ static inline bool page_pool_page_is_pp(struct page *page)
>  }
>  #endif
>  
> +#define PAGE_SNAPSHOT_FAITHFUL     (1 << 0)
> +#define PAGE_SNAPSHOT_PG_HUGE_ZERO (1 << 1)
> +#define PAGE_SNAPSHOT_PG_FREE      (1 << 2)
> +#define PAGE_SNAPSHOT_PG_IDLE      (1 << 3)
> +
> +struct page_snapshot {
> +	struct folio folio_snapshot;
> +	struct page page_snapshot;
> +	unsigned long pfn;
> +	unsigned long idx;
> +	unsigned long flags;
> +};
> +
> +static inline bool snapshot_page_is_faithful(const struct page_snapshot *ps)
> +{
> +	return ps->flags & 0x1;'

	& PAGE_SNAPSHOT_FAITHFUL?

> +}
> +

All looks sane to me.  Small-system people (are there any left?) might
point out that all the new code could be under ifdef CONFIG_PROCFS?

I'll skip v1, see what reviewers have to say, thanks.


  reply	other threads:[~2025-06-26 21:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-26 18:16 [PATCH 0/3] mm: introduce snapshot_page() Luiz Capitulino
2025-06-26 18:16 ` [PATCH 1/3] " Luiz Capitulino
2025-06-26 21:39   ` Andrew Morton [this message]
2025-06-26 21:42     ` Luiz Capitulino
2025-06-26 18:16 ` [PATCH 2/3] proc: kpagecount: use snapshot_page() Luiz Capitulino
2025-06-27 18:30   ` SeongJae Park
2025-07-01 18:36   ` David Hildenbrand
2025-07-02  6:25   ` Shivank Garg
2025-07-02 17:38     ` Luiz Capitulino
2025-06-26 18:16 ` [PATCH 3/3] fs: stable_page_flags(): " Luiz Capitulino
2025-07-01 18:44   ` David Hildenbrand
2025-07-02 17:36     ` Luiz Capitulino
2025-07-02  6:40 ` [PATCH 0/3] mm: introduce snapshot_page() Shivank Garg
2025-07-02 17:39   ` Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250626143929.a7f2bcbb8e90290f23af452e@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=lcapitulino@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luizcap@redhat.com \
    --cc=shivankg@amd.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).