Skip to content

Commit 8301483

Browse files
Wei Lin GuaySomasundaram Krishnasamy
authored andcommitted
net/rds: reduce memory footprint during rds_sendmsg with IB transport
The RDS IB large fragment size feature requires order 2 memory allocations and it introduces memory pressure in the allocation system. Thus, this patch removes this dependency and uses multiple sge in the IB work requests to support large fragment size. Orabug: 27339270 Signed-off-by: Wei Lin Guay <[email protected]> Reviewed-by: Håkon Bugge <[email protected]> Tested-by: Shih-Yu Huang <[email protected]> Acked-by: Santosh Shilimkar <[email protected]> (cherry picked from commit 0a5d76db3b352d06cf677c668d02e0326b20d8b1) (cherry picked from commit c5cc5d4c5fb98f5d4fed920cd615b10f9b91ff00) Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent 159b378 commit 8301483

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

net/rds/ib_send.c

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ static struct rds_message *rds_ib_send_unmap_op(struct rds_ib_connection *ic,
237237
void rds_ib_send_init_ring(struct rds_ib_connection *ic)
238238
{
239239
struct rds_ib_send_work *send;
240+
u32 num_send_sge = ic->i_frag_pages;
240241
u32 i;
242+
u32 j;
241243

242244
for (i = 0, send = ic->i_sends; i < ic->i_send_ring.w_nr; i++, send++) {
243245
struct ib_sge *sge;
@@ -253,7 +255,8 @@ void rds_ib_send_init_ring(struct rds_ib_connection *ic)
253255
sge->length = sizeof(struct rds_header);
254256
sge->lkey = ic->i_mr->lkey;
255257

256-
send->s_sge[1].lkey = ic->i_mr->lkey;
258+
for (j = 1; j <= num_send_sge; j++)
259+
send->s_sge[j].lkey = ic->i_mr->lkey;
257260
}
258261
}
259262

@@ -561,6 +564,7 @@ int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm,
561564
struct rds_ib_send_work *prev;
562565
struct ib_send_wr *failed_wr;
563566
struct scatterlist *scat;
567+
int remaining_sge = 0;
564568
u32 pos;
565569
u32 i;
566570
u32 work_alloc;
@@ -573,7 +577,6 @@ int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm,
573577
int flow_controlled = 0;
574578
int nr_sig = 0;
575579

576-
BUG_ON(off % ic->i_frag_sz);
577580
BUG_ON(hdr_off != 0 && hdr_off != sizeof(struct rds_header));
578581

579582
/* Do not send cong updates to IB loopback */
@@ -715,6 +718,7 @@ int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm,
715718
prev = NULL;
716719
scat = &ic->i_data_op->op_sg[rm->data.op_dmasg];
717720
i = 0;
721+
remaining_sge = rm->data.op_count - sg;
718722
do {
719723
unsigned int len = 0;
720724

@@ -735,20 +739,27 @@ int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm,
735739
/* Set up the data, if present */
736740
if (i < work_alloc
737741
&& scat != &rm->data.op_sg[rm->data.op_count]) {
738-
len = min((unsigned int)ic->i_frag_sz,
739-
ib_sg_dma_len(dev, scat) - rm->data.op_dmaoff);
740-
send->s_wr.num_sge = 2;
741-
742-
send->s_sge[1].addr = ib_sg_dma_address(dev, scat);
743-
send->s_sge[1].addr += rm->data.op_dmaoff;
744-
send->s_sge[1].length = len;
745-
746-
bytes_sent += len;
747-
rm->data.op_dmaoff += len;
748-
if (rm->data.op_dmaoff == ib_sg_dma_len(dev, scat)) {
749-
scat++;
750-
rm->data.op_dmasg++;
751-
rm->data.op_dmaoff = 0;
742+
unsigned int num_sge = min_t(unsigned long, remaining_sge,
743+
ic->i_frag_pages);
744+
unsigned int j = 1;
745+
746+
send->s_wr.num_sge += num_sge;
747+
while (j <= num_sge) {
748+
len = min((unsigned int)PAGE_SIZE,
749+
ib_sg_dma_len(dev, scat) - rm->data.op_dmaoff);
750+
send->s_sge[j].addr = ib_sg_dma_address(dev, scat);
751+
send->s_sge[j].addr += rm->data.op_dmaoff;
752+
send->s_sge[j].length = len;
753+
754+
bytes_sent += len;
755+
rm->data.op_dmaoff += len;
756+
if (rm->data.op_dmaoff == ib_sg_dma_len(dev, scat)) {
757+
scat++;
758+
rm->data.op_dmasg++;
759+
rm->data.op_dmaoff = 0;
760+
}
761+
j++;
762+
remaining_sge--;
752763
}
753764
}
754765

net/rds/send.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
12771277
if (payload_len) {
12781278
rm->data.op_sg = rds_message_alloc_sgs(rm, ceil(payload_len, PAGE_SIZE));
12791279
ret = rds_message_copy_from_user(rm, &msg->msg_iter, GFP_KERNEL,
1280-
large_page);
1280+
false);
12811281
if (ret)
12821282
goto out;
12831283
}

0 commit comments

Comments
 (0)