linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H . Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Vegard Nossum <vegardno@ifi.uio.no>,
	Pekka Enberg <penberg@kernel.org>,
	Christian Borntraeger <borntraeger@de.ibm.com>
Subject: Re: [PATCH] x86, mm: disable 1GB direct mapping when disabling 2MB mapping
Date: Sun, 11 Jun 2017 09:57:59 +0200	[thread overview]
Message-ID: <20170611075759.aiesval452dbgfpr@gmail.com> (raw)
In-Reply-To: <20170609135743.9920-1-vbabka@suse.cz>


* Vlastimil Babka <vbabka@suse.cz> wrote:

> The kmemleak and debug_pagealloc features both disable using huge pages for
> direct mapping so they can do cpa() on page level granularity in any context.
> However they only do that for 2MB pages, which means 1GB pages can still be
> used if the CPU supports it, unless disabled by a boot param, which is
> non-obvious. Disable also 1GB pages when disabling 2MB pages.
> 
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> ---
>  arch/x86/mm/init.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
> index cbc87ea98751..20282dfce0fa 100644
> --- a/arch/x86/mm/init.c
> +++ b/arch/x86/mm/init.c
> @@ -170,6 +170,10 @@ static void __init probe_page_size_mask(void)
>  	 */
>  	if (boot_cpu_has(X86_FEATURE_PSE) && !debug_pagealloc_enabled())
>  		page_size_mask |= 1 << PG_LEVEL_2M;
> +	else
> +		direct_gbpages = 0;
> +#else
> +	direct_gbpages = 0;
>  #endif
>  
>  	/* Enable PSE if available */

So I agree with the fix, but I think it would be much cleaner to eliminate the 
outer #ifdef:

	#if !defined(CONFIG_KMEMCHECK)

and put it into the condition, like this:

	if (boot_cpu_has(X86_FEATURE_PSE) && !debug_pagealloc_enabled() && !IS_ENABLED(CONFIG_KMEMCHECK))
		page_size_mask |= 1 << PG_LEVEL_2M;
	else
		direct_gbpages = 0;

without any #ifdeffery. This makes it much more readable all around, and also 
makes it obvious that when the 2MB size bit is not set then gbpages are disabled 
as well.

Thanks,

	Ingo

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-06-11  7:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09 13:57 [PATCH] x86, mm: disable 1GB direct mapping when disabling 2MB mapping Vlastimil Babka
2017-06-11  7:57 ` Ingo Molnar [this message]
2017-06-12  7:21   ` Vlastimil Babka

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=20170611075759.aiesval452dbgfpr@gmail.com \
    --to=mingo@kernel.org \
    --cc=borntraeger@de.ibm.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@redhat.com \
    --cc=penberg@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=vbabka@suse.cz \
    --cc=vegardno@ifi.uio.no \
    --cc=x86@kernel.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).