2023-07-18 06:45:11

by NeilBrown

[permalink] [raw]
Subject: [PATCH 12/14] SUNRPC: discard SP_CONGESTED

We can tell if a pool is congested by checking if the idle list is
empty. We don't need a separate flag.

Signed-off-by: NeilBrown <[email protected]>
---
include/linux/sunrpc/svc.h | 1 -
include/trace/events/sunrpc.h | 1 -
net/sunrpc/svc.c | 1 -
net/sunrpc/svc_xprt.c | 4 +---
4 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index ec8088d5b57f..f5b69e6da0f8 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -51,7 +51,6 @@ struct svc_pool {
/* bits for sp_flags */
enum {
SP_TASK_PENDING, /* still work to do even if no xprt is queued */
- SP_CONGESTED, /* all threads are busy, none idle */
SP_NEED_VICTIM, /* One thread needs to agree to exit */
SP_VICTIM_REMAINS, /* One thread needs to actually exit */
};
diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h
index dd0323c40ef5..470c5ba07fba 100644
--- a/include/trace/events/sunrpc.h
+++ b/include/trace/events/sunrpc.h
@@ -2040,7 +2040,6 @@ TRACE_EVENT(svc_xprt_enqueue,
#define show_svc_pool_flags(x) \
__print_flags(x, "|", \
{ BIT(SP_TASK_PENDING), "TASK_PENDING" }, \
- { BIT(SP_CONGESTED), "CONGESTED" }, \
{ BIT(SP_NEED_VICTIM), "NEED_VICTIM" }, \
{ BIT(SP_VICTIM_REMAINS), "VICTIM_REMAINS" })
DECLARE_EVENT_CLASS(svc_pool_scheduler_class,
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 028de8f662a8..f6da390932cd 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -721,7 +721,6 @@ void svc_pool_wake_idle_thread(struct svc_serv *serv,

trace_svc_pool_starved(serv, pool);
percpu_counter_inc(&pool->sp_threads_starved);
- set_bit(SP_CONGESTED, &pool->sp_flags);
}
EXPORT_SYMBOL_GPL(svc_pool_wake_idle_thread);

diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 1d134415ae3f..b82a66f68f17 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -734,8 +734,6 @@ static void svc_wait_for_work(struct svc_rqst *rqstp)
struct svc_pool *pool = rqstp->rq_pool;

set_current_state(TASK_IDLE);
- smp_mb__before_atomic();
- clear_bit(SP_CONGESTED, &pool->sp_flags);
spin_lock_bh(&pool->sp_lock);
list_add(&rqstp->rq_idle, &pool->sp_idle_threads);
spin_unlock_bh(&pool->sp_lock);
@@ -787,7 +785,7 @@ static void svc_wait_for_work(struct svc_rqst *rqstp)
/* Normally we will wait up to 5 seconds for any required
* cache information to be provided.
*/
- if (!test_bit(SP_CONGESTED, &pool->sp_flags))
+ if (!list_empty(&pool->sp_idle_threads))
rqstp->rq_chandle.thread_wait = 5*HZ;
else
rqstp->rq_chandle.thread_wait = 1*HZ;