aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-14 15:40:00 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-01-30 02:05:30 -0500
commit3ff7576ddac06c3d07089e241b40826d24bbf1ac (patch)
tree7f5998434b7d0dd1f08ff7ee65c93fab4861a6d3 /net
parentc970aa85e71bd581726c42df843f6f129db275ac (diff)
SUNRPC: Clean up the initialisation of priority queue scheduling info.
We want the default scheduling priority (priority == 0) to remain RPC_PRIORITY_NORMAL. Also ensure that the priority wait queue scheduling is per process id instead of sometimes being per thread, and sometimes being per inode. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/sched.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 10216989309c..b9061bcf6fc1 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -135,7 +135,7 @@ static void __rpc_add_wait_queue_priority(struct rpc_wait_queue *queue, struct r
135 if (unlikely(task->tk_priority > queue->maxpriority)) 135 if (unlikely(task->tk_priority > queue->maxpriority))
136 q = &queue->tasks[queue->maxpriority]; 136 q = &queue->tasks[queue->maxpriority];
137 list_for_each_entry(t, q, u.tk_wait.list) { 137 list_for_each_entry(t, q, u.tk_wait.list) {
138 if (t->tk_cookie == task->tk_cookie) { 138 if (t->tk_owner == task->tk_owner) {
139 list_add_tail(&task->u.tk_wait.list, &t->u.tk_wait.links); 139 list_add_tail(&task->u.tk_wait.list, &t->u.tk_wait.links);
140 return; 140 return;
141 } 141 }
@@ -208,26 +208,26 @@ static inline void rpc_set_waitqueue_priority(struct rpc_wait_queue *queue, int
208 queue->count = 1 << (priority * 2); 208 queue->count = 1 << (priority * 2);
209} 209}
210 210
211static inline void rpc_set_waitqueue_cookie(struct rpc_wait_queue *queue, unsigned long cookie) 211static inline void rpc_set_waitqueue_owner(struct rpc_wait_queue *queue, pid_t pid)
212{ 212{
213 queue->cookie = cookie; 213 queue->owner = pid;
214 queue->nr = RPC_BATCH_COUNT; 214 queue->nr = RPC_BATCH_COUNT;
215} 215}
216 216
217static inline void rpc_reset_waitqueue_priority(struct rpc_wait_queue *queue) 217static inline void rpc_reset_waitqueue_priority(struct rpc_wait_queue *queue)
218{ 218{
219 rpc_set_waitqueue_priority(queue, queue->maxpriority); 219 rpc_set_waitqueue_priority(queue, queue->maxpriority);
220 rpc_set_waitqueue_cookie(queue, 0); 220 rpc_set_waitqueue_owner(queue, 0);
221} 221}
222 222
223static void __rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const char *qname, int maxprio) 223static void __rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const char *qname, unsigned char nr_queues)
224{ 224{
225 int i; 225 int i;
226 226
227 spin_lock_init(&queue->lock); 227 spin_lock_init(&queue->lock);
228 for (i = 0; i < ARRAY_SIZE(queue->tasks); i++) 228 for (i = 0; i < ARRAY_SIZE(queue->tasks); i++)
229 INIT_LIST_HEAD(&queue->tasks[i]); 229 INIT_LIST_HEAD(&queue->tasks[i]);
230 queue->maxpriority = maxprio; 230 queue->maxpriority = nr_queues - 1;
231 rpc_reset_waitqueue_priority(queue); 231 rpc_reset_waitqueue_priority(queue);
232#ifdef RPC_DEBUG 232#ifdef RPC_DEBUG
233 queue->name = qname; 233 queue->name = qname;
@@ -236,12 +236,12 @@ static void __rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const c
236 236
237void rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const char *qname) 237void rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const char *qname)
238{ 238{
239 __rpc_init_priority_wait_queue(queue, qname, RPC_PRIORITY_HIGH); 239 __rpc_init_priority_wait_queue(queue, qname, RPC_NR_PRIORITY);
240} 240}
241 241
242void rpc_init_wait_queue(struct rpc_wait_queue *queue, const char *qname) 242void rpc_init_wait_queue(struct rpc_wait_queue *queue, const char *qname)
243{ 243{
244 __rpc_init_priority_wait_queue(queue, qname, 0); 244 __rpc_init_priority_wait_queue(queue, qname, 1);
245} 245}
246EXPORT_SYMBOL_GPL(rpc_init_wait_queue); 246EXPORT_SYMBOL_GPL(rpc_init_wait_queue);
247 247
@@ -456,12 +456,12 @@ static struct rpc_task * __rpc_wake_up_next_priority(struct rpc_wait_queue *queu
456 struct rpc_task *task; 456 struct rpc_task *task;
457 457
458 /* 458 /*
459 * Service a batch of tasks from a single cookie. 459 * Service a batch of tasks from a single owner.
460 */ 460 */
461 q = &queue->tasks[queue->priority]; 461 q = &queue->tasks[queue->priority];
462 if (!list_empty(q)) { 462 if (!list_empty(q)) {
463 task = list_entry(q->next, struct rpc_task, u.tk_wait.list); 463 task = list_entry(q->next, struct rpc_task, u.tk_wait.list);
464 if (queue->cookie == task->tk_cookie) { 464 if (queue->owner == task->tk_owner) {
465 if (--queue->nr) 465 if (--queue->nr)
466 goto out; 466 goto out;
467 list_move_tail(&task->u.tk_wait.list, q); 467 list_move_tail(&task->u.tk_wait.list, q);
@@ -470,7 +470,7 @@ static struct rpc_task * __rpc_wake_up_next_priority(struct rpc_wait_queue *queu
470 * Check if we need to switch queues. 470 * Check if we need to switch queues.
471 */ 471 */
472 if (--queue->count) 472 if (--queue->count)
473 goto new_cookie; 473 goto new_owner;
474 } 474 }
475 475
476 /* 476 /*
@@ -492,8 +492,8 @@ static struct rpc_task * __rpc_wake_up_next_priority(struct rpc_wait_queue *queu
492 492
493new_queue: 493new_queue:
494 rpc_set_waitqueue_priority(queue, (unsigned int)(q - &queue->tasks[0])); 494 rpc_set_waitqueue_priority(queue, (unsigned int)(q - &queue->tasks[0]));
495new_cookie: 495new_owner:
496 rpc_set_waitqueue_cookie(queue, task->tk_cookie); 496 rpc_set_waitqueue_owner(queue, task->tk_owner);
497out: 497out:
498 __rpc_wake_up_task(task); 498 __rpc_wake_up_task(task);
499 return task; 499 return task;
@@ -830,8 +830,8 @@ void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *task_setu
830 task->tk_garb_retry = 2; 830 task->tk_garb_retry = 2;
831 task->tk_cred_retry = 2; 831 task->tk_cred_retry = 2;
832 832
833 task->tk_priority = RPC_PRIORITY_NORMAL; 833 task->tk_priority = task_setup_data->priority - RPC_PRIORITY_LOW;
834 task->tk_cookie = (unsigned long)current; 834 task->tk_owner = current->tgid;
835 835
836 /* Initialize workqueue for async tasks */ 836 /* Initialize workqueue for async tasks */
837 task->tk_workqueue = rpciod_workqueue; 837 task->tk_workqueue = rpciod_workqueue;