aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Layton <jlayton@primarydata.com>2014-11-21 14:19:28 -0500
committerJ. Bruce Fields <bfields@redhat.com>2014-12-09 11:22:22 -0500
commit812443865c5fc255363d4a684a62c086af1addca (patch)
treeaed67f73c91814fc0ee5e59d53b8c97a28148074
parent0b5707e4524eb817b7b02863887820d27b56910a (diff)
sunrpc: add a rcu_head to svc_rqst and use kfree_rcu to free it
...also make the manipulation of sp_all_threads list use RCU-friendly functions. Signed-off-by: Jeff Layton <jlayton@primarydata.com> Tested-by: Chris Worley <chris.worley@primarydata.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r--include/linux/sunrpc/svc.h2
-rw-r--r--include/trace/events/sunrpc.h3
-rw-r--r--net/sunrpc/svc.c10
3 files changed, 10 insertions, 5 deletions
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 5f0ab39bf7c3..7f80a99c59e4 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -223,6 +223,7 @@ static inline void svc_putu32(struct kvec *iov, __be32 val)
223struct svc_rqst { 223struct svc_rqst {
224 struct list_head rq_list; /* idle list */ 224 struct list_head rq_list; /* idle list */
225 struct list_head rq_all; /* all threads list */ 225 struct list_head rq_all; /* all threads list */
226 struct rcu_head rq_rcu_head; /* for RCU deferred kfree */
226 struct svc_xprt * rq_xprt; /* transport ptr */ 227 struct svc_xprt * rq_xprt; /* transport ptr */
227 228
228 struct sockaddr_storage rq_addr; /* peer address */ 229 struct sockaddr_storage rq_addr; /* peer address */
@@ -262,6 +263,7 @@ struct svc_rqst {
262#define RQ_SPLICE_OK (4) /* turned off in gss privacy 263#define RQ_SPLICE_OK (4) /* turned off in gss privacy
263 * to prevent encrypting page 264 * to prevent encrypting page
264 * cache pages */ 265 * cache pages */
266#define RQ_VICTIM (5) /* about to be shut down */
265 unsigned long rq_flags; /* flags field */ 267 unsigned long rq_flags; /* flags field */
266 268
267 void * rq_argp; /* decoded arguments */ 269 void * rq_argp; /* decoded arguments */
diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h
index 5848fc235869..08a5fed50f34 100644
--- a/include/trace/events/sunrpc.h
+++ b/include/trace/events/sunrpc.h
@@ -418,7 +418,8 @@ TRACE_EVENT(xs_tcp_data_recv,
418 { (1UL << RQ_LOCAL), "RQ_LOCAL"}, \ 418 { (1UL << RQ_LOCAL), "RQ_LOCAL"}, \
419 { (1UL << RQ_USEDEFERRAL), "RQ_USEDEFERRAL"}, \ 419 { (1UL << RQ_USEDEFERRAL), "RQ_USEDEFERRAL"}, \
420 { (1UL << RQ_DROPME), "RQ_DROPME"}, \ 420 { (1UL << RQ_DROPME), "RQ_DROPME"}, \
421 { (1UL << RQ_SPLICE_OK), "RQ_SPLICE_OK"}) 421 { (1UL << RQ_SPLICE_OK), "RQ_SPLICE_OK"}, \
422 { (1UL << RQ_VICTIM), "RQ_VICTIM"})
422 423
423TRACE_EVENT(svc_recv, 424TRACE_EVENT(svc_recv,
424 TP_PROTO(struct svc_rqst *rqst, int status), 425 TP_PROTO(struct svc_rqst *rqst, int status),
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index a06a891012e5..b90d1bca4349 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -616,7 +616,7 @@ svc_prepare_thread(struct svc_serv *serv, struct svc_pool *pool, int node)
616 serv->sv_nrthreads++; 616 serv->sv_nrthreads++;
617 spin_lock_bh(&pool->sp_lock); 617 spin_lock_bh(&pool->sp_lock);
618 pool->sp_nrthreads++; 618 pool->sp_nrthreads++;
619 list_add(&rqstp->rq_all, &pool->sp_all_threads); 619 list_add_rcu(&rqstp->rq_all, &pool->sp_all_threads);
620 spin_unlock_bh(&pool->sp_lock); 620 spin_unlock_bh(&pool->sp_lock);
621 rqstp->rq_server = serv; 621 rqstp->rq_server = serv;
622 rqstp->rq_pool = pool; 622 rqstp->rq_pool = pool;
@@ -684,7 +684,8 @@ found_pool:
684 * so we don't try to kill it again. 684 * so we don't try to kill it again.
685 */ 685 */
686 rqstp = list_entry(pool->sp_all_threads.next, struct svc_rqst, rq_all); 686 rqstp = list_entry(pool->sp_all_threads.next, struct svc_rqst, rq_all);
687 list_del_init(&rqstp->rq_all); 687 set_bit(RQ_VICTIM, &rqstp->rq_flags);
688 list_del_rcu(&rqstp->rq_all);
688 task = rqstp->rq_task; 689 task = rqstp->rq_task;
689 } 690 }
690 spin_unlock_bh(&pool->sp_lock); 691 spin_unlock_bh(&pool->sp_lock);
@@ -782,10 +783,11 @@ svc_exit_thread(struct svc_rqst *rqstp)
782 783
783 spin_lock_bh(&pool->sp_lock); 784 spin_lock_bh(&pool->sp_lock);
784 pool->sp_nrthreads--; 785 pool->sp_nrthreads--;
785 list_del(&rqstp->rq_all); 786 if (!test_and_set_bit(RQ_VICTIM, &rqstp->rq_flags))
787 list_del_rcu(&rqstp->rq_all);
786 spin_unlock_bh(&pool->sp_lock); 788 spin_unlock_bh(&pool->sp_lock);
787 789
788 kfree(rqstp); 790 kfree_rcu(rqstp, rq_rcu_head);
789 791
790 /* Release the server */ 792 /* Release the server */
791 if (serv) 793 if (serv)