Skip to contentSkip to conversation

bcachefs: Remove unnecessary kthread_should_stop()

PATCH In review Kevin Hao 3 participants 4 messages Dec 16, 2023 – Jan 4, 2024

lore
Share & tools
lore

Kevin Hao

author
#0 lore raw

PATCH 1/1 bcachefs: Remove unnecessary kthread_should_stop()

In the macro kthread_wait_freezable(), there is already a check for kthread_should_stop(), so there is no need to pass kthread_should_stop() as a parameter to kthread_wait_freezable().

---
 fs/bcachefs/movinggc.c  | 3 +--
 fs/bcachefs/rebalance.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
fs/bcachefs/movinggc.c +1 -2
index fd239a261aca..bc1ec877a66b 100644
@@ -345,8 +345,7 @@ static int bch2_copygc_thread(void *arg)
 
 		if (!c->copy_gc_enabled) {
 			move_buckets_wait(&ctxt, buckets, true);
-			kthread_wait_freezable(c->copy_gc_enabled ||
-					       kthread_should_stop());
+			kthread_wait_freezable(c->copy_gc_enabled);
 		}
 
 		if (unlikely(freezing(current))) {
fs/bcachefs/rebalance.c +1 -2
index ee452aa51a26..b83dd613e247 100644
@@ -334,8 +334,7 @@ static int do_rebalance(struct moving_context *ctxt)
 	while (!bch2_move_ratelimit(ctxt)) {
 		if (!r->enabled) {
 			bch2_moving_ctxt_flush_all(ctxt);
-			kthread_wait_freezable(r->enabled ||
-					       kthread_should_stop());
+			kthread_wait_freezable(r->enabled);
 		}
 
 		if (kthread_should_stop())
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Kevin Hao

In the macro kthread_wait_freezable(), there is already a check for kthread_should_stop(), so there is no need to pass kthread_should_stop() as a parameter to kthread_wait_freezable().

---

Looks right to me:

Quoted 35 lines
 fs/bcachefs/movinggc.c  | 3 +--
 fs/bcachefs/rebalance.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
fs/bcachefs/movinggc.c +1 -2
index fd239a261aca..bc1ec877a66b 100644
@@ -345,8 +345,7 @@ static int bch2_copygc_thread(void *arg)
 
 		if (!c->copy_gc_enabled) {
 			move_buckets_wait(&ctxt, buckets, true);
-			kthread_wait_freezable(c->copy_gc_enabled ||
-					       kthread_should_stop());
+			kthread_wait_freezable(c->copy_gc_enabled);
 		}
 
 		if (unlikely(freezing(current))) {
fs/bcachefs/rebalance.c +1 -2
index ee452aa51a26..b83dd613e247 100644
@@ -334,8 +334,7 @@ static int do_rebalance(struct moving_context *ctxt)
 	while (!bch2_move_ratelimit(ctxt)) {
 		if (!r->enabled) {
 			bch2_moving_ctxt_flush_all(ctxt);
-			kthread_wait_freezable(r->enabled ||
-					       kthread_should_stop());
+			kthread_wait_freezable(r->enabled);
 		}
 
 		if (kthread_should_stop())
Signature · 1 line
2.39.2
#2 lore raw
Quoted 11 lines · Brian Foster
Quoted 6 lines · Kevin Hao

In the macro kthread_wait_freezable(), there is already a check for kthread_should_stop(), so there is no need to pass kthread_should_stop() as a parameter to kthread_wait_freezable().

---

Looks right to me:

It is technically correct, but recently the issues have been more with having too few kthread_should_stop() calls, not too many; I think I want to leave this for now, even though it's redundant it's more explicit.

#3 lore raw
Quoted 9 lines · Kent Overstreet
Quoted 8 lines · Brian Foster
Quoted 6 lines · Kevin Hao

In the macro kthread_wait_freezable(), there is already a check for kthread_should_stop(), so there is no need to pass kthread_should_stop() as a parameter to kthread_wait_freezable().

---

Quoted 8 lines
Quoted 3 lines

Looks right to me:

It is technically correct, but recently the issues have been more with having too few kthread_should_stop() calls, not too many; I think I want to leave this for now, even though it's redundant it's more explicit.

What recent issues do you mean? ISTM this logic serves more as a placebo than anything. Is there a more explicit issue to dig into?

Brian