mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 05:04:02 +02:00
Merge patch series "treewide: remove unnecessary invalid range checks in memblock iteration loops"
Sang-Heon Jeon <ekffu200098@gmail.com> says:
treewide: remove unnecessary invalid range checks in memblock iteration loops
The memblock API guarantees that for_each_mem_range() and
for_each_mem_pfn_range() never return an invalid range, meaning start is
always less than end.
Several memblock callers still have unnecessary invalid range checks in
their loop bodies, so remove them.
Patches 1-6 cover for_each_mem_range() callers. memblock never stores a
zero-size region, so the range it returns always has start < end. Some
callers apply __va() or __phys_to_virt() before comparing, but these keep
start < end too, so the check is unreachable.
Patches 7-8 cover for_each_mem_pfn_range() callers. __next_mem_pfn_range()
skips any region that does not contain a whole page, so it only ever returns
start_pfn < end_pfn and the check is unnecessary.
For reference, commit 36ca7f4be8 ("arm64: mm: Remove bogus stop
condition from map_mem() loop") did a similar cleanup in arm64 map_mem().
* patches from https://patch.msgid.link/20260630150413.1718632-1-ekffu200098@gmail.com
arm64: mm: remove unreachable invalid range check in kasan_init_shadow()
LoongArch: remove unreachable invalid range check in kasan_init()
riscv: remove unreachable invalid range check in
create_linear_mapping_page_table()
riscv: remove unreachable invalid range check in kasan_init()
ARM: remove unreachable invalid range check in kasan_init()
powerpc64/kasan: Remove unreachable invalid range check in
kasan_init_phys_region()
mm: remove unnecessary empty range check in early_calculate_totalpages()
mm/hugetlb: remove unnecessary empty range check in
hugetlb_bootmem_set_nodes()
Link: https://patch.msgid.link/20260630150413.1718632-1-ekffu200098@gmail.com
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
This commit is contained in:
commit
b45533e67a
|
|
@ -262,12 +262,6 @@ void __init kasan_init(void)
|
|||
&pa_start, &pa_end, &arm_lowmem_limit);
|
||||
end = __va(arm_lowmem_limit);
|
||||
}
|
||||
if (start >= end) {
|
||||
pr_info("Skipping invalid memory block %pa-%pa (virtual %p-%p)\n",
|
||||
&pa_start, &pa_end, start, end);
|
||||
continue;
|
||||
}
|
||||
|
||||
create_mapping(start, end);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -353,9 +353,6 @@ static void __init kasan_init_shadow(void)
|
|||
void *start = (void *)__phys_to_virt(pa_start);
|
||||
void *end = (void *)__phys_to_virt(pa_end);
|
||||
|
||||
if (start >= end)
|
||||
break;
|
||||
|
||||
kasan_map_populate((unsigned long)kasan_mem_to_shadow(start),
|
||||
(unsigned long)kasan_mem_to_shadow(end),
|
||||
early_pfn_to_nid(virt_to_pfn(start)));
|
||||
|
|
|
|||
|
|
@ -305,9 +305,6 @@ void __init kasan_init(void)
|
|||
void *start = (void *)phys_to_virt(pa_start);
|
||||
void *end = (void *)phys_to_virt(pa_end);
|
||||
|
||||
if (start >= end)
|
||||
break;
|
||||
|
||||
kasan_map_populate((unsigned long)mem_to_shadow(start),
|
||||
(unsigned long)mem_to_shadow(end), NUMA_NO_NODE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,9 +68,6 @@ static void __init kasan_init_phys_region(void *start, void *end)
|
|||
unsigned long k_start, k_end, k_cur;
|
||||
void *va;
|
||||
|
||||
if (start >= end)
|
||||
return;
|
||||
|
||||
k_start = ALIGN_DOWN((unsigned long)kasan_mem_to_shadow(start), PAGE_SIZE);
|
||||
k_end = ALIGN((unsigned long)kasan_mem_to_shadow(end), PAGE_SIZE);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,6 @@ static void __init kasan_init_phys_region(void *start, void *end)
|
|||
unsigned long k_start, k_end, k_cur;
|
||||
void *va;
|
||||
|
||||
if (start >= end)
|
||||
return;
|
||||
|
||||
k_start = ALIGN_DOWN((unsigned long)kasan_mem_to_shadow(start), PAGE_SIZE);
|
||||
k_end = ALIGN((unsigned long)kasan_mem_to_shadow(end), PAGE_SIZE);
|
||||
|
||||
|
|
|
|||
|
|
@ -1229,8 +1229,6 @@ static void __init create_linear_mapping_page_table(void)
|
|||
|
||||
/* Map all memory banks in the linear mapping */
|
||||
for_each_mem_range(i, &start, &end) {
|
||||
if (start >= end)
|
||||
break;
|
||||
if (start <= __pa(PAGE_OFFSET) &&
|
||||
__pa(PAGE_OFFSET) < end)
|
||||
start = __pa(PAGE_OFFSET);
|
||||
|
|
|
|||
|
|
@ -512,9 +512,6 @@ void __init kasan_init(void)
|
|||
void *start = (void *)__va(p_start);
|
||||
void *end = (void *)__va(p_end);
|
||||
|
||||
if (start >= end)
|
||||
break;
|
||||
|
||||
kasan_populate(kasan_mem_to_shadow(start), kasan_mem_to_shadow(end));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4444,15 +4444,12 @@ hugetlb_early_param("default_hugepagesz", default_hugepagesz_setup);
|
|||
void __init hugetlb_bootmem_set_nodes(void)
|
||||
{
|
||||
int i, nid;
|
||||
unsigned long start_pfn, end_pfn;
|
||||
|
||||
if (!nodes_empty(hugetlb_bootmem_nodes))
|
||||
return;
|
||||
|
||||
for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) {
|
||||
if (end_pfn > start_pfn)
|
||||
node_set(nid, hugetlb_bootmem_nodes);
|
||||
}
|
||||
for_each_mem_pfn_range(i, MAX_NUMNODES, NULL, NULL, &nid)
|
||||
node_set(nid, hugetlb_bootmem_nodes);
|
||||
}
|
||||
|
||||
void __init hugetlb_bootmem_alloc(void)
|
||||
|
|
|
|||
|
|
@ -332,8 +332,7 @@ static unsigned long __init early_calculate_totalpages(void)
|
|||
unsigned long pages = end_pfn - start_pfn;
|
||||
|
||||
totalpages += pages;
|
||||
if (pages)
|
||||
node_set_state(nid, N_MEMORY);
|
||||
node_set_state(nid, N_MEMORY);
|
||||
}
|
||||
return totalpages;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user