From patchwork Wed Nov 3 20:57:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12601609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC86BC433EF for ; Wed, 3 Nov 2021 20:57:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A137761139 for ; Wed, 3 Nov 2021 20:57:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A137761139 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3AD776B006C; Wed, 3 Nov 2021 16:57:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 36888940008; Wed, 3 Nov 2021 16:57:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FD806B0073; Wed, 3 Nov 2021 16:57:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0049.hostedemail.com [216.40.44.49]) by kanga.kvack.org (Postfix) with ESMTP id 135F66B006C for ; Wed, 3 Nov 2021 16:57:14 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B266A184AABC9 for ; Wed, 3 Nov 2021 20:57:13 +0000 (UTC) X-FDA: 78768829146.06.C81DFF4 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf22.hostedemail.com (Postfix) with ESMTP id 4FBCC1912 for ; Wed, 3 Nov 2021 20:57:13 +0000 (UTC) Received: by mail-pl1-f177.google.com with SMTP id u17so3582832plg.9 for ; Wed, 03 Nov 2021 13:57:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BFDd8LYLL9iLsk41I8B0uvCN8xqAE1pF4tRiEAvVNwE=; b=mU/lV2PDVhzl2apO/sKJObAt5f2aQJwQjF56oeVDNAVFILPaAuxYJqhe1INkvwqK4F LngVqgj0bbkDnnMIpWpgkEg0e1gJ0LjAb+Wa0Zl4FB/D1ubP7uxUhSGpeFZ/UyV3OVDE iboE6h8OZq9FAYalgtPZyloyJkImXmUB4SWh+r+uP5/FsZ736QljFfuaw+xVrDymxAB4 N/D/ZuCnmbUzIGKyGSVySnFm/d5mC3XHS9nuPl4FkifJtkOBXUSHWmxEgGxCyGGR9Dhx LaYP4R60y2USvsvPyIpAax1BhdGd55TQ7J+x2lsDtzWDTlNrIBhyOX1s8ltU2lNK8Vw1 /8Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BFDd8LYLL9iLsk41I8B0uvCN8xqAE1pF4tRiEAvVNwE=; b=4iE0Ag06GnhnSwwP2H7udUI5jTQRCJiBvDbk8iyFKRchj8dxa/sXrArp7AZvXOSjL3 tK5i1Vks5Yl1FPrsmqDSm/DT3TvbVN4UPg26w4MV05iKkMmdbSob/vpbd3LhFG2ApRZa Gnbdrp1e1KnQ8XdxBnDN4zBo++YwHvDpJNcwh+EM+o2fqoVjFRWdfQXLUuz1rGuRVL3S rSnE479Pjn7/Deg806fakDC7YYhm5mo1v7kLexYo52gfZ0+fFkYnMPTbTcPuhswOKB3o PY6GlYPjqojcuMwaXHr2hLTujPdrIB1/94nTVOfPUKZfpdBxRKU64Tp/FE5WYdjmzyQF 3E/g== X-Gm-Message-State: AOAM530LMiDBS+ssCQIcw7TqINlPMyluRQAfs2PZMukqIFn7D2do9AXP HJuplQ+RfaPmorAucJeuLK8= X-Google-Smtp-Source: ABdhPJztIqZLojbQkcG9MLb1IIhhdLW0+uR0uxDfAsAAHrYl0w4LRAN+yau1elpkYyy4Jk6iCHIbXw== X-Received: by 2002:a17:903:1c3:b0:142:3ae:5c09 with SMTP id e3-20020a17090301c300b0014203ae5c09mr14720727plh.52.1635973032210; Wed, 03 Nov 2021 13:57:12 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id b18sm2554859pjo.31.2021.11.03.13.57.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 13:57:11 -0700 (PDT) From: Florian Fainelli To: linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org, Greg Kroah-Hartman , Sasha Levin , "Kirill A. Shutemov" , Nitin Gupta , Minchan Kim , Andy Lutomirski , Borislav Petkov , Linus Torvalds , Peter Zijlstra , Sergey Senozhatsky , Thomas Gleixner , linux-mm@kvack.org, Ingo Molnar , Florian Fainelli , Vineet Gupta , Russell King , Ralf Baechle , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), Arnd Bergmann , Stefan Agner , Thomas Bogendoerfer , Mike Rapoport , linux-snps-arc@lists.infradead.org (open list:SYNOPSYS ARC ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:ARM PORT), linux-mips@linux-mips.org (open list:MIPS), linuxppc-dev@lists.ozlabs.org (open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)), linux-arch@vger.kernel.org (open list:GENERIC INCLUDE/ASM HEADER FILES) Subject: [PATCH stable 4.14 1/2] mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS Date: Wed, 3 Nov 2021 13:57:03 -0700 Message-Id: <20211103205704.374734-2-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211103205704.374734-1-f.fainelli@gmail.com> References: <20211103205704.374734-1-f.fainelli@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4FBCC1912 X-Stat-Signature: 75uqi3sh1c5hx37kakh56r63uj94hrkr Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="mU/lV2PD"; spf=pass (imf22.hostedemail.com: domain of f.fainelli@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=f.fainelli@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam02 X-HE-Tag: 1635973033-533053 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: "Kirill A. Shutemov" commit 02390b87a9459937cdb299e6b34ff33992512ec7 upstream 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 Reviewed-by: Nitin Gupta Acked-by: Minchan Kim Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Sergey Senozhatsky Cc: Thomas Gleixner Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20180214111656.88514-3-kirill.shutemov@linux.intel.com Signed-off-by: Ingo Molnar Signed-off-by: Florian Fainelli --- 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 bf6d2692fc60..2bd79b7ae9d6 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 6ed736ea9b59..633ebcac82f8 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -83,18 +83,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