Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp497652imu; Thu, 8 Nov 2018 11:14:29 -0800 (PST) X-Google-Smtp-Source: AJdET5fOBDIstk8ML2/dWDlsOB72AByi2lkL1ieStl7gmypyST14u/gatkumn02H5RyiXkLEKRxU X-Received: by 2002:a63:ae01:: with SMTP id q1mr4707717pgf.402.1541704469202; Thu, 08 Nov 2018 11:14:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541704469; cv=none; d=google.com; s=arc-20160816; b=iZIHy93dWkKQ4+SZizV1IZJyKCfArs8FURZT9Feqbkl/Ltz/RHQcir1bnFPL0D+JFX TKxXxE+OwIY4adV/UbufbP1OaNckT1e02cbbKVUZ5YljjWstEc2/zU6ccy1vZaSxPg6J kSTm0kee12QfVPXgJHjg12FNNFYamkb8hiYIXMEaUVQ3CbayStIufgsiZAyYlzL+GNQM Tu6X2Lq5HDjzhkE51W8XF72Ve77ZwXgKfnUa1sKxO9244bLT3EDez4lobkUPyb2prosA jhns/8w2z8DNLn+bAyfm6zgtPHFSmj04NduGqAspOJmpAelHKW2MogzdWLM627dC8Zys 5u4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=9pqgH5iPyY9JT34F1WXkxY6gvLmgbkxVD023KV58pqA=; b=QM1Hb5Ru/OpT/6fqLWyFZLPmb16LFurvy1u+Uijl7c53SO97RUI3LdVgVaaVRVMPIJ QkFpEeDZIodR6miJCPuK8nM/7w9wmOovzL6cloOVboh7/+yrvioyBqA111mvQP7DikbT CiESnI2eTBths06nowLxMFdz+3cfkVRUpYQtMPGSAQKdbJNa2e0nPjdJDhcy/5PRsnGC 9oa7ShF1cPDZOzYiF/qvAQP1lMSO6VGPZItwzSSxqnLVc2kQIhXuv7ASW4cFRiWnJisE SF5qMZh1GWnk7oh9O589MQ0oy7JAZmk0qTWqpN6yd8Z1O48/052eN5TXoFdMG9FNwurm AWfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hYKBzT0d; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y207-v6si5187919pfb.59.2018.11.08.11.14.13; Thu, 08 Nov 2018 11:14:29 -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; dkim=pass header.i=@linaro.org header.s=google header.b=hYKBzT0d; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727343AbeKIEuh (ORCPT + 99 others); Thu, 8 Nov 2018 23:50:37 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:32831 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbeKIEuh (ORCPT ); Thu, 8 Nov 2018 23:50:37 -0500 Received: by mail-it1-f195.google.com with SMTP id p11-v6so2549241itf.0 for ; Thu, 08 Nov 2018 11:13:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=9pqgH5iPyY9JT34F1WXkxY6gvLmgbkxVD023KV58pqA=; b=hYKBzT0deMlLz1oSe/c+8VVcDAGWbH40xIsshe0Azuk1a3dWEL9hqyHgk6vjfqNbw9 wtVl4VxjSvJfAaLR7HkdiH6R+kAeRirTZqsHL0VlhPedgAEYtA84wGz14uNM+itrLbvf AGAZ6pOQyIQoQSzJ1Vchlr7mSs0m2zcPI5HrY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=9pqgH5iPyY9JT34F1WXkxY6gvLmgbkxVD023KV58pqA=; b=GSZ2VRPa+vHxF+4yz4h5AbFRNkgpHDRPgaXPRZS6uq5URYzenf1YDorCC26hPtMqg9 SsfT75IWTQMg+lreog+gB8KiyIuSBeXVged5ULidUF3KUTJHbZwVWWUO4fXq8m/muaBO AjwHjVF5YH7zfJL8Q1JIWloRftXd8b6iYapTRimkRIVVxL5jp1wPuZS1YOhWzN0XWJrF BkHGF89gvsLGGZiAjzXAf5clZiD8VS5iEE1KBWhYefwGTALYGVVpzrYAWe/ok/1vHRc1 4cGdgFzAPZb9/kpfyg7Rf5dwG+h0QGZvIh6UyYxtHwtmlioJS2TPFGc7Q4OkBSaHVlKJ K9Ww== X-Gm-Message-State: AGRZ1gIk16mhMbVv0TOCGdShV7TnYduF8IhZvruifLOsty6TMelt0TRg wd5SMSC7OdBr0J6ZCYWmuuhQrPzZXUmRWa2yNYJ5NA== X-Received: by 2002:a24:7d8d:: with SMTP id b135-v6mr2079018itc.121.1541704425013; Thu, 08 Nov 2018 11:13:45 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a6b:4f16:0:0:0:0:0 with HTTP; Thu, 8 Nov 2018 11:13:44 -0800 (PST) In-Reply-To: <20181107205433.3875-2-logang@deltatee.com> References: <20181107205433.3875-1-logang@deltatee.com> <20181107205433.3875-2-logang@deltatee.com> From: Ard Biesheuvel Date: Thu, 8 Nov 2018 20:13:44 +0100 Message-ID: Subject: Re: [PATCH v2 1/2] mm: Introduce common STRUCT_PAGE_MAX_SHIFT define To: Logan Gunthorpe Cc: Linux Kernel Mailing List , Linux-MM , linux-arch , linux-riscv@lists.infradead.org, linux-arm-kernel , linux-sh@vger.kernel.org, Andrew Morton , Albert Ou , Arnd Bergmann , Catalin Marinas , Palmer Dabbelt , Stephen Bates , Christoph Hellwig Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7 November 2018 at 21:54, Logan Gunthorpe wrote: > This define is used by arm64 to calculate the size of the vmemmap > region. It is defined as the log2 of the upper bound on the size > of a struct page. > > We move it into mm_types.h so it can be defined properly instead of > set and checked with a build bug. This also allows us to use the same > define for riscv. > > Signed-off-by: Logan Gunthorpe > Acked-by: Will Deacon > Acked-by: Andrew Morton > Cc: Catalin Marinas > Cc: Arnd Bergmann > Cc: Christoph Hellwig Acked-by: Ard Biesheuvel > --- > arch/arm64/include/asm/memory.h | 9 --------- > arch/arm64/mm/init.c | 8 -------- > include/asm-generic/fixmap.h | 1 + > include/linux/mm_types.h | 5 +++++ > 4 files changed, 6 insertions(+), 17 deletions(-) > > diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h > index b96442960aea..f0a5c9531e8b 100644 > --- a/arch/arm64/include/asm/memory.h > +++ b/arch/arm64/include/asm/memory.h > @@ -34,15 +34,6 @@ > */ > #define PCI_IO_SIZE SZ_16M > > -/* > - * Log2 of the upper bound of the size of a struct page. Used for sizing > - * the vmemmap region only, does not affect actual memory footprint. > - * We don't use sizeof(struct page) directly since taking its size here > - * requires its definition to be available at this point in the inclusion > - * chain, and it may not be a power of 2 in the first place. > - */ > -#define STRUCT_PAGE_MAX_SHIFT 6 > - > /* > * VMEMMAP_SIZE - allows the whole linear region to be covered by > * a struct page array > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > index 9d9582cac6c4..1a3e411a1d08 100644 > --- a/arch/arm64/mm/init.c > +++ b/arch/arm64/mm/init.c > @@ -612,14 +612,6 @@ void __init mem_init(void) > BUILD_BUG_ON(TASK_SIZE_32 > TASK_SIZE_64); > #endif > > -#ifdef CONFIG_SPARSEMEM_VMEMMAP > - /* > - * Make sure we chose the upper bound of sizeof(struct page) > - * correctly when sizing the VMEMMAP array. > - */ > - BUILD_BUG_ON(sizeof(struct page) > (1 << STRUCT_PAGE_MAX_SHIFT)); > -#endif > - > if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) { > extern int sysctl_overcommit_memory; > /* > diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h > index 827e4d3bbc7a..8cc7b09c1bc7 100644 > --- a/include/asm-generic/fixmap.h > +++ b/include/asm-generic/fixmap.h > @@ -16,6 +16,7 @@ > #define __ASM_GENERIC_FIXMAP_H > > #include > +#include > > #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) > #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT) > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > index 5ed8f6292a53..2c471a2c43fa 100644 > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -206,6 +206,11 @@ struct page { > #endif > } _struct_page_alignment; > > +/* > + * Used for sizing the vmemmap region on some architectures > + */ > +#define STRUCT_PAGE_MAX_SHIFT (order_base_2(sizeof(struct page))) > + > #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK) > #define PAGE_FRAG_CACHE_MAX_ORDER get_order(PAGE_FRAG_CACHE_MAX_SIZE) > > -- > 2.19.0 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel