Linux NFS development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@primarydata.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 08/10] sunrpc: convert sp_task_pending flag to use atomic bitops
Date: Wed, 19 Nov 2014 07:51:20 -0500	[thread overview]
Message-ID: <1416401482-2562-9-git-send-email-jlayton@primarydata.com> (raw)
In-Reply-To: <1416401482-2562-1-git-send-email-jlayton@primarydata.com>

In a later patch, we'll want to be able to handle this flag without
holding the sp_lock. Change this field to an unsigned long flags
field, and declare a new flag in it that can be managed with atomic
bitops.

Signed-off-by: Jeff Layton <jlayton@primarydata.com>
---
 include/linux/sunrpc/svc.h | 4 +++-
 net/sunrpc/svc_xprt.c      | 7 +++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 8054a30c8a95..5f0ab39bf7c3 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -50,7 +50,9 @@ struct svc_pool {
 	unsigned int		sp_nrthreads;	/* # of threads in pool */
 	struct list_head	sp_all_threads;	/* all server threads */
 	struct svc_pool_stats	sp_stats;	/* statistics on pool operation */
-	int			sp_task_pending;/* has pending task */
+#define	SP_TASK_PENDING		(0)		/* still work to do even if no
+						 * xprt is queued. */
+	unsigned long		sp_flags;
 } ____cacheline_aligned_in_smp;
 
 /*
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 143c4c8ea2f1..37446046f4bf 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -509,7 +509,7 @@ void svc_wake_up(struct svc_serv *serv)
 			 */
 			wake_up_process(rqstp->rq_task);
 		} else
-			pool->sp_task_pending = 1;
+			set_bit(SP_TASK_PENDING, &pool->sp_flags);
 		spin_unlock_bh(&pool->sp_lock);
 	}
 }
@@ -644,10 +644,9 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
 		 * long for cache updates.
 		 */
 		rqstp->rq_chandle.thread_wait = 1*HZ;
-		pool->sp_task_pending = 0;
+		clear_bit(SP_TASK_PENDING, &pool->sp_flags);
 	} else {
-		if (pool->sp_task_pending) {
-			pool->sp_task_pending = 0;
+		if (test_and_clear_bit(SP_TASK_PENDING, &pool->sp_flags)) {
 			xprt = ERR_PTR(-EAGAIN);
 			goto out;
 		}
-- 
2.1.0


  parent reply	other threads:[~2014-11-19 12:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-19 12:51 [PATCH 00/10] sunrpc: fixes and cleanups for svc creation and thread handling Jeff Layton
2014-11-19 12:51 ` [PATCH 01/10] sunrpc: release svc_pool_map reference when serv allocation fails Jeff Layton
2014-11-19 12:51 ` [PATCH 02/10] sunrpc: add a generic rq_flags field to svc_rqst and move rq_secure to it Jeff Layton
2014-11-19 12:51 ` [PATCH 03/10] sunrpc: move rq_local field to rq_flags Jeff Layton
2014-11-19 12:51 ` [PATCH 04/10] sunrpc: move rq_usedeferral flag " Jeff Layton
2014-11-19 12:51 ` [PATCH 05/10] sunrpc: move rq_dropme flag into rq_flags Jeff Layton
2014-11-19 12:51 ` [PATCH 06/10] sunrpc: move rq_splice_ok " Jeff Layton
2014-11-19 12:51 ` [PATCH 07/10] sunrpc: move rq_cachetype field to better optimize space Jeff Layton
2014-11-19 12:51 ` Jeff Layton [this message]
2014-11-19 12:51 ` [PATCH 09/10] sunrpc: have svc_wake_up only deal with pool 0 Jeff Layton
2014-11-19 12:51 ` [PATCH 10/10] sunrpc: require svc_create callers to pass in meaningful shutdown routine Jeff Layton
2014-11-19 14:57 ` [PATCH 00/10] sunrpc: fixes and cleanups for svc creation and thread handling J. Bruce Fields
2014-11-19 21:37 ` J. Bruce Fields
2014-11-19 21:59   ` Jeff Layton
2014-11-20 14:17     ` Anna Schumaker
2014-12-01 19:56       ` J. Bruce Fields
2014-12-01 20:08         ` Trond Myklebust
2014-12-01 20:12           ` J. Bruce Fields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1416401482-2562-9-git-send-email-jlayton@primarydata.com \
    --to=jlayton@primarydata.com \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox