Received: by 10.223.185.116 with SMTP id b49csp549196wrg; Wed, 14 Feb 2018 03:18:51 -0800 (PST) X-Google-Smtp-Source: AH8x227pWS1ZmB3c4eGpLXXqGplOfGZYbcFJ+O1RhNqZRiX/1jY4Eg1icvt0LsOnjfuRmYj/ainK X-Received: by 10.101.78.1 with SMTP id r1mr3697645pgt.322.1518607130984; Wed, 14 Feb 2018 03:18:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518607130; cv=none; d=google.com; s=arc-20160816; b=XtjnuFQCZTX+tRWOqNDDE6WZi05ZnU8zp12pXq/DfQVkXqkOXZoV2X4iGvGwNV2+Vv lrCV51ztyycBpSZ1UytTenDW+NZeU13cQofJ4sXORfPL9mcudeUVS0QYscKE+W7RkhE5 0+eQNM/Gbqi5BP+x4RUHoBleNN+o4hbf/K6DqgQbOB5soUDKnKOMWC53ofqkX/ILIVqR GrtBqz8bLBjPivTQN2luwcEas2+jODf1rEsMZoYHTxKjWueF2MzlGStGaLX4qFMVGyzQ DcMFg8yjvx5Ks4T0N7TKrjm9tZX9Y/gPXh42OjgzsYbruIlWdHlOckLajSdQaIqHF4Nz y4AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=OffpI5HiA1igLL+vKuDc1MqFRTx8pttDEEFX0YpZz0U=; b=ELH6Z7nUOsqyH7HfO4hY5N0Gz4qmdkgvsEVAEQePB4kRiLlqr19kuPg50NXpLVdGCO FbcX8Ilky3Tn+BrhoVJ7DFxlDrjq9dwFLRJBtWf6DmVl0xCEhX1BugXlL5/0E8ueWJiE 4oDhAgghyzg2qmdDeD049mISyDKp+6N9TkW4eSXBGGDtE0jk+/5OLamS6YZ41sXS9Ygz zeN6cPPgXE0qTs55RbrtZYP0OVpbDERRJ9gtm4S12VWhbrFmUFv/o83VaC0rasUdqXQ/ imixpYAPAvarqv2o4Nj3tVo0Ef5n2xu6d61Pvt2MsHlwOIOyF7BcRYYRMWz4jx9zD959 i9Zg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k8-v6si2671631plt.293.2018.02.14.03.18.36; Wed, 14 Feb 2018 03:18:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967421AbeBNLRR (ORCPT + 99 others); Wed, 14 Feb 2018 06:17:17 -0500 Received: from mga11.intel.com ([192.55.52.93]:37976 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967375AbeBNLRN (ORCPT ); Wed, 14 Feb 2018 06:17:13 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2018 03:17:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,512,1511856000"; d="scan'208";a="201054938" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 14 Feb 2018 03:17:09 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 5AE62159; Wed, 14 Feb 2018 13:17:08 +0200 (EET) From: "Kirill A. Shutemov" To: Ingo Molnar , x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" Cc: Linus Torvalds , Andy Lutomirski , Borislav Petkov , Andi Kleen , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , Sergey Senozhatsky Subject: [PATCH 2/9] mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS Date: Wed, 14 Feb 2018 14:16:49 +0300 Message-Id: <20180214111656.88514-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180214111656.88514-1-kirill.shutemov@linux.intel.com> References: <20180214111656.88514-1-kirill.shutemov@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With boot-time switching between paging mode we will have variable MAX_PHYSMEM_BITS. Let's use the maximum variable possible for CONFIG_X86_5LEVEL=y configuration to define zsmalloc data structures. The patch introduces MAX_POSSIBLE_PHYSMEM_BITS to cover such case. It also suits well to handle PAE special case. Signed-off-by: Kirill A. Shutemov Acked-by: Minchan Kim Reviewed-by: Nitin Gupta Cc: Sergey Senozhatsky --- arch/x86/include/asm/pgtable-3level_types.h | 1 + arch/x86/include/asm/pgtable_64_types.h | 2 ++ mm/zsmalloc.c | 13 +++++++------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/pgtable-3level_types.h b/arch/x86/include/asm/pgtable-3level_types.h index 876b4c77d983..6a59a6d0cc50 100644 --- a/arch/x86/include/asm/pgtable-3level_types.h +++ b/arch/x86/include/asm/pgtable-3level_types.h @@ -44,5 +44,6 @@ typedef union { */ #define PTRS_PER_PTE 512 +#define MAX_POSSIBLE_PHYSMEM_BITS 36 #endif /* _ASM_X86_PGTABLE_3LEVEL_DEFS_H */ diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h index 6b8f73dcbc2c..7168de7d34eb 100644 --- a/arch/x86/include/asm/pgtable_64_types.h +++ b/arch/x86/include/asm/pgtable_64_types.h @@ -40,6 +40,8 @@ typedef struct { pteval_t pte; } pte_t; #define P4D_SIZE (_AC(1, UL) << P4D_SHIFT) #define P4D_MASK (~(P4D_SIZE - 1)) +#define MAX_POSSIBLE_PHYSMEM_BITS 52 + #else /* CONFIG_X86_5LEVEL */ /* diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index c3013505c305..b7f61cd1c709 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -84,18 +84,19 @@ * This is made more complicated by various memory models and PAE. */ -#ifndef MAX_PHYSMEM_BITS -#ifdef CONFIG_HIGHMEM64G -#define MAX_PHYSMEM_BITS 36 -#else /* !CONFIG_HIGHMEM64G */ +#ifndef MAX_POSSIBLE_PHYSMEM_BITS +#ifdef MAX_PHYSMEM_BITS +#define MAX_POSSIBLE_PHYSMEM_BITS MAX_PHYSMEM_BITS +#else /* * If this definition of MAX_PHYSMEM_BITS is used, OBJ_INDEX_BITS will just * be PAGE_SHIFT */ -#define MAX_PHYSMEM_BITS BITS_PER_LONG +#define MAX_POSSIBLE_PHYSMEM_BITS BITS_PER_LONG #endif #endif -#define _PFN_BITS (MAX_PHYSMEM_BITS - PAGE_SHIFT) + +#define _PFN_BITS (MAX_POSSIBLE_PHYSMEM_BITS - PAGE_SHIFT) /* * Memory for allocating for handle keeps object position by -- 2.15.1