Skip to content

Commit 3f15746

Browse files
kcp-gitSomasundaram Krishnasamy
authored andcommitted
net/rds: Recycle RDS headers to speed up connection fail over
At fail over time, a connection's headers are freed and then re-allocated again based on the underlying device. Since fail over only happens between ports of the same device, it means that the freed headers may be re-used. This commit delays the headers deallocation. When headers need to allocated, it checks if the previously "freed" headers can be re-used. If yes, those headers are re-used. If not, new headers will be allocated. The delayed time can be changed using the sysctl net.rds.ib.dma_hdrs_free_delay. The default value is 10 seconds. Under normal conditions, this delay does not need to be that long and this value should do no harm. But in successive fail over and back testing, a short delay can cause unnecessary de-allocation. Orabug: 30434704 Fixes: 10b43f1 ("net/rds: Use DMA memory pool allocation for rds_header") Signed-off-by: Ka-Cheong Poon <[email protected]> Reviewed-by: Håkon Bugge <[email protected]> Tested-by: Håkon Bugge <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent 2d70f84 commit 3f15746

File tree

3 files changed

+198
-107
lines changed

3 files changed

+198
-107
lines changed

net/rds/ib.h

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -184,28 +184,28 @@ struct rds_ib_rx_work {
184184
struct rds_ib_connection *ic;
185185
};
186186

187-
/* Structure for the DMA headers pool deallocation work */
188-
struct rds_dma_hdrs_free_wk {
189-
struct work_struct rdhf_work;
190-
struct dma_pool *rdhf_pool; /* Pool for the headers. */
187+
/* Time (in millisec) to wait before deallocating the RDS connection headers.
188+
*/
189+
extern u32 rds_hdrs_free_wait_ms;
191190

191+
/* Structure for storing all the DMA headers */
192+
struct rds_dma_hdrs {
192193
/* Info of headers for sending. */
193-
struct rds_header **rdhf_snd_hdrs;
194-
dma_addr_t *rdhf_snd_dma_addrs;
195-
u32 rdhf_snd_num_hdrs;
194+
struct rds_header **rdh_snd_hdrs;
195+
dma_addr_t *rdh_snd_dma_addrs;
196+
u32 rdh_snd_num_hdrs;
196197

197198
/* Info of headers for receiving. */
198-
struct rds_header **rdhf_rcv_hdrs;
199-
dma_addr_t *rdhf_rcv_dma_addrs;
200-
u32 rdhf_rcv_num_hdrs;
199+
struct rds_header **rdh_rcv_hdrs;
200+
dma_addr_t *rdh_rcv_dma_addrs;
201+
u32 rdh_rcv_num_hdrs;
201202

202203
/* Info of the ACK header. */
203-
struct rds_header *rdhf_ack_rds_hdr;
204-
dma_addr_t rdhf_ack_dma_addr;
204+
struct rds_header *rdh_ack_hdr;
205+
dma_addr_t rdh_ack_dma_addr;
205206
};
206207

207208
struct rds_ib_connection {
208-
209209
struct list_head ib_node;
210210
struct rds_ib_device *rds_ibdev;
211211
struct rds_connection *conn;
@@ -227,11 +227,21 @@ struct rds_ib_connection {
227227
struct tasklet_struct i_stasklet;
228228
struct tasklet_struct i_rtasklet;
229229

230+
struct rds_dma_hdrs i_hdrs;
231+
232+
/* Quick access to the fields of struct rds_dma_hdrs */
233+
#define i_send_hdrs i_hdrs.rdh_snd_hdrs
234+
#define i_send_hdrs_dma i_hdrs.rdh_snd_dma_addrs
235+
#define i_send_num_hdrs i_hdrs.rdh_snd_num_hdrs
236+
#define i_recv_hdrs i_hdrs.rdh_rcv_hdrs
237+
#define i_recv_hdrs_dma i_hdrs.rdh_rcv_dma_addrs
238+
#define i_recv_num_hdrs i_hdrs.rdh_rcv_num_hdrs
239+
#define i_ack i_hdrs.rdh_ack_hdr
240+
#define i_ack_dma i_hdrs.rdh_ack_dma_addr
241+
230242
/* tx */
231243
struct rds_ib_work_ring i_send_ring;
232244
struct rm_data_op *i_data_op;
233-
struct rds_header **i_send_hdrs;
234-
dma_addr_t *i_send_hdrs_dma;
235245
struct rds_ib_send_work *i_sends;
236246
atomic_t i_signaled_sends;
237247

@@ -241,8 +251,6 @@ struct rds_ib_connection {
241251
struct rds_ib_work_ring i_recv_ring;
242252
struct rds_ib_incoming *i_ibinc;
243253
u32 i_recv_data_rem;
244-
struct rds_header **i_recv_hdrs;
245-
dma_addr_t *i_recv_hdrs_dma;
246254
struct rds_ib_recv_work *i_recvs;
247255
u64 i_ack_recv; /* last ACK received */
248256
struct rds_ib_refill_cache i_cache_incs;
@@ -256,12 +264,15 @@ struct rds_ib_connection {
256264
spinlock_t i_ack_lock; /* protect i_ack_next */
257265
u64 i_ack_next; /* next ACK to send */
258266
#endif
259-
struct rds_header *i_ack;
260267
struct ib_send_wr i_ack_wr;
261268
struct ib_sge i_ack_sge;
262-
u64 i_ack_dma;
263269
unsigned long i_ack_queued;
264270

271+
/* Lock for synchronizing with clean up worker */
272+
spinlock_t i_hdrs_lock;
273+
struct dma_pool *i_saved_hdrs_pool; /* Pool for the headers. */
274+
struct delayed_work i_hdrs_free_work;
275+
265276
/* Flow control related information
266277
*
267278
* Our algorithm uses a pair variables that we need to access

0 commit comments

Comments
 (0)