From patchwork Wed Nov 7 17:38:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10672775 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EFC2B109C for ; Wed, 7 Nov 2018 17:39:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E25BB2CD06 for ; Wed, 7 Nov 2018 17:39:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D69802CD1C; Wed, 7 Nov 2018 17:39:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BE162CD06 for ; Wed, 7 Nov 2018 17:39:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DCED6B0531; Wed, 7 Nov 2018 12:39:07 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 18C9A6B0533; Wed, 7 Nov 2018 12:39:07 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07CFE6B0534; Wed, 7 Nov 2018 12:39:06 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it1-f197.google.com (mail-it1-f197.google.com [209.85.166.197]) by kanga.kvack.org (Postfix) with ESMTP id CF7646B0531 for ; Wed, 7 Nov 2018 12:39:06 -0500 (EST) Received: by mail-it1-f197.google.com with SMTP id r79-v6so11358970itc.4 for ; Wed, 07 Nov 2018 09:39:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :date:message-id:in-reply-to:references:mime-version :content-transfer-encoding:subject; bh=Izl7FQIjX6vtgzV3Bh7GUeX8NbhWtWlS4nwo7NYT9mE=; b=pL20uPQd987uzbXdSrMzmSVqmrC7Oe3eWeIfSikX5dJlrGaWiRBK4TZSWt2sO9H7Qd OIeowcYGObmZakqDe9ej7h6CGxDXHzkAP2+4cUHDSkWHhdxNw9AKS6XAGwJDFbFpaHAl 1F1IPTDNCqLoEYeFXHdEqUUVXky1DPWe/mzZvUGTD6Vzq3GCNNWDSCnqD0NXjlfGTDRc MIOdJ/eqGOmpkiemYN0IQ4POFtM+eGprmVGTItFpQj9+u2jREzeKGwJpxxDp4E+M3a2B gy0OFDUZ4SE1TGIkVa3EnsCvBY2D5pBhtarg5iynvrf23km12h65a/WaAa6jXb5wsgvU NWYg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) smtp.mailfrom=gunthorp@deltatee.com X-Gm-Message-State: AGRZ1gKMBrYUsmMBKRuV0OyRiFTyH6q8u2JAjC9jJ2B6TNokSsJbOzmw H+BgDFs/GVRDV8cvLd088JrAcBQWFjKMY0G0l5x0y2SAtEVdDS/2JY2euGTIAiNdzI2ZxlZw/Ml PgFW4bGLnm9RbU81DYSikihhDC/8B6mqViEUEhSpL6lK2W5+w9PG0Hkbh/VGN2DqgaQ== X-Received: by 2002:a24:4486:: with SMTP id o128-v6mr977605ita.23.1541612346595; Wed, 07 Nov 2018 09:39:06 -0800 (PST) X-Google-Smtp-Source: AJdET5cZUtJOaVxbwdvwl6/iNQzNSTYF1fuZ42gKmJbs7AjvJEhKHoM+f6DPqczdvPYshJRUPBYk X-Received: by 2002:a24:4486:: with SMTP id o128-v6mr977579ita.23.1541612345875; Wed, 07 Nov 2018 09:39:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541612345; cv=none; d=google.com; s=arc-20160816; b=q5dluBxGZDtCwYVI+1hj+RwB3aHsMG4ySeS4og4LVAONUgg1VnhA5mDYH2lkvlTxeG +jgJm5LXLO5rJJj0WLEAZdwkAMsDZUekyARlh4TJKWwEaf43Bx/cifQ9mibZTEO3WLnG YD8BjtEGrldww1oQ1sELUaFF/1ht2PT9/XSIXdCc9Fd0hn52TmCb6J9OwOvgwzc8Qkzc r2a/pRALHIDDgwAykZkrhgo9hw/flfjCYmO4eGr2cKiprmHIRzi8VmvyLbgoto+6+gOr 34rpQGeJbxMWf7cL+nZHfUk/xvAMVNp/H5Zk85zw3eXDjFWEfdxn/Enr77t5kHhckZO3 /A0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:cc:to:from; bh=Izl7FQIjX6vtgzV3Bh7GUeX8NbhWtWlS4nwo7NYT9mE=; b=s3rpwUux74LKy6c/YbHJjpqNlvKq8sxBkRR8H5Bpn1YOlATt7mjfSXr4AbNgpRO5Ps FMno5uKsHUbNumaG8RbTMhTQRwanrKtvaUbNifbDkUSThUnNkV0RenRr3Ky5uEtCpPgk aCPl56g+/WOTa12TUREIySQpzbfmb7ZRCON6GYj87VfeUqJ4JYPWnzviq0UVuKsBQbT6 v32VbyPjazQxgoFbniMjfppYuYZvnvaaLmzFQkvAhGPFSMjQfXWAopyjcJfOdY9Iv5l3 zUXEDvOWxS2WCdD0srgFL7q4AFruA1+J24grPYUS7rIOJaDngR0zEhcfqp2Byk09F8OV Vo5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) smtp.mailfrom=gunthorp@deltatee.com Received: from ale.deltatee.com (ale.deltatee.com. [207.54.116.67]) by mx.google.com with ESMTPS id c7-v6si924267jah.125.2018.11.07.09.39.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Nov 2018 09:39:03 -0800 (PST) Received-SPF: pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) client-ip=207.54.116.67; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) smtp.mailfrom=gunthorp@deltatee.com Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gKRnB-0003U5-I0; Wed, 07 Nov 2018 10:39:02 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1gKRnA-0006HQ-Fv; Wed, 07 Nov 2018 10:39:00 -0700 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-sh@vger.kernel.org, Andrew Morton Cc: Stephen Bates , Palmer Dabbelt , Albert Ou , Christoph Hellwig , Arnd Bergmann , Logan Gunthorpe , Catalin Marinas Date: Wed, 7 Nov 2018 10:38:58 -0700 Message-Id: <20181107173859.24096-2-logang@deltatee.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181107173859.24096-1-logang@deltatee.com> References: <20181107173859.24096-1-logang@deltatee.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-sh@vger.kernel.org, akpm@linux-foundation.org, sbates@raithlin.com, palmer@sifive.com, aou@eecs.berkeley.edu, hch@lst.de, arnd@arndb.de, logang@deltatee.com, catalin.marinas@arm.com X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH 1/2] mm: Introduce common STRUCT_PAGE_MAX_SHIFT define X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) 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: X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Catalin Marinas Cc: Arnd Bergmann Cc: Andrew Morton Cc: Christoph Hellwig Acked-by: Andrew Morton --- 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)