From: Mike Rapoport <rppt@kernel.org>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Alexander Potapenko <glider@google.com>,
Kees Cook <keescook@chromium.org>,
Michal Hocko <mhocko@kernel.org>,
David Hildenbrand <david@redhat.com>,
Mateusz Nosek <mateusznosek0@gmail.com>
Subject: Re: [PATCH 1/3] mm, page_alloc: do not rely on the order of page_poison and init_on_alloc/free parameters
Date: Wed, 28 Oct 2020 10:31:12 +0200 [thread overview]
Message-ID: <20201028083112.GA1428094@kernel.org> (raw)
In-Reply-To: <20201026173358.14704-2-vbabka@suse.cz>
On Mon, Oct 26, 2020 at 06:33:56PM +0100, Vlastimil Babka wrote:
> Enabling page_poison=1 together with init_on_alloc=1 or init_on_free=1 produces
> a warning in dmesg that page_poison takes precendence. However, as these
^ precedence
> warnings are printed in early_param handlers for init_on_alloc/free, they are
> not printed if page_poison is enabled later on the command line (handlers are
> called in the order of their parameters), or when init_on_alloc/free is always
> enabled by the respective config option - before the page_poison early param
> handler is called, it is not considered to be enabled. This is inconsistent.
>
> We can remove the dependency on order by making the init_on_* parameters only
> set a boolean variable, and postponing the evaluation after all early params
> have been processed. Introduce a new init_mem_debugging() function for that,
> and move the related debug_pagealloc processing there as well.
>
> As a result init_mem_debugging() knows always accurately if init_on_* and/or
> page_poison options were enabled. Thus we can also optimize want_init_on_alloc()
> and want_init_on_free(). We don't need to check page_poisoning_enabled() there,
> we can instead not enable the init_on_* tracepoint at all, if page poisoning is
> enabled. This results in a simpler and more effective code.
>
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
With two more nits below fixed
Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
> ---
> include/linux/mm.h | 20 ++--------
> init/main.c | 2 +-
> mm/page_alloc.c | 94 +++++++++++++++++++++++-----------------------
> 3 files changed, 50 insertions(+), 66 deletions(-)
>
...
> @@ -792,6 +752,44 @@ static inline void clear_page_guard(struct zone *zone, struct page *page,
> unsigned int order, int migratetype) {}
> #endif
>
> +/*
> + * Enable static keys related to various memory debugging and hardening options.
> + * Some override others, and depend on early params that are evaluated in the
> + * order of appearance. So we need to first gather the full picture of what was
> + * enabled, and then make decisions.
> + */
> +void init_mem_debugging()
Shouldn't it be init_mem_debug(void)?
Or whatever a new name would be :)
> +{
> + if (_init_on_alloc_enabled_early) {
> + if (page_poisoning_enabled()) {
> + pr_info("mem auto-init: CONFIG_PAGE_POISONING is on, "
> + "will take precedence over init_on_alloc\n");
> + } else {
> + static_branch_enable(&init_on_alloc);
> + }
> + }
> + if (_init_on_free_enabled_early) {
> + if (page_poisoning_enabled()) {
> + pr_info("mem auto-init: CONFIG_PAGE_POISONING is on, "
> + "will take precedence over init_on_free\n");
> + } else {
> + static_branch_enable(&init_on_free);
> + }
> + }
I think the braces for the inner ifs are not required.
> +
> +#ifdef CONFIG_DEBUG_PAGEALLOC
> + if (!debug_pagealloc_enabled())
> + return;
> +
> + static_branch_enable(&_debug_pagealloc_enabled);
> +
> + if (!debug_guardpage_minorder())
> + return;
> +
> + static_branch_enable(&_debug_guardpage_enabled);
> +#endif
> +}
> +
> static inline void set_buddy_order(struct page *page, unsigned int order)
> {
> set_page_private(page, order);
> --
> 2.29.0
>
>
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2020-10-28 8:31 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-26 17:33 [PATCH 0/3] optimize handling of memory debugging parameters Vlastimil Babka
2020-10-26 17:33 ` [PATCH 1/3] mm, page_alloc: do not rely on the order of page_poison and init_on_alloc/free parameters Vlastimil Babka
2020-10-27 9:03 ` David Hildenbrand
2020-10-27 9:58 ` Vlastimil Babka
2020-10-27 9:58 ` David Hildenbrand
2020-10-28 8:31 ` Mike Rapoport [this message]
2020-10-26 17:33 ` [PATCH 2/3] mm, page_poison: use static key more efficiently Vlastimil Babka
2020-10-27 9:07 ` David Hildenbrand
2020-10-30 16:27 ` Luis Chamberlain
2020-10-30 22:56 ` Vlastimil Babka
2020-11-11 13:29 ` Luis Chamberlain
2020-10-26 17:33 ` [PATCH 3/3] mm, page_alloc: reduce static keys in prep_new_page() Vlastimil Babka
2020-10-27 9:10 ` David Hildenbrand
2020-10-27 11:05 ` Vlastimil Babka
2020-10-27 13:32 ` Vlastimil Babka
2020-10-27 17:41 ` Vlastimil Babka
2020-10-28 8:38 ` David Hildenbrand
2020-10-29 17:37 ` Alexander Potapenko
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=20201028083112.GA1428094@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=glider@google.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mateusznosek0@gmail.com \
--cc=mhocko@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.