Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2624539imm; Thu, 11 Oct 2018 13:22:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV603UC7m6obrnkBHUQtf3HglPKKx2p6e0k0HL179wc2BTAPb/rBuNdG/0iis6ss7ya6YQpb+ X-Received: by 2002:a65:4d03:: with SMTP id i3-v6mr2717500pgt.239.1539289330666; Thu, 11 Oct 2018 13:22:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539289330; cv=none; d=google.com; s=arc-20160816; b=U5MIIn5q2R9mt6o0A72audfP5ZdRb474zeuJOlRDSmXn/3l4z7vrxg5g8Gdol9JOKE hrwwIxEhZs/N6+Vc+qtbU2SKJm54QFayL/8Csr10UirefyYbeRSDzuEyRCc5z/47GWB3 6ayv/8xBqIQHoDG3DDhnWxJt4KHPOUMSJ3vN8u70ex/XQ9vwDBkWGks2zVy5SIHdxqoD J6lY8KzMEF8ImX+IlUsD4qfjWpvHi8NovlkeEW57QnF3o0+cJvqdVCRpS91htn8DnnBK 1ArhWJoYtsHcZhc8NQTc9RwjgWQ7NZHIXoTP2+PHUwcK0OvVtxq5P/r/FgzjISi4RM8Z 192w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from; bh=Y4JtwPizmYlttbS9vcUyylB/b2FaV85MS9wq3jlS3bM=; b=xgwczUtqj1iEmC05KFzoHme8kwh3ZaeG6VMJQJdwc0KxAKB4AeAUV2Y+uGaX2Pb+Mf R3ZbbEXNokNaDZFqURv0Y6OQKl5ZdS4dBTK+e1uN4l/YeakdJLhY9ytOCxW/8XdFiyWu ds5GZdvH+98xno4sj4VQkJ5dhTRTTZK8sWR2e4b/Wanf1MU90ZyAwBMel3XWvb9f9HpE ELW0UDXcNxIArKiZ4wvPHvgDtgRQZWDKNyOw275AVaP4VZRE+dmDE0SXwzC66ELo135y uLui9BtWO4OeZEGNKOhb5Vm68VSYRTkSmsX4DJd/RT8Ja4yyMGlvSXlv9JGrE99LqYB4 YKuw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7-v6si22486443pfj.49.2018.10.11.13.21.55; Thu, 11 Oct 2018 13:22:10 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726220AbeJLDuZ (ORCPT + 99 others); Thu, 11 Oct 2018 23:50:25 -0400 Received: from ale.deltatee.com ([207.54.116.67]:60680 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726040AbeJLDuZ (ORCPT ); Thu, 11 Oct 2018 23:50:25 -0400 Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.89) (envelope-from ) id 1gAhSR-0004GP-Bp; Thu, 11 Oct 2018 14:21:20 -0600 From: Logan Gunthorpe To: Christoph Hellwig Cc: Rob Herring , Albert Ou , Andrew Waterman , linux-sh@vger.kernel.org, Palmer Dabbelt , linux-kernel@vger.kernel.org, Stephen Bates , Zong Li , linux-mm@kvack.org, Olof Johansson , linux-riscv@lists.infradead.org, Michael Clark , linux-arm-kernel@lists.infradead.org References: <20181005161642.2462-1-logang@deltatee.com> <20181005161642.2462-6-logang@deltatee.com> <20181011133730.GB7276@lst.de> <8cea5ffa-5fbf-8ea2-b673-20e2d09a910d@deltatee.com> <83cfd2d7-b840-b0c6-594e-8b39be8177c1@deltatee.com> Message-ID: Date: Thu, 11 Oct 2018 14:21:17 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <83cfd2d7-b840-b0c6-594e-8b39be8177c1@deltatee.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, michaeljclark@mac.com, linux-riscv@lists.infradead.org, olof@lixom.net, linux-mm@kvack.org, zong@andestech.com, sbates@raithlin.com, linux-kernel@vger.kernel.org, palmer@sifive.com, linux-sh@vger.kernel.org, andrew@sifive.com, aou@eecs.berkeley.edu, robh@kernel.org, hch@lst.de X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE autolearn=ham autolearn_force=no version=3.4.1 Subject: Re: [PATCH 5/5] RISC-V: Implement sparsemem 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-10-11 12:45 p.m., Logan Gunthorpe wrote: > Ok, I spoke too soon... > > Having this define next to the struct page definition works great for > riscv. However, making that happen in arm64 seems to be a nightmare. The > include chain in arm64 is tangled up so much that including mm_types > where this is needed seems to be extremely difficult. Sorry for all the unnecessary churn but I've figured it out. Just had to realize we only need mm_types.h to be included where STRUCT_PAGE_MAX_SHIFT is finally expanded. Thus we only need it in one more spot (fixmap.h). See below. Thanks, Logan -- 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/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..d1c3cde8c201 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)