RE: [PATCH v10 1/3] mm: Add node_to_range lookup facility to numa_memblks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>-----Original Message-----
>From: Mike Rapoport <rppt@xxxxxxxxxx>
>Sent: 05 August 2025 11:20
>To: Shiju Jose <shiju.jose@xxxxxxxxxx>
>Cc: rafael@xxxxxxxxxx; bp@xxxxxxxxx; akpm@xxxxxxxxxxxxxxxxxxxx;
>dferguson@xxxxxxxxxxxxxxxxxxx; linux-edac@xxxxxxxxxxxxxxx; linux-
>acpi@xxxxxxxxxxxxxxx; linux-mm@xxxxxxxxx; linux-doc@xxxxxxxxxxxxxxx;
>tony.luck@xxxxxxxxx; lenb@xxxxxxxxxx; leo.duran@xxxxxxx;
>Yazen.Ghannam@xxxxxxx; mchehab@xxxxxxxxxx; Jonathan Cameron
><jonathan.cameron@xxxxxxxxxx>; Linuxarm <linuxarm@xxxxxxxxxx>;
>rientjes@xxxxxxxxxx; jiaqiyan@xxxxxxxxxx; Jon.Grimm@xxxxxxx;
>dave.hansen@xxxxxxxxxxxxxxx; naoya.horiguchi@xxxxxxx;
>james.morse@xxxxxxx; jthoughton@xxxxxxxxxx; somasundaram.a@xxxxxxx;
>erdemaktas@xxxxxxxxxx; pgonda@xxxxxxxxxx; duenwen@xxxxxxxxxx;
>gthelen@xxxxxxxxxx; wschwartz@xxxxxxxxxxxxxxxxxxx;
>wbs@xxxxxxxxxxxxxxxxxxxxxx; nifan.cxl@xxxxxxxxx; tanxiaofei
><tanxiaofei@xxxxxxxxxx>; Zengtao (B) <prime.zeng@xxxxxxxxxxxxx>; Roberto
>Sassu <roberto.sassu@xxxxxxxxxx>; kangkang.shen@xxxxxxxxxxxxx;
>wanghuiqiang <wanghuiqiang@xxxxxxxxxx>
>Subject: Re: [PATCH v10 1/3] mm: Add node_to_range lookup facility to
>numa_memblks
>
>On Fri, Aug 01, 2025 at 06:20:27PM +0100, shiju.jose@xxxxxxxxxx wrote:
>> From: Shiju Jose <shiju.jose@xxxxxxxxxx>
>>
>> Lookup facility to retrieve memory phys lowest continuous range for a
>> NUMA node is required in the numa_memblks for the ACPI RAS2 memory
>> scrub use case.
>
>If the code that needs to find the lowest contiguous range in a node runs before
>we discard .init you can just use
>
>	unsigned long pfn = node_start_pfn(nid);
>	unsigned long start_pfn, end_pfn;
>
>	memblock_search_pfn_nid(pfn, &start_pfn, &end_pfn);

Thanks Mike for your suggestion and help.
 
With node_start_pfn(nid) and memblock_search_pfn_nid(), the 'end_pfn' return 
different value than the actual.

Found similar function get_pfn_range_for_nid(nid, &start_pfn, &end_pfn), seems more
suitable as it takes 'nid' directly and both 'start_pfn' and 'end_pfn 'return correct values. 

Thanks,
Shiju

>
>> Suggested-by: Jonathan Cameron <jonathan.cameron@xxxxxxxxxx>
>> Signed-off-by: Shiju Jose <shiju.jose@xxxxxxxxxx>
>> ---
>>  include/linux/numa.h         | 10 ++++++++++
>>  include/linux/numa_memblks.h |  2 ++
>>  mm/numa.c                    | 10 ++++++++++
>>  mm/numa_memblks.c            | 23 +++++++++++++++++++++++
>>  4 files changed, 45 insertions(+)
>>
>> diff --git a/include/linux/numa.h b/include/linux/numa.h index
>> e6baaf6051bc..d41e583a902d 100644
>> --- a/include/linux/numa.h
>> +++ b/include/linux/numa.h
>> @@ -41,6 +41,10 @@ int memory_add_physaddr_to_nid(u64 start);  int
>> phys_to_target_node(u64 start);  #endif
>>
>> +#ifndef node_to_phys_lowest_continuous_range
>> +int node_to_phys_lowest_continuous_range(int nid, u64 *start, u64
>> +*end); #endif
>> +
>>  int numa_fill_memblks(u64 start, u64 end);
>>
>>  #else /* !CONFIG_NUMA */
>> @@ -63,6 +67,12 @@ static inline int phys_to_target_node(u64 start)
>>  	return 0;
>>  }
>>
>> +static inline int node_to_phys_lowest_continuous_range(int nid, u64 *start,
>> +						       u64 *end)
>> +{
>> +	return 0;
>> +}
>> +
>>  static inline void alloc_offline_node_data(int nid) {}  #endif
>>
>> diff --git a/include/linux/numa_memblks.h
>> b/include/linux/numa_memblks.h index 991076cba7c5..ccc53029de8b 100644
>> --- a/include/linux/numa_memblks.h
>> +++ b/include/linux/numa_memblks.h
>> @@ -55,6 +55,8 @@ extern int phys_to_target_node(u64 start);  #define
>> phys_to_target_node phys_to_target_node  extern int
>> memory_add_physaddr_to_nid(u64 start);  #define
>> memory_add_physaddr_to_nid memory_add_physaddr_to_nid
>> +extern int node_to_phys_lowest_continuous_range(int nid, u64 *start,
>> +u64 *end); #define node_to_phys_lowest_continuous_range
>> +node_to_phys_lowest_continuous_range
>>  #endif /* CONFIG_NUMA_KEEP_MEMINFO */
>>
>>  #endif /* CONFIG_NUMA_MEMBLKS */
>> diff --git a/mm/numa.c b/mm/numa.c
>> index 7d5e06fe5bd4..0affb56ef4f2 100644
>> --- a/mm/numa.c
>> +++ b/mm/numa.c
>> @@ -59,3 +59,13 @@ int phys_to_target_node(u64 start)  }
>> EXPORT_SYMBOL_GPL(phys_to_target_node);
>>  #endif
>> +
>> +#ifndef node_to_phys_lowest_continuous_range
>> +int node_to_phys_lowest_continuous_range(int nid, u64 *start, u64
>> +*end) {
>> +	pr_info_once("Unknown target phys addr range for node=%d\n", nid);
>> +
>> +	return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(node_to_phys_lowest_continuous_range);
>> +#endif
>> diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c index
>> 541a99c4071a..9cbaa38cb92d 100644
>> --- a/mm/numa_memblks.c
>> +++ b/mm/numa_memblks.c
>> @@ -590,4 +590,27 @@ int memory_add_physaddr_to_nid(u64 start)  }
>> EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
>>
>> +static int nid_to_meminfo(struct numa_meminfo *mi, int nid, u64
>> +*start, u64 *end) {
>> +	int i;
>> +
>> +	if (!numa_valid_node(nid))
>> +		return -EINVAL;
>> +
>> +	for (i = 0; i < mi->nr_blks; i++) {
>> +		if (mi->blk[i].nid == nid) {
>> +			*start = mi->blk[i].start;
>> +			*end = mi->blk[i].end;
>> +			return 0;
>> +		}
>> +	}
>> +
>> +	return -ENODEV;
>> +}
>> +
>> +int node_to_phys_lowest_continuous_range(int nid, u64 *start, u64
>> +*end) {
>> +	return nid_to_meminfo(&numa_meminfo, nid, start, end); }
>> +EXPORT_SYMBOL_GPL(node_to_phys_lowest_continuous_range);
>>  #endif /* CONFIG_NUMA_KEEP_MEMINFO */
>> --
>> 2.43.0
>>
>
>--
>Sincerely yours,
>Mike.






[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux