From: Yuquan Wang <wangyuquan1236@phytium.com.cn>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: dan.j.williams@intel.com, linux-cxl@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, chenbaozi@phytium.com.cn
Subject: Re: [RFC PATCH 1/8] arm64: numa: Introduce a memory_add_physaddr_to_nid()
Date: Thu, 1 Aug 2024 15:50:23 +0800 [thread overview]
Message-ID: <Zqs+P/TO01Y3TKcd@phytium.com.cn> (raw)
In-Reply-To: <20240529171236.32002-2-Jonathan.Cameron@huawei.com>
On Wed, May 29, 2024 at 06:12:29PM +0100, Jonathan Cameron wrote:
> From: Dan Williams <dan.j.williams@intel.com>
>
> Based heavily on Dan William's earlier attempt to introduce this
> infrastruture for all architectures so I've kept his authorship. [1]
>
> arm64 stores it's numa data in memblock. Add a memblock generic
> way to interrogate that data for memory_Add_physaddr_to_nid.
>
> Cc: Mike Rapoport <rppt@linux.ibm.com>
> Cc: Jia He <justin.he@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> Link: https://lore.kernel.org/r/159457120334.754248.12908401960465408733.stgit@dwillia2-desk3.amr.corp.intel.com [1]
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> arch/arm64/include/asm/sparsemem.h | 4 ++++
> arch/arm64/mm/init.c | 29 +++++++++++++++++++++++++++++
> 2 files changed, 33 insertions(+)
>
> diff --git a/arch/arm64/include/asm/sparsemem.h b/arch/arm64/include/asm/sparsemem.h
> index 8a8acc220371..8dd1b6a718fa 100644
> --- a/arch/arm64/include/asm/sparsemem.h
> +++ b/arch/arm64/include/asm/sparsemem.h
> @@ -26,4 +26,8 @@
> #define SECTION_SIZE_BITS 27
> #endif /* CONFIG_ARM64_64K_PAGES */
>
> +#ifndef __ASSEMBLY__
> +extern int memory_add_physaddr_to_nid(u64 addr);
> +#define memory_add_physaddr_to_nid memory_add_physaddr_to_nid
> +#endif /* __ASSEMBLY__ */
> #endif
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index 9b5ab6818f7f..f310cbd349ba 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -48,6 +48,35 @@
> #include <asm/alternative.h>
> #include <asm/xen/swiotlb-xen.h>
>
> +#ifdef CONFIG_NUMA
> +
> +static int __memory_add_physaddr_to_nid(u64 addr)
> +{
> + unsigned long start_pfn, end_pfn, pfn = PHYS_PFN(addr);
> + int nid;
> +
> + for_each_online_node(nid) {
> + get_pfn_range_for_nid(nid, &start_pfn, &end_pfn);
> + if (pfn >= start_pfn && pfn <= end_pfn)
> + return nid;
> + }
> + return NUMA_NO_NODE;
> +}
> +
> +int memory_add_physaddr_to_nid(u64 start)
> +{
> + int nid = __memory_add_physaddr_to_nid(start);
> +
> + /* Default to node0 as not all callers are prepared for this to fail */
> + if (nid == NUMA_NO_NODE)
> + return 0;
> +
> + return nid;
> +}
> +EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
> +
> +#endif /* CONFIG_NUMA */
> +
> /*
> * We need to be able to catch inadvertent references to memstart_addr
> * that occur (potentially in generic code) before arm64_memblock_init()
> --
> 2.39.2
>
Tested-off-by: Yuquan Wang <wangyuquan1236@phytium.com.cn>
next prev parent reply other threads:[~2024-08-01 7:51 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-29 17:12 [RFC PATCH 0/8] arm64/memblock: Handling of CXL Fixed Memory Windows Jonathan Cameron
2024-05-29 17:12 ` [RFC PATCH 1/8] arm64: numa: Introduce a memory_add_physaddr_to_nid() Jonathan Cameron
2024-08-01 7:50 ` Yuquan Wang [this message]
2024-05-29 17:12 ` [RFC PATCH 2/8] arm64: memblock: Introduce a generic phys_addr_to_target_node() Jonathan Cameron
2024-08-01 7:52 ` Yuquan Wang
2024-05-29 17:12 ` [RFC PATCH 3/8] mm: memblock: Add a means to add to memblock.reserved Jonathan Cameron
2024-08-01 7:53 ` Yuquan Wang
2024-05-29 17:12 ` [RFC PATCH 4/8] arch_numa: Avoid onlining empty NUMA nodes Jonathan Cameron
2024-08-01 7:53 ` Yuquan Wang
2024-05-29 17:12 ` [RFC PATCH 5/8] arch_numa: Make numa_add_memblk() set nid for memblock.reserved regions Jonathan Cameron
2024-08-01 7:54 ` Yuquan Wang
2024-05-29 17:12 ` [RFC PATCH 6/8] arm64: mm: numa_fill_memblks() to add a memblock.reserved region if match Jonathan Cameron
2024-08-01 7:54 ` Yuquan Wang
2024-05-29 17:12 ` [RFC PATCH 7/8] acpi: srat: cxl: Skip zero length CXL fixed memory windows Jonathan Cameron
2024-08-01 7:55 ` Yuquan Wang
2024-05-29 17:12 ` [RFC PATCH 8/8] HACK: mm: memory_hotplug: Drop memblock_phys_free() call in try_remove_memory() Jonathan Cameron
2024-05-30 10:07 ` Oscar Salvador
2024-05-30 12:14 ` Jonathan Cameron
2024-05-31 7:49 ` David Hildenbrand
2024-05-31 9:48 ` Jonathan Cameron
2024-05-31 9:55 ` David Hildenbrand
2024-06-06 15:44 ` Mike Rapoport
2024-06-03 7:57 ` Mike Rapoport
2024-06-03 9:14 ` David Hildenbrand
2024-06-03 10:43 ` Mike Rapoport
2024-06-03 20:53 ` David Hildenbrand
2024-06-04 9:35 ` Mike Rapoport
2024-06-04 9:39 ` David Hildenbrand
2024-06-05 8:00 ` Mike Rapoport
2024-06-05 8:23 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zqs+P/TO01Y3TKcd@phytium.com.cn \
--to=wangyuquan1236@phytium.com.cn \
--cc=Jonathan.Cameron@huawei.com \
--cc=chenbaozi@phytium.com.cn \
--cc=dan.j.williams@intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-cxl@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).