From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: David Hildenbrand <david@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Memory Management List <linux-mm@kvack.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Alexander Potapenko <glider@google.com>,
Kees Cook <keescook@chromium.org>,
Michal Hocko <mhocko@kernel.org>,
Mateusz Nosek <mateusznosek0@gmail.com>,
Laura Abbott <labbott@kernel.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
Linux PM <linux-pm@vger.kernel.org>
Subject: Re: [PATCH v2 3/5] kernel/power: allow hibernation with page_poison sanity checking
Date: Thu, 12 Nov 2020 16:52:42 +0100 [thread overview]
Message-ID: <CAJZ5v0inNr=h7PsSdGgiWZO6t9nGLWagNtM=C_AnoVyw6f3m8g@mail.gmail.com> (raw)
In-Reply-To: <7811e5ec-c7ae-09a9-7f90-45e14956c4c4@suse.cz>
On Thu, Nov 12, 2020 at 3:42 PM Vlastimil Babka <vbabka@suse.cz> wrote:
>
> On 11/11/20 4:42 PM, David Hildenbrand wrote:
> ...
> >> @@ -1152,12 +1152,18 @@ void clear_free_pages(void)
> >> if (WARN_ON(!(free_pages_map)))
> >> return;
> >>
> >> - if (IS_ENABLED(CONFIG_PAGE_POISONING_ZERO) || want_init_on_free()) {
> >> + if (page_poisoning_enabled() || want_init_on_free()) {
> >> memory_bm_position_reset(bm);
> >> pfn = memory_bm_next_pfn(bm);
> >> while (pfn != BM_END_OF_MAP) {
> >> - if (pfn_valid(pfn))
> >> - clear_highpage(pfn_to_page(pfn));
> >> + if (pfn_valid(pfn)) {
> >> + struct page *page = pfn_to_page(pfn);
> >
> > ^ empty line missing. And at least I prefer to declare all variables in
> > the function header.
> >
> > I'd even suggest to move this into a separate function like
> >
> > clear_or_poison_free_page(struct page *page)
> >
> >
>
> Ok, fixup below.
>
> ----8<----
> From cae1e8ccfa57c28ed1b2f5f8a47319b86cbdcfbf Mon Sep 17 00:00:00 2001
> From: Vlastimil Babka <vbabka@suse.cz>
> Date: Thu, 12 Nov 2020 15:33:07 +0100
> Subject: [PATCH] kernel/power: allow hibernation with page_poison sanity
> checking-fix
>
> Adapt to __kernel_unpoison_pages fixup. Split out clear_or_poison_free_page()
> per David Hildenbrand.
>
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Still
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> include/linux/mm.h | 1 +
> kernel/power/snapshot.c | 18 ++++++++++--------
> 2 files changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 861b9392b5dc..d4cfb06a611e 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -2896,6 +2896,7 @@ static inline void kernel_unpoison_pages(struct page *page, int numpages)
> #else
> static inline bool page_poisoning_enabled(void) { return false; }
> static inline bool page_poisoning_enabled_static(void) { return false; }
> +static inline void __kernel_poison_pages(struct page *page, int nunmpages) { }
> static inline void kernel_poison_pages(struct page *page, int numpages) { }
> static inline void kernel_unpoison_pages(struct page *page, int numpages) { }
> #endif
> diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
> index 6b1c84afa891..a3491b29c5cc 100644
> --- a/kernel/power/snapshot.c
> +++ b/kernel/power/snapshot.c
> @@ -1144,6 +1144,14 @@ void free_basic_memory_bitmaps(void)
> pr_debug("Basic memory bitmaps freed\n");
> }
>
> +static void clear_or_poison_free_page(struct page *page)
> +{
> + if (page_poisoning_enabled_static())
> + __kernel_poison_pages(page, 1);
> + else if (want_init_on_free())
> + clear_highpage(page);
> +}
> +
> void clear_or_poison_free_pages(void)
> {
> struct memory_bitmap *bm = free_pages_map;
> @@ -1156,14 +1164,8 @@ void clear_or_poison_free_pages(void)
> memory_bm_position_reset(bm);
> pfn = memory_bm_next_pfn(bm);
> while (pfn != BM_END_OF_MAP) {
> - if (pfn_valid(pfn)) {
> - struct page *page = pfn_to_page(pfn);
> - if (page_poisoning_enabled_static())
> - kernel_poison_pages(page, 1);
> - else if (want_init_on_free())
> - clear_highpage(page);
> -
> - }
> + if (pfn_valid(pfn))
> + clear_or_poison_free_page(pfn_to_page(pfn));
>
> pfn = memory_bm_next_pfn(bm);
> }
> --
> 2.29.1
>
>
next prev parent reply other threads:[~2020-11-12 15:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 15:22 [PATCH v2 0/5] cleanup page poisoning Vlastimil Babka
2020-11-03 15:22 ` [PATCH v2 1/5] mm, page_alloc: do not rely on the order of page_poison and init_on_alloc/free parameters Vlastimil Babka
2020-11-03 15:22 ` [PATCH v2 2/5] mm, page_poison: use static key more efficiently Vlastimil Babka
2020-11-11 15:38 ` David Hildenbrand
2020-11-12 14:37 ` Vlastimil Babka
2020-11-12 16:06 ` David Hildenbrand
2020-11-03 15:22 ` [PATCH v2 3/5] kernel/power: allow hibernation with page_poison sanity checking Vlastimil Babka
2020-11-05 18:36 ` Rafael J. Wysocki
2020-11-11 15:42 ` David Hildenbrand
2020-11-12 14:39 ` Vlastimil Babka
2020-11-12 15:52 ` Rafael J. Wysocki [this message]
2020-11-12 16:07 ` David Hildenbrand
2020-11-03 15:22 ` [PATCH v2 4/5] mm, page_poison: remove CONFIG_PAGE_POISONING_NO_SANITY Vlastimil Babka
2020-11-11 15:43 ` David Hildenbrand
2020-11-03 15:22 ` [PATCH v2 5/5] mm, page_poison: remove CONFIG_PAGE_POISONING_ZERO Vlastimil Babka
2020-11-11 15:45 ` David Hildenbrand
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='CAJZ5v0inNr=h7PsSdGgiWZO6t9nGLWagNtM=C_AnoVyw6f3m8g@mail.gmail.com' \
--to=rafael@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=glider@google.com \
--cc=keescook@chromium.org \
--cc=labbott@kernel.org \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pm@vger.kernel.org \
--cc=mateusznosek0@gmail.com \
--cc=mhocko@kernel.org \
--cc=pavel@ucw.cz \
--cc=rjw@rjwysocki.net \
--cc=vbabka@suse.cz \
/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