* [PATCH] hibernation: clear PG_reported before saving image
@ 2026-11-30 17:02 Michael S. Tsirkin
2026-11-30 18:48 ` Rafael J. Wysocki (Intel)
0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2026-11-30 17:02 UTC (permalink / raw)
To: linux-mm
Cc: Andrea Arcangeli, Dan Williams, Dave Hansen, David Hildenbrand,
Konrad Rzeszutek Wilk, Luiz Capitulino, Matthew Wilcox,
Michal Hocko, Nitesh Narayan Lal, Oscar Salvador, Pankaj Gupta,
Paolo Bonzini, Rik van Riel, Vlastimil Babka, Wei Wang,
Yang Zhang, wei qi, Rafael J. Wysocki, Len Brown, Pavel Machek,
Mel Gorman, Andrew Morton, Alexander Duyck, linux-pm
Free buddy pages are excluded from the hibernation image, but the struct
page entries containing their PG_reported flags are saved. If
PG_reported is set, then after resume, page reporting will never report
these pages. But this is wrong: the restore kernel may have written to
these free pages while loading the image.
Clear the flag on save.
Fixes: 36e66c554b5c ("mm: introduce Reported pages")
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Nitesh Narayan Lal <nitesh@redhat.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Pankaj Gupta <pagupta@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Wei Wang <wei.w.wang@intel.com>
Cc: Yang Zhang <yang.zhang.wz@gmail.com>
Cc: wei qi <weiqi4@huawei.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
kernel/power/snapshot.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index d5dba0e50b2eb..82775e91f79c5 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -1274,6 +1274,11 @@ static void mark_free_pages(struct zone *zone)
list_for_each_entry(page, free_list, buddy_list) {
unsigned long i;
+ /*
+ * Free page contents are not preserved across hibernation.
+ */
+ __ClearPageReported(page);
+
pfn = page_to_pfn(page);
for (i = 0; i < (1UL << order); i++) {
if (!--page_count) {
--
MST
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] hibernation: clear PG_reported before saving image
2026-11-30 17:02 [PATCH] hibernation: clear PG_reported before saving image Michael S. Tsirkin
@ 2026-11-30 18:48 ` Rafael J. Wysocki (Intel)
2026-11-30 20:54 ` Michael S. Tsirkin
0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki (Intel) @ 2026-11-30 18:48 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: linux-mm, Andrea Arcangeli, Dan Williams, Dave Hansen,
David Hildenbrand, Konrad Rzeszutek Wilk, Luiz Capitulino,
Matthew Wilcox, Michal Hocko, Nitesh Narayan Lal, Oscar Salvador,
Pankaj Gupta, Paolo Bonzini, Rik van Riel, Vlastimil Babka,
Wei Wang, Yang Zhang, wei qi, Rafael J. Wysocki, Len Brown,
Pavel Machek, Mel Gorman, Andrew Morton, Alexander Duyck,
linux-pm
On Mon, Nov 30, 2026 at 6:03 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> Free buddy pages are excluded from the hibernation image, but the struct
> page entries containing their PG_reported flags are saved. If
> PG_reported is set, then after resume, page reporting will never report
> these pages. But this is wrong: the restore kernel may have written to
> these free pages while loading the image.
Why would that matter?
The image kernel will still regard those pages as free, won't it?
> Clear the flag on save.
>
> Fixes: 36e66c554b5c ("mm: introduce Reported pages")
> Cc: Andrea Arcangeli <aarcange@redhat.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Dave Hansen <dave.hansen@intel.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Luiz Capitulino <lcapitulino@redhat.com>
> Cc: Matthew Wilcox <willy@infradead.org>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: Nitesh Narayan Lal <nitesh@redhat.com>
> Cc: Oscar Salvador <osalvador@suse.de>
> Cc: Pankaj Gupta <pagupta@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Rik van Riel <riel@surriel.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: Wei Wang <wei.w.wang@intel.com>
> Cc: Yang Zhang <yang.zhang.wz@gmail.com>
> Cc: wei qi <weiqi4@huawei.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> kernel/power/snapshot.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
> index d5dba0e50b2eb..82775e91f79c5 100644
> --- a/kernel/power/snapshot.c
> +++ b/kernel/power/snapshot.c
> @@ -1274,6 +1274,11 @@ static void mark_free_pages(struct zone *zone)
> list_for_each_entry(page, free_list, buddy_list) {
> unsigned long i;
>
> + /*
> + * Free page contents are not preserved across hibernation.
> + */
> + __ClearPageReported(page);
> +
> pfn = page_to_pfn(page);
> for (i = 0; i < (1UL << order); i++) {
> if (!--page_count) {
> --
> MST
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] hibernation: clear PG_reported before saving image
2026-11-30 18:48 ` Rafael J. Wysocki (Intel)
@ 2026-11-30 20:54 ` Michael S. Tsirkin
0 siblings, 0 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2026-11-30 20:54 UTC (permalink / raw)
To: Rafael J. Wysocki (Intel)
Cc: linux-mm, Andrea Arcangeli, Dan Williams, Dave Hansen,
David Hildenbrand, Konrad Rzeszutek Wilk, Luiz Capitulino,
Matthew Wilcox, Michal Hocko, Nitesh Narayan Lal, Oscar Salvador,
Pankaj Gupta, Paolo Bonzini, Rik van Riel, Vlastimil Babka,
Wei Wang, Yang Zhang, wei qi, Len Brown, Pavel Machek, Mel Gorman,
Andrew Morton, Alexander Duyck, linux-pm
On Mon, Nov 30, 2026 at 07:48:25PM +0100, Rafael J. Wysocki (Intel) wrote:
> On Mon, Nov 30, 2026 at 6:03 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > Free buddy pages are excluded from the hibernation image, but the struct
> > page entries containing their PG_reported flags are saved. If
> > PG_reported is set, then after resume, page reporting will never report
> > these pages. But this is wrong: the restore kernel may have written to
> > these free pages while loading the image.
>
> Why would that matter?
>
> The image kernel will still regard those pages as free, won't it?
Well there's presumably a point to reporting right? Specifically, I'm
using it to free up host memory. Currently, the host will not free this
memory, and it could.
> > Clear the flag on save.
> >
> > Fixes: 36e66c554b5c ("mm: introduce Reported pages")
> > Cc: Andrea Arcangeli <aarcange@redhat.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Cc: Dave Hansen <dave.hansen@intel.com>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > Cc: Luiz Capitulino <lcapitulino@redhat.com>
> > Cc: Matthew Wilcox <willy@infradead.org>
> > Cc: Michael S. Tsirkin <mst@redhat.com>
> > Cc: Michal Hocko <mhocko@kernel.org>
> > Cc: Nitesh Narayan Lal <nitesh@redhat.com>
> > Cc: Oscar Salvador <osalvador@suse.de>
> > Cc: Pankaj Gupta <pagupta@redhat.com>
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: Rik van Riel <riel@surriel.com>
> > Cc: Vlastimil Babka <vbabka@suse.cz>
> > Cc: Wei Wang <wei.w.wang@intel.com>
> > Cc: Yang Zhang <yang.zhang.wz@gmail.com>
> > Cc: wei qi <weiqi4@huawei.com>
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> > kernel/power/snapshot.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
> > index d5dba0e50b2eb..82775e91f79c5 100644
> > --- a/kernel/power/snapshot.c
> > +++ b/kernel/power/snapshot.c
> > @@ -1274,6 +1274,11 @@ static void mark_free_pages(struct zone *zone)
> > list_for_each_entry(page, free_list, buddy_list) {
> > unsigned long i;
> >
> > + /*
> > + * Free page contents are not preserved across hibernation.
> > + */
> > + __ClearPageReported(page);
> > +
> > pfn = page_to_pfn(page);
> > for (i = 0; i < (1UL << order); i++) {
> > if (!--page_count) {
> > --
> > MST
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-30 20:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 17:02 [PATCH] hibernation: clear PG_reported before saving image Michael S. Tsirkin
2026-11-30 18:48 ` Rafael J. Wysocki (Intel)
2026-11-30 20:54 ` Michael S. Tsirkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox