Skip to content

Commit 09b2b8f

Browse files
RDS: IB: add few useful cache stasts
Tracks the ib receive cache total, incoming and frag allocations. Signed-off-by: Santosh Shilimkar <[email protected]>
1 parent 581d53c commit 09b2b8f

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

net/rds/ib.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ struct rds_ib_connection {
151151
u64 i_ack_recv; /* last ACK received */
152152
struct rds_ib_refill_cache i_cache_incs;
153153
struct rds_ib_refill_cache i_cache_frags;
154+
atomic_t i_cache_allocs;
154155

155156
/* sending acks */
156157
unsigned long i_ack_flags;
@@ -254,6 +255,8 @@ struct rds_ib_statistics {
254255
uint64_t s_ib_rx_refill_from_cq;
255256
uint64_t s_ib_rx_refill_from_thread;
256257
uint64_t s_ib_rx_alloc_limit;
258+
uint64_t s_ib_rx_total_frags;
259+
uint64_t s_ib_rx_total_incs;
257260
uint64_t s_ib_rx_credit_updates;
258261
uint64_t s_ib_ack_sent;
259262
uint64_t s_ib_ack_send_failure;
@@ -276,6 +279,8 @@ struct rds_ib_statistics {
276279
uint64_t s_ib_rdma_mr_1m_reused;
277280
uint64_t s_ib_atomic_cswp;
278281
uint64_t s_ib_atomic_fadd;
282+
uint64_t s_ib_recv_added_to_cache;
283+
uint64_t s_ib_recv_removed_from_cache;
279284
};
280285

281286
extern struct workqueue_struct *rds_ib_wq;
@@ -406,6 +411,8 @@ int rds_ib_xmit_atomic(struct rds_connection *conn, struct rm_atomic_op *op);
406411
/* ib_stats.c */
407412
DECLARE_PER_CPU(struct rds_ib_statistics, rds_ib_stats);
408413
#define rds_ib_stats_inc(member) rds_stats_inc_which(rds_ib_stats, member)
414+
#define rds_ib_stats_add(member, count) \
415+
rds_stats_add_which(rds_ib_stats, member, count)
409416
unsigned int rds_ib_stats_info_copy(struct rds_info_iterator *iter,
410417
unsigned int avail);
411418

net/rds/ib_recv.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ static void rds_ib_frag_free(struct rds_ib_connection *ic,
194194
rdsdebug("frag %p page %p\n", frag, sg_page(&frag->f_sg));
195195

196196
rds_ib_recv_cache_put(&frag->f_cache_entry, &ic->i_cache_frags);
197+
atomic_add(RDS_FRAG_SIZE / SZ_1K, &ic->i_cache_allocs);
198+
rds_ib_stats_add(s_ib_recv_added_to_cache, RDS_FRAG_SIZE);
197199
}
198200

199201
/* Recycle inc after freeing attached frags */
@@ -261,6 +263,7 @@ static struct rds_ib_incoming *rds_ib_refill_one_inc(struct rds_ib_connection *i
261263
atomic_dec(&rds_ib_allocation);
262264
return NULL;
263265
}
266+
rds_ib_stats_inc(s_ib_rx_total_incs);
264267
}
265268
INIT_LIST_HEAD(&ibinc->ii_frags);
266269
rds_inc_init(&ibinc->ii_inc, ic->conn, ic->conn->c_faddr);
@@ -278,6 +281,8 @@ static struct rds_page_frag *rds_ib_refill_one_frag(struct rds_ib_connection *ic
278281
cache_item = rds_ib_recv_cache_get(&ic->i_cache_frags);
279282
if (cache_item) {
280283
frag = container_of(cache_item, struct rds_page_frag, f_cache_entry);
284+
atomic_sub(RDS_FRAG_SIZE / SZ_1K, &ic->i_cache_allocs);
285+
rds_ib_stats_add(s_ib_recv_added_to_cache, RDS_FRAG_SIZE);
281286
} else {
282287
frag = kmem_cache_alloc(rds_ib_frag_slab, slab_mask);
283288
if (!frag)
@@ -290,6 +295,7 @@ static struct rds_page_frag *rds_ib_refill_one_frag(struct rds_ib_connection *ic
290295
kmem_cache_free(rds_ib_frag_slab, frag);
291296
return NULL;
292297
}
298+
rds_ib_stats_inc(s_ib_rx_total_frags);
293299
}
294300

295301
INIT_LIST_HEAD(&frag->f_item);

net/rds/ib_stats.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ static const char *const rds_ib_stat_names[] = {
5555
"ib_rx_refill_from_cq",
5656
"ib_rx_refill_from_thread",
5757
"ib_rx_alloc_limit",
58+
"ib_rx_total_frags",
59+
"ib_rx_total_incs",
5860
"ib_rx_credit_updates",
5961
"ib_ack_sent",
6062
"ib_ack_send_failure",

0 commit comments

Comments
 (0)