From: Wei Lin Guay Date: Fri, 20 Nov 2015 23:14:48 +0000 (-0800) Subject: RDS: fix the sg allocation based on actual message size X-Git-Tag: v4.1.12-92~175^2~13 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=23f90cccfba4d320e40913eea8afe5dc729ae146;p=users%2Fjedix%2Flinux-maple.git RDS: fix the sg allocation based on actual message size Fix an issue where only PAGE_SIZE bytes are allocated per scatter-gather entry (SGE) regardless of the actual message size: Furthermore, use buddy memory allocation technique to allocate/free memmory (if possible) to reduce SGE. Orabug: 21894138 Signed-off-by: Wei Lin Guay Signed-off-by: Santosh Shilimkar --- diff --git a/net/rds/message.c b/net/rds/message.c index ab535e2cb184..f0e540094ed3 100644 --- a/net/rds/message.c +++ b/net/rds/message.c @@ -63,7 +63,10 @@ static void rds_message_purge(struct rds_message *rm) for (i = 0; i < rm->data.op_nents; i++) { rdsdebug("putting data page %p\n", (void *)sg_page(&rm->data.op_sg[i])); /* XXX will have to put_page for page refs */ - __free_page(sg_page(&rm->data.op_sg[i])); + (rm->data.op_sg[i].length <= PAGE_SIZE) ? + __free_page(sg_page(&rm->data.op_sg[i])) : + __free_pages(sg_page(&rm->data.op_sg[i]), + get_order(rm->data.op_sg[i].length)); } rm->data.op_nents = 0; diff --git a/net/rds/page.c b/net/rds/page.c index e35a92fde68f..c09f29655dfd 100644 --- a/net/rds/page.c +++ b/net/rds/page.c @@ -127,11 +127,11 @@ int rds_page_remainder_alloc(struct scatterlist *scat, unsigned long bytes, /* jump straight to allocation if we're trying for a huge page */ if (bytes >= PAGE_SIZE) { - page = alloc_page(gfp); + page = alloc_pages(gfp, get_order(bytes)); if (!page) { ret = -ENOMEM; } else { - sg_set_page(scat, page, PAGE_SIZE, 0); + sg_set_page(scat, page, bytes, 0); ret = 0; } goto out;