Skip to contentSkip to conversation

rcu: Stop shrinker loop

PATCH Applied Peter Enderborg 3 participants 4 messages Jun 4, 2020 RCU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rcu: Stop shrinker loop

The count and scan can be separated in time. It is a fair chance that all work is already done when the scan starts. It then might retry. This is can be avoided with returning SHRINK_STOP.

---
 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +1 -1
index c716eadc7617..8b36c6b2887d 100644
@@ -3310,7 +3310,7 @@ kfree_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 			break;
 	}
 
-	return freed;
+	return freed == 0 ? SHRINK_STOP : freed;
 }
 
 static struct shrinker kfree_rcu_shrinker = {
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Peter Enderborg

The count and scan can be separated in time. It is a fair chance that all work is already done when the scan starts. It then might retry. This is can be avoided with returning SHRINK_STOP.

---
 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +0 -0
index c716eadc7617..8b36c6b2887d 100644

kernel/rcu/tree.c kfree_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) · line 3315

Quoted 7 lines
kernel/rcu/tree.c +1 -1
@@ -3310,7 +3310,7 @@ kfree_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 			break;
 	}
 
-	return freed;
+	return freed == 0 ? SHRINK_STOP : freed;
 }
 

The loop will be stopped anyway sooner or later, but sooner is better :) To me that change makes sense.

--
Vlad Rezki

maintainer Applied
#2 lore raw
Quoted 18 lines · Uladzislau Rezki
Quoted 17 lines · Peter Enderborg

The count and scan can be separated in time. It is a fair chance that all work is already done when the scan starts. It then might retry. This is can be avoided with returning SHRINK_STOP.

---
 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +0 -0
index c716eadc7617..8b36c6b2887d 100644
@@ -3310,7 +3310,7 @@ kfree_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 			break;
 	}
 
Quoted 8 lines

kernel/rcu/tree.c kfree_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) · line 3315

Quoted 4 lines
kernel/rcu/tree.c +1 -1
-	return freed;
+	return freed == 0 ? SHRINK_STOP : freed;
 }
 

The loop will be stopped anyway sooner or later, but sooner is better :) To me that change makes sense.

Queued, thank you both!

Thanx, Paul

maintainer
#3 lore raw
Quoted 26 lines · Uladzislau Rezki
Quoted 25 lines · Peter Enderborg
Quoted 14 lines

The count and scan can be separated in time. It is a fair chance that all work is already done when the scan starts. It then might retry. This is can be avoided with returning SHRINK_STOP.

---
 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +0 -0
index c716eadc7617..8b36c6b2887d 100644

kernel/rcu/tree.c kfree_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) · line 3315

Quoted 7 lines
kernel/rcu/tree.c +1 -1
@@ -3310,7 +3310,7 @@ kfree_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 			break;
 	}
 
-	return freed;
+	return freed == 0 ? SHRINK_STOP : freed;
 }
 

The loop will be stopped anyway sooner or later, but sooner is better :) To me that change makes sense.

Quoted 4 lines
Quoted 1 line

Queued, thank you both!

Thank you, Paul!

--
Vlad Rezki