From mboxrd@z Thu Jan 1 00:00:00 1970 From: hch@lst.de (Christoph Hellwig) Date: Thu, 11 Oct 2018 15:37:30 +0200 Subject: [PATCH 5/5] RISC-V: Implement sparsemem In-Reply-To: <20181005161642.2462-6-logang@deltatee.com> References: <20181005161642.2462-1-logang@deltatee.com> <20181005161642.2462-6-logang@deltatee.com> Message-ID: <20181011133730.GB7276@lst.de> To: linux-riscv@lists.infradead.org List-Id: linux-riscv.lists.infradead.org > +/* > + * 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 I know this is copied from arm64, but wouldn't this be a good time to move this next to the struct page defintion? Also this: arch/arm64/mm/init.c: BUILD_BUG_ON(sizeof(struct page) > (1 << STRUCT_PAGE_MAX_SHIFT)); should move to comment code (or would have to be duplicated for riscv) > +#define VMEMMAP_SIZE (UL(1) << (CONFIG_VA_BITS - PAGE_SHIFT - 1 + \ > + STRUCT_PAGE_MAX_SHIFT)) Might be more readable with a another define, and without abuse of the horrible UL macro: #define VMEMMAP_SHIFT \ (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT) #define VMEMMAP_SIZE (1UL << VMEMMAP_SHIFT) > +#define VMEMMAP_END (VMALLOC_START - 1) > +#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE) > + > +#define vmemmap ((struct page *)VMEMMAP_START) This could also use some comments.. > @@ -0,0 +1,11 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > + > +#ifndef __ASM_SPARSEMEM_H > +#define __ASM_SPARSEMEM_H > + > +#ifdef CONFIG_SPARSEMEM > +#define MAX_PHYSMEM_BITS CONFIG_PA_BITS > +#define SECTION_SIZE_BITS 30 > +#endif > + > +#endif For potentially wide-spanning ifdefs like inclusion headers it always is nice to have a comment with the symbol on the endif line. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DBA3C32788 for ; Thu, 11 Oct 2018 13:38:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D17AA20652 for ; Thu, 11 Oct 2018 13:38:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="L5pg0J+Y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D17AA20652 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=g01bFjTxuoEvB+iZgLzQobx27XxIAFvwS+GN8JvibgQ=; b=L5pg0J+Yioc3oc eGJZUkbrHDekcdENPbkacDkgfbcClHscCWxuqqHutHF8s1FMf5V115tEBu2t827Hwk0/QAn2meuXE mtOsWZorGkkMLv9J6fVcFYdgVFkwyAk18a2hXiHB6648ai2swDR7NPLe3+8d2NJLXU2/EdjBlgkRr LnB2eS9oRYd2+M9BJog4/AVEP36d9DUtD6lcvWgUECV7Ivmc1+fjEEAkqULRfehDlETqO0AU+fTas +mlWbHXbEZLNlX8Z0+2LE1T0S7wtEVbhxl7LjmkUcdJ/8Ie8bTlWsJun7zLJuyFtuQrYN/iYpKJQu KTueX7yPbYjMYu0KfaWA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gAbAM-0005z8-1V; Thu, 11 Oct 2018 13:38:14 +0000 Received: from verein.lst.de ([213.95.11.211] helo=newverein.lst.de) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gAb9q-0005j4-90; Thu, 11 Oct 2018 13:37:43 +0000 Received: by newverein.lst.de (Postfix, from userid 2407) id CB5BA68BFE; Thu, 11 Oct 2018 15:37:30 +0200 (CEST) Date: Thu, 11 Oct 2018 15:37:30 +0200 From: Christoph Hellwig To: Logan Gunthorpe Subject: Re: [PATCH 5/5] RISC-V: Implement sparsemem Message-ID: <20181011133730.GB7276@lst.de> References: <20181005161642.2462-1-logang@deltatee.com> <20181005161642.2462-6-logang@deltatee.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20181005161642.2462-6-logang@deltatee.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181011_063742_466260_C98B0BD9 X-CRM114-Status: GOOD ( 12.69 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 , Christoph Hellwig , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org Message-ID: <20181011133730.zc3nM_RI0NGqsVMfi_1NFSxtfRkCju7m8cqsJGJtfMs@z> > +/* > + * 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 I know this is copied from arm64, but wouldn't this be a good time to move this next to the struct page defintion? Also this: arch/arm64/mm/init.c: BUILD_BUG_ON(sizeof(struct page) > (1 << STRUCT_PAGE_MAX_SHIFT)); should move to comment code (or would have to be duplicated for riscv) > +#define VMEMMAP_SIZE (UL(1) << (CONFIG_VA_BITS - PAGE_SHIFT - 1 + \ > + STRUCT_PAGE_MAX_SHIFT)) Might be more readable with a another define, and without abuse of the horrible UL macro: #define VMEMMAP_SHIFT \ (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT) #define VMEMMAP_SIZE (1UL << VMEMMAP_SHIFT) > +#define VMEMMAP_END (VMALLOC_START - 1) > +#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE) > + > +#define vmemmap ((struct page *)VMEMMAP_START) This could also use some comments.. > @@ -0,0 +1,11 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > + > +#ifndef __ASM_SPARSEMEM_H > +#define __ASM_SPARSEMEM_H > + > +#ifdef CONFIG_SPARSEMEM > +#define MAX_PHYSMEM_BITS CONFIG_PA_BITS > +#define SECTION_SIZE_BITS 30 > +#endif > + > +#endif For potentially wide-spanning ifdefs like inclusion headers it always is nice to have a comment with the symbol on the endif line. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv