Skip to content

Commit 6859d1f

Browse files
neilbrownchucklever
authored andcommitted
SUNRPC: make rqst_should_sleep() idempotent()
Based on its name you would think that rqst_should_sleep() would be read-only, not changing anything. But in fact it will clear SP_TASK_PENDING if that was set. This is surprising, and it blurs the line between "check for work to do" and "dequeue work to do". So change the "test_and_clear" to simple "test" and clear the bit once the thread has decided to wake up and return to the caller. With this, it makes sense to *always* set SP_TASK_PENDING when asked, rather than to set it only if no thread could be woken up. [ cel: Previously TASK_PENDING indicated there is work waiting but no idle threads were found to pick up that work. After this patch, it acts as an XPT_BUSY flag for wake-ups that have no associated xprt. ] Signed-off-by: NeilBrown <neilb@suse.de> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent d2f0ef1 commit 6859d1f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

net/sunrpc/svc_xprt.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,8 @@ void svc_wake_up(struct svc_serv *serv)
581581
{
582582
struct svc_pool *pool = &serv->sv_pools[0];
583583

584-
if (!svc_pool_wake_idle_thread(pool))
585-
set_bit(SP_TASK_PENDING, &pool->sp_flags);
584+
set_bit(SP_TASK_PENDING, &pool->sp_flags);
585+
svc_pool_wake_idle_thread(pool);
586586
}
587587
EXPORT_SYMBOL_GPL(svc_wake_up);
588588

@@ -704,7 +704,7 @@ rqst_should_sleep(struct svc_rqst *rqstp)
704704
struct svc_pool *pool = rqstp->rq_pool;
705705

706706
/* did someone call svc_wake_up? */
707-
if (test_and_clear_bit(SP_TASK_PENDING, &pool->sp_flags))
707+
if (test_bit(SP_TASK_PENDING, &pool->sp_flags))
708708
return false;
709709

710710
/* was a socket queued? */
@@ -748,6 +748,7 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp)
748748

749749
set_bit(RQ_BUSY, &rqstp->rq_flags);
750750
smp_mb__after_atomic();
751+
clear_bit(SP_TASK_PENDING, &pool->sp_flags);
751752
rqstp->rq_xprt = svc_xprt_dequeue(pool);
752753
if (rqstp->rq_xprt)
753754
goto out_found;
@@ -756,6 +757,7 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp)
756757
return NULL;
757758
return NULL;
758759
out_found:
760+
clear_bit(SP_TASK_PENDING, &pool->sp_flags);
759761
/* Normally we will wait up to 5 seconds for any required
760762
* cache information to be provided.
761763
*/

0 commit comments

Comments
 (0)