[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6497d8421945c_2ed72941@dwillia2-xfh.jf.intel.com.notmuch>
Date: Sat, 24 Jun 2023 23:01:38 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: <alison.schofield@...el.com>,
"Rafael J. Wysocki" <rafael@...nel.org>,
"Len Brown" <lenb@...nel.org>,
Dan Williams <dan.j.williams@...el.com>,
"Thomas Gleixner" <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"Borislav Petkov" <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>,
Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
"Jonathan Cameron" <Jonathan.Cameron@...wei.com>,
Dave Jiang <dave.jiang@...el.com>,
Mike Rapoport <rppt@...nel.org>
CC: Alison Schofield <alison.schofield@...el.com>, <x86@...nel.org>,
<linux-cxl@...r.kernel.org>, <linux-acpi@...r.kernel.org>,
<linux-kernel@...r.kernel.org>,
Derick Marks <derick.w.marks@...el.com>
Subject: RE: [PATCH v3 1/2] x86/numa: Introduce numa_fill_memblks()
alison.schofield@ wrote:
> From: Alison Schofield <alison.schofield@...el.com>
>
> numa_fill_memblks() fills in the gaps in numa_meminfo memblks
> over an physical address range.
[..]
> diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
> index 2aadb2019b4f..152398bdecc4 100644
> --- a/arch/x86/mm/numa.c
> +++ b/arch/x86/mm/numa.c
[..]
> +int __init numa_fill_memblks(u64 start, u64 end)
> +{
> + struct numa_memblk **blk = &numa_memblk_list[0];
> + struct numa_meminfo *mi = &numa_meminfo;
> + int count = 0;
> + u64 prev_end;
> +
> + /*
> + * Create a list of pointers to numa_meminfo memblks that
> + * overlap start, end. Exclude (start == bi->end) since
> + * end addresses in both a CFMWS range and a memblk range
> + * are exclusive.
> + *
> + * This list of pointers is used to make in-place changes
> + * that fill out the numa_meminfo memblks.
> + */
> + for (int i = 0; i < mi->nr_blks; i++) {
> + struct numa_memblk *bi = &mi->blk[i];
> +
> + if (start < bi->end && end >= bi->start) {
> + blk[count] = &mi->blk[i];
> + count++;
> + }
> + }
> + if (!count)
> + return NUMA_NO_MEMBLK;
> +
> + /* Sort the list of pointers in memblk->start order */
> + sort(&blk[0], count, sizeof(blk[0]), cmp_memblk, NULL);
> +
> + /* Make sure the first/last memblks include start/end */
> + blk[0]->start = min(blk[0]->start, start);
> + blk[count - 1]->end = max(blk[count - 1]->end, end);
> +
> + /*
> + * Fill any gaps by tracking the previous memblks
> + * end address and backfilling to it if needed.
> + */
> + prev_end = blk[0]->end;
> + for (int i = 1; i < count; i++) {
> + struct numa_memblk *curr = blk[i];
> +
> + if (prev_end >= curr->start) {
> + if (prev_end < curr->end)
> + prev_end = curr->end;
> + } else {
> + curr->start = prev_end;
> + prev_end = curr->end;
> + }
> + }
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(numa_fill_memblks);
After deleting this export you can add:
Reviewed-by: Dan Williams <dan.j.williams@...el.com>
Powered by blists - more mailing lists