From patchwork Mon Oct 15 17:56:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10642289 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 39B4C13AD for ; Mon, 15 Oct 2018 17:57:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AC362984E for ; Mon, 15 Oct 2018 17:57:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F19F298CA; Mon, 15 Oct 2018 17:57:25 +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=ham 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 8B5EF2984E for ; Mon, 15 Oct 2018 17:57:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D2BA6B0007; Mon, 15 Oct 2018 13:57:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8305C6B000C; Mon, 15 Oct 2018 13:57:18 -0400 (EDT) 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 682F36B000D; Mon, 15 Oct 2018 13:57:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) by kanga.kvack.org (Postfix) with ESMTP id 36B7B6B0007 for ; Mon, 15 Oct 2018 13:57:18 -0400 (EDT) Received: by mail-it1-f199.google.com with SMTP id z136-v6so23111974itc.5 for ; Mon, 15 Oct 2018 10:57:18 -0700 (PDT) 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=Q2/22PJP5KiW9SOBKPYV29chcTBnVKjNVxRDnLt6F18=; b=UdCM835kAXdnrcxD++e5GOsqgLk7UhFBzfNapqFN2/gHXvn+ydtp6anQ/OxlXdQcec ocZKA9ZvwT9RMltt5tzvQCl0C+bdvI5X/kx+UV0+CE31ovxwTNzI3kxz1T40cG52tJnT VN8Neg8V3ZLWqyoSSVNXV4zBmtOWi1oR8uizqUgcCuIXrnTteYOdj7oqQF+WFfu4gUEm bTlWoYPSy617l6/x8OBRrijPh996uJKU4ZP7FfSPF42SIvOOPujmm6pIz2rXYq7G8XcO 2l373BdN77Xj/gbAd4wHRaiCijzPi9eP72N+yjejYmLjgx4M7Q21dO/YvNQHPKkf8lg2 Geig== 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: ABuFfoiEDhbvjDb0NSUy6nw9z5QyBsBt3+7WuimGyNp28m/0V14lnc4i tYg72JENu1b6p0hb2VDzTA/ckiTkdVOvPTfhLL32D4MgP6sxHZxwaYjs7ndLy5C3Y64c3haV+bu 2X2soeUSCU9PwZmIuMeJkyZSb51RzFhjKjN+H0cdY90xrKb0ZcpQZb/C22jDO1LVheQ== X-Received: by 2002:a24:ac53:: with SMTP id m19-v6mr12533615iti.147.1539626237930; Mon, 15 Oct 2018 10:57:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV6105B61rJb+4V6S34Z7f57wFLnqfPy/WieGzdf0CANTfKgp03E2aN6YswXCT7TfeT6+TfYh X-Received: by 2002:a24:ac53:: with SMTP id m19-v6mr12533582iti.147.1539626237143; Mon, 15 Oct 2018 10:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539626237; cv=none; d=google.com; s=arc-20160816; b=XKoZx3VT2gM0nbDq+qn2JA3DQZ92UvhwUumr41TT6qHjSUUYbRzwILIycHHbqEpRt8 jgyVxOfp0FcVnwQkocXu+UHZ/hueeepwDzhkOMSXtYTU1PJLsCkqrDjq9eDVr5Dxz7Hu 4N+MxX681WxfOE/UKTE9zNSsUyOVJE98KgtToy3jPVZSPZGqqSTByKJuv9xWjpPJ4ebH LGrPxxYfmYl/woPEWrZHu+WMcyou8oHzR4zujkRjRdJg7Ad23Xenpq5pJabZxB2hpDG0 WrwWw8DoUwUMOSoHyNfDDt0gkXZd7TYGxrz052rXAs8LCZgeZRVjllw4xJB2kQnQHgHP memw== 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=Q2/22PJP5KiW9SOBKPYV29chcTBnVKjNVxRDnLt6F18=; b=mtiEwYgF6uLkar4uZ/T/AQJLPcwdvPGF64l96UtZ+OaqGVBrV7znWqUqzhNZOiX0S2 M6vUWAgkEYwflqaHQU4tVqbCOsHuomLYcDHYTCfB6/IgzgEF2eB5UakoRkrmUobB27GZ 4PWFj9vnFTTkxXNr+ABfSrly5if07eSsWiwXiCKHdNqEC7hu0ZmezTTeGIfKMM61XwR7 NXY9z5s17nA21En80jgCWxM2e0icvCVuketggCmcqCvKPLFPiOiOsTaTov9fyD2G2KT/ /cpAcEH6UD/Bibkrytcu9YV8kolHsl/Z3CINaDeG7YnoMi9jK4VtelNqiDm8Q7bRx04z IJ7Q== 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 a204-v6si7556442ita.40.2018.10.15.10.57.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Oct 2018 10:57:17 -0700 (PDT) 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 1gC77C-0002II-7K; Mon, 15 Oct 2018 11:57:16 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1gC779-0002Ma-0e; Mon, 15 Oct 2018 11:57:11 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-sh@vger.kernel.org Cc: Stephen Bates , Palmer Dabbelt , Albert Ou , Christoph Hellwig , Andrew Morton , Arnd Bergmann , Logan Gunthorpe , Catalin Marinas , Will Deacon Date: Mon, 15 Oct 2018 11:56:57 -0600 Message-Id: <20181015175702.9036-2-logang@deltatee.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181015175702.9036-1-logang@deltatee.com> References: <20181015175702.9036-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-sh@vger.kernel.org, sbates@raithlin.com, palmer@sifive.com, aou@eecs.berkeley.edu, hch@lst.de, akpm@linux-foundation.org, arnd@arndb.de, logang@deltatee.com, catalin.marinas@arm.com, will.deacon@arm.com X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH v2 1/6] 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 Cc: Catalin Marinas Cc: Will Deacon Cc: Arnd Bergmann Cc: Andrew Morton Cc: Christoph Hellwig Acked-by: Will Deacon --- 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 787e27964ab9..6a0b5c5a61af 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -615,14 +615,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..ec8c16d9396b 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 ilog2(roundup_pow_of_two(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)