2024-05-16 09:17:40

by Yajun Deng

[permalink] [raw]
Subject: [PATCH] mm/cma: get nid from physical address

The nid passed to cma_declare_contiguous_nid() may be NUMA_NO_NODE,
which is not the actual nid. To get the correct nid, we can get the nid
from physical address.

Signed-off-by: Yajun Deng <[email protected]>
---
mm/cma.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/mm/cma.c b/mm/cma.c
index 3e9724716bad..be6cdde32944 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -361,6 +361,7 @@ int __init cma_declare_contiguous_nid(phys_addr_t base,
kmemleak_ignore_phys(addr);
base = addr;
}
+ nid = early_pfn_to_nid(PHYS_PFN(base));

ret = cma_init_reserved_mem(base, size, order_per_bit, name, res_cma);
if (ret)
--
2.25.1



2024-05-16 10:24:44

by Kefeng Wang

[permalink] [raw]
Subject: Re: [PATCH] mm/cma: get nid from physical address



On 2024/5/16 17:17, Yajun Deng wrote:
> The nid passed to cma_declare_contiguous_nid() may be NUMA_NO_NODE,
> which is not the actual nid. To get the correct nid, we can get the nid
> from physical address.
>

Please check

https://lore.kernel.org/linux-riscv/[email protected]/

> Signed-off-by: Yajun Deng <[email protected]>
> ---
> mm/cma.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/cma.c b/mm/cma.c
> index 3e9724716bad..be6cdde32944 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -361,6 +361,7 @@ int __init cma_declare_contiguous_nid(phys_addr_t base,
> kmemleak_ignore_phys(addr);
> base = addr;
> }
> + nid = early_pfn_to_nid(PHYS_PFN(base));
>
> ret = cma_init_reserved_mem(base, size, order_per_bit, name, res_cma);
> if (ret)

2024-05-16 11:16:16

by Yajun Deng

[permalink] [raw]
Subject: Re: [PATCH] mm/cma: get nid from physical address

May 16, 2024 at 6:03 PM, "Kefeng Wang" <[email protected]> wrote:



>
> On 2024/5/16 17:17, Yajun Deng wrote:
>
> >
> > The nid passed to cma_declare_contiguous_nid() may be NUMA_NO_NODE,
> >
> > which is not the actual nid. To get the correct nid, we can get the nid
> >
> > from physical address.
> >
>
> Please check
>
> https://lore.kernel.org/linux-riscv/[email protected]/
>

Okay, thanks!
> >
> > Signed-off-by: Yajun Deng <[email protected]>
> >
> > ---
> >
> > mm/cma.c | 1 +
> >
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/mm/cma.c b/mm/cma.c
> >
> > index 3e9724716bad..be6cdde32944 100644
> >
> > --- a/mm/cma.c
> >
> > +++ b/mm/cma.c
> >
> > @@ -361,6 +361,7 @@ int __init cma_declare_contiguous_nid(phys_addr_t base,
> >
> > kmemleak_ignore_phys(addr);
> >
> > base = addr;
> >
> > }
> >
> > + nid = early_pfn_to_nid(PHYS_PFN(base));
> >
> > > ret = cma_init_reserved_mem(base, size, order_per_bit, name, res_cma);
> >
> > if (ret)
> >
>