From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752368AbdFLHVd (ORCPT ); Mon, 12 Jun 2017 03:21:33 -0400 Received: from mx2.suse.de ([195.135.220.15]:43791 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752269AbdFLHVc (ORCPT ); Mon, 12 Jun 2017 03:21:32 -0400 Subject: Re: [PATCH] x86, mm: disable 1GB direct mapping when disabling 2MB mapping To: Ingo Molnar Cc: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vegard Nossum , Pekka Enberg , Christian Borntraeger References: <20170609135743.9920-1-vbabka@suse.cz> <20170611075759.aiesval452dbgfpr@gmail.com> From: Vlastimil Babka Message-ID: <2be70c78-6130-855d-3dfa-d87bd1dd4fda@suse.cz> Date: Mon, 12 Jun 2017 09:21:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20170611075759.aiesval452dbgfpr@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/11/2017 09:57 AM, Ingo Molnar wrote: > 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)) Right, that's better, thanks. ----8<---- From: Vlastimil Babka Date: Fri, 9 Jun 2017 15:41:22 +0200 Subject: [PATCH v2] x86, mm: disable 1GB direct mapping when disabling 2MB mapping 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 --- arch/x86/mm/init.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index cbc87ea98751..b11afaf04c9d 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -161,16 +161,17 @@ static int page_size_mask; static void __init probe_page_size_mask(void) { -#if !defined(CONFIG_KMEMCHECK) /* * For CONFIG_KMEMCHECK or pagealloc debugging, identity mapping will * use small pages. * This will simplify cpa(), which otherwise needs to support splitting * large pages into small in interrupt context, etc. */ - if (boot_cpu_has(X86_FEATURE_PSE) && !debug_pagealloc_enabled()) + if (boot_cpu_has(X86_FEATURE_PSE) && !debug_pagealloc_enabled() && + !IS_ENABLED(CONFIG_KMEMCHECK)) page_size_mask |= 1 << PG_LEVEL_2M; -#endif + else + direct_gbpages = 0; /* Enable PSE if available */ if (boot_cpu_has(X86_FEATURE_PSE)) -- 2.13.1