Skip to content

Commit 5f58d7e

Browse files
Wei Lin GuayDhaval Giani
authored andcommitted
net/rds: reduce memory footprint during ib_post_recv in 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 implements large fragment size support in ib_post_recv with N sge. As of today, RDS has an assumption that each IB received work request has only two SGEs. This patch removes this assumption and uses various SGE to support large fragment size. Orabug: 26770234 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]> Signed-off-by: Dhaval Giani <[email protected]>
1 parent b01fd90 commit 5f58d7e

File tree

4 files changed

+151
-82
lines changed

4 files changed

+151
-82
lines changed

net/rds/ib.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2836,32 +2836,37 @@ int rds_ib_inc_to_skb(struct rds_incoming *inc, struct sk_buff *skb)
28362836
int i;
28372837
struct rds_ib_incoming *ibinc;
28382838
struct rds_page_frag *ibfrag;
2839+
struct scatterlist *sg;
28392840

28402841
/* pull out initial pointers */
28412842
ibinc = container_of(inc, struct rds_ib_incoming, ii_inc);
28422843
ibfrag = list_entry(ibinc->ii_frags.next, struct rds_page_frag, f_item);
28432844
len = be32_to_cpu(inc->i_hdr.h_len);
2845+
sg = ibfrag->f_sg;
28442846
slen = len;
28452847
i = 0;
28462848

28472849
/* run through the entire ib fragment list and save off the buffers */
28482850
while (NULL != ibfrag && slen > 0) {
28492851
/* one to one mapping of frags to sg structures */
28502852
frag = &skb_shinfo(skb)->frags[i];
2851-
28522853
/* save off all the sg pieces to the skb frags we are creating */
2853-
frag->size = ibfrag->f_sg.length;
2854-
frag->page_offset = ibfrag->f_sg.offset;
2855-
frag->page.p = sg_page(&ibfrag->f_sg);
2854+
frag->size = sg->length;
2855+
frag->page_offset = sg->offset;
2856+
frag->page.p = sg_page(sg);
28562857

28572858
/* AA: do we need to bump up the page reference */
28582859
/* get_page(frag->page); */
28592860

28602861
/* dec the amount of data we are consuming */
28612862
slen -= frag->size;
28622863

2863-
/* bump to the next entry */
2864-
ibfrag = list_entry(ibfrag->f_item.next, struct rds_page_frag, f_item);
2864+
sg = sg_next(sg);
2865+
if (!sg) {
2866+
/* bump to the next entry */
2867+
ibfrag = list_entry(ibfrag->f_item.next, struct rds_page_frag, f_item);
2868+
sg = ibfrag->f_sg;
2869+
}
28652870
i++;
28662871

28672872
/* for now we will only have a single chain of fragments in the skb */

net/rds/ib.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050

5151
#define RDS_WC_MAX 32
5252

53+
#define NUM_RDS_RECV_SG (PAGE_ALIGN(RDS_MAX_FRAG_SIZE) / PAGE_SIZE)
54+
5355
#define RDS_IB_CLEAN_CACHE 1
5456

5557
#define RDS_IB_DEFAULT_FREG_PORT_NUM 1
@@ -65,7 +67,7 @@ extern struct list_head rds_ib_devices;
6567
struct rds_page_frag {
6668
struct list_head f_item;
6769
struct list_head f_cache_entry;
68-
struct scatterlist f_sg;
70+
struct scatterlist f_sg[NUM_RDS_RECV_SG];
6971
};
7072

7173
struct rds_ib_incoming {
@@ -110,7 +112,7 @@ struct rds_ib_recv_work {
110112
struct rds_ib_incoming *r_ibinc;
111113
struct rds_page_frag *r_frag;
112114
struct ib_recv_wr r_wr;
113-
struct ib_sge r_sge[2];
115+
struct ib_sge r_sge[RDS_IB_MAX_SGE];
114116
struct rds_ib_connection *r_ic;
115117
int r_posted;
116118
};

net/rds/ib_cm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
754754
attr.cap.max_send_wr = ic->i_send_ring.w_nr + 1 + mr_reg;
755755
attr.cap.max_recv_wr = ic->i_recv_ring.w_nr + 1;
756756
attr.cap.max_send_sge = rds_ibdev->max_sge;
757-
attr.cap.max_recv_sge = RDS_IB_RECV_SGE;
757+
attr.cap.max_recv_sge = rds_ibdev->max_sge;
758758
attr.sq_sig_type = IB_SIGNAL_REQ_WR;
759759
attr.qp_type = IB_QPT_RC;
760760
attr.send_cq = ic->i_scq;

0 commit comments

Comments
 (0)