[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181011133730.GB7276@lst.de>
Date: Thu, 11 Oct 2018 15:37:30 +0200
From: Christoph Hellwig <hch@....de>
To: Logan Gunthorpe <logang@...tatee.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
linux-riscv@...ts.infradead.org,
linux-arm-kernel@...ts.infradead.org, linux-sh@...r.kernel.org,
Stephen Bates <sbates@...thlin.com>,
Palmer Dabbelt <palmer@...ive.com>,
Albert Ou <aou@...s.berkeley.edu>,
Christoph Hellwig <hch@....de>,
Andrew Waterman <andrew@...ive.com>,
Olof Johansson <olof@...om.net>,
Michael Clark <michaeljclark@....com>,
Rob Herring <robh@...nel.org>, Zong Li <zong@...estech.com>
Subject: Re: [PATCH 5/5] RISC-V: Implement sparsemem
> +/*
> + * 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.
Powered by blists - more mailing lists