Skip to contentSkip to conversation

percpu: remove code with no effect

PATCH Applied Sang-Heon Jeon 1 participant 5 messages Sep 1

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover percpu: remove code with no effect

Hello,

While reading the percpu initialization path, I found some minor cleanups for unnecessary initializations and an obsolete return statement.

No functional change.

Sang-Heon Jeon (4):
percpu: remove redundant assignments to bits
percpu: remove unnecessary initialization in pcpu_build_alloc_info()
percpu: remove unnecessary cpumask_clear() in pcpu_build_alloc_info()
percpu: remove unnecessary return in pcpu_populate_pte()

 mm/percpu.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/4 percpu: remove redundant assignments to bits

pcpu_chunk_refresh_hint() and pcpu_find_block_fit() set bits to 0 and later call pcpu_next_md_free_region() or pcpu_next_fit_region(), which unconditionally set *bits to 0. Nothing uses it in between, so the assignments have no effect.

Remove redundant assignments.

No functional change.

---
 mm/percpu.c | 2 --
 1 file changed, 2 deletions(-)
mm/percpu.c +0 -2
index a802d72c116f..5700385fe6a4 100644
@@ -758,7 +758,6 @@ static void pcpu_chunk_refresh_hint(struct pcpu_chunk *chunk, bool full_scan)
 		chunk_md->contig_hint = 0;
 	}
 
-	bits = 0;
 	pcpu_for_each_md_free_region(chunk, bit_off, bits)
 		pcpu_block_update(chunk_md, bit_off, bit_off + bits);
 }
@@ -1122,7 +1121,6 @@ static int pcpu_find_block_fit(struct pcpu_chunk *chunk, int alloc_bits,
 		return -1;
 
 	bit_off = pcpu_next_hint(chunk_md, alloc_bits);
-	bits = 0;
 	pcpu_for_each_fit_region(chunk, alloc_bits, align, bit_off, bits) {
 		if (!pop_only || pcpu_is_populated(chunk, bit_off, bits,
 						   &next_off))
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/4 percpu: remove unnecessary initialization in pcpu_build_alloc_info()

In reply to Sang-Heon Jeon

pcpu_build_alloc_info() initializes nr_groups to 1 and unconditionally sets it to the number of groups. Nothing uses it in between, so the initialization has no effect.

Remove unnecessary initialization.

No functional change.

---
 mm/percpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/percpu.c +1 -1
index 5700385fe6a4..f222b43cc90a 100644
@@ -2817,7 +2817,7 @@ static struct pcpu_alloc_info * __init __flatten pcpu_build_alloc_info(
 	static int group_cnt[NR_CPUS] __initdata;
 	static struct cpumask mask __initdata;
 	const size_t static_size = __per_cpu_end - __per_cpu_start;
-	int nr_groups = 1, nr_units = 0;
+	int nr_groups, nr_units = 0;
 	size_t size_sum, min_unit_size, alloc_size;
 	int upa, max_upa, best_upa;	/* units_per_alloc */
 	int last_allocs, group, unit;
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/4 percpu: remove unnecessary cpumask_clear() in pcpu_build_alloc_info()

In reply to Sang-Heon Jeon

pcpu_build_alloc_info() clears mask and unconditionally sets it to cpu_possible_mask. Nothing uses it in between, so cpumask_clear() has no effect.

Remove unnecessary cpumask_clear().

No functional change.

---
 mm/percpu.c | 1 -
 1 file changed, 1 deletion(-)
mm/percpu.c +0 -1
index f222b43cc90a..45f3e3fda2f9 100644
@@ -2828,7 +2828,6 @@ static struct pcpu_alloc_info * __init __flatten pcpu_build_alloc_info(
 	/* this function may be called multiple times */
 	memset(group_map, 0, sizeof(group_map));
 	memset(group_cnt, 0, sizeof(group_cnt));
-	cpumask_clear(&mask);
 
 	/* calculate size_sum and ensure dyn_size is enough for early alloc */
 	size_sum = PFN_ALIGN(static_size + reserved_size +
Signature · 1 line
2.43.0
#4 lore raw

PATCH 4/4 percpu: remove unnecessary return in pcpu_populate_pte()

In reply to Sang-Heon Jeon

Since commit c6f239796b55 ("mm/memblock: add memblock_alloc_or_panic interface"), pcpu_populate_pte() no longer has an error label after the return statement, so the return statement has no effect.

Remove unnecessary return.

No functional change.

---
 mm/percpu.c | 2 --
 1 file changed, 2 deletions(-)
mm/percpu.c +0 -2
index 45f3e3fda2f9..9df6cdf636fd 100644
@@ -3178,8 +3178,6 @@ void __init __weak pcpu_populate_pte(unsigned long addr)
 		new = memblock_alloc_or_panic(PTE_TABLE_SIZE, PTE_TABLE_SIZE);
 		pmd_populate_kernel(&init_mm, pmd, new);
 	}
-
-	return;
 }
 
 /**
Signature · 1 line
2.43.0