Skip to content

Commit e38b3f2

Browse files
neilbrownchucklever
authored andcommitted
SUNRPC: don't pause on incomplete allocation
alloc_pages_bulk_array() attempts to allocate at least one page based on the provided pages, and then opportunistically allocates more if that can be done without dropping the spinlock. So if it returns fewer than requested, that could just mean that it needed to drop the lock. In that case, try again immediately. Only pause for a time if no progress could be made. Reported-and-tested-by: Mike Javorski <[email protected]> Reported-and-tested-by: Lothar Paltins <[email protected]> Fixes: f6e70aa ("SUNRPC: refresh rq_pages using a bulk page allocator") Signed-off-by: NeilBrown <[email protected]> Acked-by: Mel Gorman <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 0bcc7ca commit e38b3f2

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

net/sunrpc/svc_xprt.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ static int svc_alloc_arg(struct svc_rqst *rqstp)
663663
{
664664
struct svc_serv *serv = rqstp->rq_server;
665665
struct xdr_buf *arg = &rqstp->rq_arg;
666-
unsigned long pages, filled;
666+
unsigned long pages, filled, ret;
667667

668668
pagevec_init(&rqstp->rq_pvec);
669669

@@ -675,11 +675,12 @@ static int svc_alloc_arg(struct svc_rqst *rqstp)
675675
pages = RPCSVC_MAXPAGES;
676676
}
677677

678-
for (;;) {
679-
filled = alloc_pages_bulk_array(GFP_KERNEL, pages,
680-
rqstp->rq_pages);
681-
if (filled == pages)
682-
break;
678+
for (filled = 0; filled < pages; filled = ret) {
679+
ret = alloc_pages_bulk_array(GFP_KERNEL, pages,
680+
rqstp->rq_pages);
681+
if (ret > filled)
682+
/* Made progress, don't sleep yet */
683+
continue;
683684

684685
set_current_state(TASK_INTERRUPTIBLE);
685686
if (signalled() || kthread_should_stop()) {

0 commit comments

Comments
 (0)