Skip to content

Commit c05eecf

Browse files
Trond MyklebustTrond Myklebust
authored andcommitted
SUNRPC: Don't allow low priority tasks to pre-empt higher priority ones
Currently, the priority queues attempt to be 'fair' to lower priority tasks by scheduling them after a certain number of higher priority tasks have run. The problem is that both the transport send queue and the NFSv4.1 session slot queue have strong ordering requirements. This patch therefore removes the fairness code in favour of strong ordering of task priorities. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent b75ad4c commit c05eecf

2 files changed

Lines changed: 22 additions & 23 deletions

File tree

‎include/linux/sunrpc/sched.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ struct rpc_wait_queue {
192192
pid_t owner; /* process id of last task serviced */
193193
unsigned char maxpriority; /* maximum priority (0 if queue is not a priority queue) */
194194
unsigned char priority; /* current priority */
195-
unsigned char count; /* # task groups remaining serviced so far */
196195
unsigned char nr; /* # tasks remaining for cookie */
197196
unsigned short qlen; /* total # tasks waiting in queue */
198197
struct rpc_timer timer_list;

‎net/sunrpc/sched.c‎

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,23 @@ __rpc_add_timer(struct rpc_wait_queue *queue, struct rpc_task *task)
9898
list_add(&task->u.tk_wait.timer_list, &queue->timer_list.list);
9999
}
100100

101+
static void rpc_set_waitqueue_priority(struct rpc_wait_queue *queue, int priority)
102+
{
103+
queue->priority = priority;
104+
}
105+
106+
static void rpc_set_waitqueue_owner(struct rpc_wait_queue *queue, pid_t pid)
107+
{
108+
queue->owner = pid;
109+
queue->nr = RPC_BATCH_COUNT;
110+
}
111+
112+
static void rpc_reset_waitqueue_priority(struct rpc_wait_queue *queue)
113+
{
114+
rpc_set_waitqueue_priority(queue, queue->maxpriority);
115+
rpc_set_waitqueue_owner(queue, 0);
116+
}
117+
101118
/*
102119
* Add new request to a priority queue.
103120
*/
@@ -109,9 +126,11 @@ static void __rpc_add_wait_queue_priority(struct rpc_wait_queue *queue,
109126
struct rpc_task *t;
110127

111128
INIT_LIST_HEAD(&task->u.tk_wait.links);
112-
q = &queue->tasks[queue_priority];
113129
if (unlikely(queue_priority > queue->maxpriority))
114-
q = &queue->tasks[queue->maxpriority];
130+
queue_priority = queue->maxpriority;
131+
if (queue_priority > queue->priority)
132+
rpc_set_waitqueue_priority(queue, queue_priority);
133+
q = &queue->tasks[queue_priority];
115134
list_for_each_entry(t, q, u.tk_wait.list) {
116135
if (t->tk_owner == task->tk_owner) {
117136
list_add_tail(&task->u.tk_wait.list, &t->u.tk_wait.links);
@@ -180,24 +199,6 @@ static void __rpc_remove_wait_queue(struct rpc_wait_queue *queue, struct rpc_tas
180199
task->tk_pid, queue, rpc_qname(queue));
181200
}
182201

183-
static inline void rpc_set_waitqueue_priority(struct rpc_wait_queue *queue, int priority)
184-
{
185-
queue->priority = priority;
186-
queue->count = 1 << (priority * 2);
187-
}
188-
189-
static inline void rpc_set_waitqueue_owner(struct rpc_wait_queue *queue, pid_t pid)
190-
{
191-
queue->owner = pid;
192-
queue->nr = RPC_BATCH_COUNT;
193-
}
194-
195-
static inline void rpc_reset_waitqueue_priority(struct rpc_wait_queue *queue)
196-
{
197-
rpc_set_waitqueue_priority(queue, queue->maxpriority);
198-
rpc_set_waitqueue_owner(queue, 0);
199-
}
200-
201202
static void __rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const char *qname, unsigned char nr_queues)
202203
{
203204
int i;
@@ -464,8 +465,7 @@ static struct rpc_task *__rpc_find_next_queued_priority(struct rpc_wait_queue *q
464465
/*
465466
* Check if we need to switch queues.
466467
*/
467-
if (--queue->count)
468-
goto new_owner;
468+
goto new_owner;
469469
}
470470

471471
/*

0 commit comments

Comments
 (0)