Skip to contentSkip to conversation

sched/topology: avoid calling synchronize_rcu()

PATCH In review [email protected] 2 participants 2 messages Mar 2, 2022 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/topology: avoid calling synchronize_rcu()

From: Lv Ruyi (CGEL ZTE) <[email protected]>

Kfree_rcu() usually results in even simpler code than does synchronize_rcu() without synchronize_rcu()'s multi-millisecond latency, so replace synchronize_rcu() with kfree_rcu().

---
 kernel/sched/topology.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/sched/topology.c +1 -2
index 974212620fa1..0ce302b4d732 100644
@@ -1970,8 +1970,7 @@ static void sched_reset_numa(void)
 	if (distances || masks) {
 		int i, j;
 
-		synchronize_rcu();
-		kfree(distances);
+		kfree_rcu(distances);
 		for (i = 0; i < nr_levels && masks; i++) {
 			if (!masks[i])
 				continue;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 17 lines · On 02/03/22 01:14, [email protected] wrote:

From: Lv Ruyi (CGEL ZTE) <[email protected]>

Kfree_rcu() usually results in even simpler code than does synchronize_rcu() without synchronize_rcu()'s multi-millisecond latency, so replace synchronize_rcu() with kfree_rcu().

---
 kernel/sched/topology.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/sched/topology.c +0 -0
index 974212620fa1..0ce302b4d732 100644

kernel/sched/topology.c static void sched_reset_numa(void) · line 1973

Quoted 6 lines
kernel/sched/topology.c +1 -2
@@ -1970,8 +1970,7 @@ static void sched_reset_numa(void)
      if (distances || masks) {
              int i, j;
 
-		synchronize_rcu();
-		kfree(distances);
+		kfree_rcu(distances);

What about the freeing of the cpumasks below? You don't want to free those before the end of the grace period either. With that in mind, I think the current synchronize_rcu() + batch of kfree()'s is fine, it's a slow path anyway (hotplug).

Quoted 5 lines
kernel/sched/topology.c +0 -1
              for (i = 0; i < nr_levels && masks; i++) {
                      if (!masks[i])
                              continue;
--

2.25.1