Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4120310pxb; Tue, 10 Nov 2020 08:24:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxu7StB9lC4e2wo8pa36MWmI2R8gjZ+GqUp1DmmaYfpnMntG8DZEaC3zTfmiOLDmkopAC+Y X-Received: by 2002:a17:906:6b82:: with SMTP id l2mr20318988ejr.241.1605025456713; Tue, 10 Nov 2020 08:24:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605025456; cv=none; d=google.com; s=arc-20160816; b=Rqu7AIE4mO3wCo05SGt5cWwBaZEW6oo/QOJPQ8SAaf9Fv+6H0KVjve7Ju4hnkGqoYd tfQZfKInlgBIROAD9JcROAmEMQYJtIlffUcRxCiYXbm8r7ZtrV/pvLzFNLZ77Io7i2sf MfFY7mEKCRGqoZK2oA+A/0WNtkxgvJ/tAofRAbf1bBjCDHxY5OsjzjHF/peiUVwKkGdu e84dDkBL/P69abI7tf7+h3OfIiZKQ1Mo5uaK230CPxNhqZeN8CgsUkYDPcL0TvZeEEIo a7fA3QfXzIJOi3I98Br74tlyYSe4jDnhk2pfA39AHCimwgztxOpODi3oCl92HmCmAskZ RfMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KMxTrhJgnM6tNZwRqTvtkti6rn5UkOW3lvy982jKDcI=; b=expwxbR8FsCWwQSFOIHeWZ9v4orJzjbSsE2su3E59e99ZOkTlP0MMTtB3b8AiRQcUb pA8/9OZ361xLbSeVZ1CgSjx3y2HYCGjMd5Cgg50OWOF3FPZfJWh0MguI7cImYFsRC8gE PU8FzDJHZ3boQ+rxGycOO831BJqQz/NAhQ64M/OxK/3TMQLuXqHNZsuuAb4wD7NWjvNq 7Cz4FIS13ZZ9+LhPH44HuWCWV06finKOCL57k2Y1oPOoCa4tqI80iOvXAhtf0SSSS/SS C3QzLjpQVbR6QcPwubmL+1d/SNBUjBVr7CXvRdiSI/t5Ve4dHdk7qsWLFh1dk44d9xro YMvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kb3zIebj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bd6si2179902edb.284.2020.11.10.08.23.49; Tue, 10 Nov 2020 08:24:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kb3zIebj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729674AbgKJQWD (ORCPT + 99 others); Tue, 10 Nov 2020 11:22:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:50826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728975AbgKJQWD (ORCPT ); Tue, 10 Nov 2020 11:22:03 -0500 Received: from kernel.org (unknown [77.125.7.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2B12E20780; Tue, 10 Nov 2020 16:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605025322; bh=S7fPKbnOBa681jEtV41yEhcDtYpsejk92mutLM74Y1E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Kb3zIebjdGichNbUVFjcQ0NMGWcRwoou8zfvC3rq/TQp9mk97GghtvDN0mRB6mHQh pOu3tQl1ue9WpYZeDkGj6cVI89g2bxa6EyVLlHOyKdhs68qFLYlp9UT6L121fo4x2S pTn2EiXJopoi7q2BWPqJfLfHRWMRyy7ppcR7kS9Y= Date: Tue, 10 Nov 2020 18:21:55 +0200 From: Mike Rapoport To: Arnd Bergmann Cc: Stefan Agner , Minchan Kim , ngupta@vflare.org, Sergey Senozhatsky , Andrew Morton , sjenning@linux.vnet.ibm.com, gregkh , Arnd Bergmann , Linux-MM , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] mm/zsmalloc: include sparsemem.h for MAX_PHYSMEM_BITS Message-ID: <20201110162155.GA4758@kernel.org> References: <20201108064659.GD301837@kernel.org> <7782fb694a6b0c500e8f32ecf895b2bf@agner.ch> <20201110095806.GH301837@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 10, 2020 at 12:21:11PM +0100, Arnd Bergmann wrote: > On Tue, Nov 10, 2020 at 10:58 AM Mike Rapoport wrote: > > > > > > > > asm/sparsemem.h is not available on some architectures. > > > > It's better to use linux/mmzone.h instead. > > Ah, I missed that, too. > > > > Hm, linux/mmzone.h only includes asm/sparsemem.h when CONFIG_SPARSEMEM > > > is enabled. However, on ARM at least I can have configurations without > > > CONFIG_SPARSEMEM and physical address extension on (e.g. > > > multi_v7_defconfig + CONFIG_LPAE + CONFIG_ZSMALLOC). > > > > > > While sparsemem seems to be a good idea with LPAE it really seems not > > > required (see also https://lore.kernel.org/patchwork/patch/567589/). > > > > > > There seem to be also other architectures which define MAX_PHYSMEM_BITS > > > only when SPARSEMEM is enabled, e.g. > > > arch/riscv/include/asm/sparsemem.h... > > > > > > Not sure how to get out of this.. Maybe make ZSMALLOC dependent on > > > SPARSEMEM? It feels a bit silly restricting ZSMALLOC selection only due > > > to a compile time define... > > > > I think we can define MAX_POSSIBLE_PHYSMEM_BITS in one of > > arch/arm/inclide/asm/pgtable-{2,3}level-*.h headers to values supported > > by !LPAE and LPAE. > > Good idea. I wonder what other architectures need the same though. > Here are some I found: > > $ git grep -l PHYS_ADDR_T_64BIT arch | grep Kconfig > arch/arc/Kconfig > arch/arm/mm/Kconfig > arch/mips/Kconfig > arch/powerpc/platforms/Kconfig.cputype > arch/x86/Kconfig > > arch/arc has a CONFIG_ARC_HAS_PAE40 option > arch/riscv has 34-bit addressing in rv32 mode > arch/mips has up to 40 bits with mips32r3 XPA, but I don't know what > supports that > > arch/powerpc has this: > config PHYS_64BIT > bool 'Large physical address support' if E500 || PPC_86xx > depends on (44x || E500 || PPC_86xx) && !PPC_83xx && !PPC_82xx > > Apparently all three (4xx, e500v2, mpc86xx/e600) do 36-bit physical > addressing, but each one has a different page table format. > > Microblaze has physical address extensions, but neither those nor > 64-bit mode have so far made it into the kernel. > > To be on the safe side, we could provoke a compile-time error > when CONFIG_PHYS_ADDR_T_64BIT is set on a 32-bit > architecture, but MAX_POSSIBLE_PHYSMEM_BITS is not set. Maybe compile time warning and a runtime error in zs_init() if 32 bit machine has memory above 4G? > > That's what x86 does: > > > > $ git grep -w MAX_POSSIBLE_PHYSMEM_BITS arch/ > > arch/x86/include/asm/pgtable-3level_types.h:#define MAX_POSSIBLE_PHYSMEM_BITS 36 > > Doesn't x86 also support a 40-bit addressing mode? I suppose > those machines that actually used it are long gone. > > > arch/x86/include/asm/pgtable_64_types.h:#define MAX_POSSIBLE_PHYSMEM_BITS 52 > > > > It seems that actual numbers would be 36 for !LPAE and 40 for LPAE, but > > I'm not sure about that. > > Close enough, yes. > > The 36-bit addressing is on !LPAE is only used for early static mappings, > so I think we can pretend it's always 32-bit. I checked the ARMv8 reference, > and it says that ARMv8-Aarch32 actually supports 40 bit physical addressing > both with non-LPAE superpages (short descriptor format) and LPAE (long > descriptor format), but Linux only does 36-bit addressing on superpages > as specified for ARMv6/ARMv7 short descriptors. > > Arnd -- Sincerely yours, Mike.