RDS: IB: add few useful cache stasts
authorSantosh Shilimkar <santosh.shilimkar@oracle.com>
Sun, 10 Jul 2016 00:14:02 +0000 (17:14 -0700)
committerSantosh Shilimkar <santosh.shilimkar@oracle.com>
Mon, 2 Jan 2017 22:02:51 +0000 (14:02 -0800)
Tracks the ib receive cache total, incoming and frag allocations.

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
net/rds/ib.h
net/rds/ib_recv.c
net/rds/ib_stats.c

index 5f02b4d8f10c536ccabf931435bb95006ac10d71..c62e5513d306c38c2b058f5eba61fa2eaa582c45 100644 (file)
@@ -151,6 +151,7 @@ struct rds_ib_connection {
        u64                     i_ack_recv;     /* last ACK received */
        struct rds_ib_refill_cache i_cache_incs;
        struct rds_ib_refill_cache i_cache_frags;
+       atomic_t                i_cache_allocs;
 
        /* sending acks */
        unsigned long           i_ack_flags;
@@ -254,6 +255,8 @@ struct rds_ib_statistics {
        uint64_t        s_ib_rx_refill_from_cq;
        uint64_t        s_ib_rx_refill_from_thread;
        uint64_t        s_ib_rx_alloc_limit;
+       uint64_t        s_ib_rx_total_frags;
+       uint64_t        s_ib_rx_total_incs;
        uint64_t        s_ib_rx_credit_updates;
        uint64_t        s_ib_ack_sent;
        uint64_t        s_ib_ack_send_failure;
@@ -276,6 +279,8 @@ struct rds_ib_statistics {
        uint64_t        s_ib_rdma_mr_1m_reused;
        uint64_t        s_ib_atomic_cswp;
        uint64_t        s_ib_atomic_fadd;
+       uint64_t        s_ib_recv_added_to_cache;
+       uint64_t        s_ib_recv_removed_from_cache;
 };
 
 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);
 /* ib_stats.c */
 DECLARE_PER_CPU(struct rds_ib_statistics, rds_ib_stats);
 #define rds_ib_stats_inc(member) rds_stats_inc_which(rds_ib_stats, member)
+#define rds_ib_stats_add(member, count) \
+               rds_stats_add_which(rds_ib_stats, member, count)
 unsigned int rds_ib_stats_info_copy(struct rds_info_iterator *iter,
                                    unsigned int avail);
 
index 6803b75eb8bdfeeb2ea3120e1c3c7c7b68893f06..4b0f12679219f4a7b5a3d085c7725f8a1f4cca77 100644 (file)
@@ -194,6 +194,8 @@ static void rds_ib_frag_free(struct rds_ib_connection *ic,
        rdsdebug("frag %p page %p\n", frag, sg_page(&frag->f_sg));
 
        rds_ib_recv_cache_put(&frag->f_cache_entry, &ic->i_cache_frags);
+       atomic_add(RDS_FRAG_SIZE / SZ_1K, &ic->i_cache_allocs);
+       rds_ib_stats_add(s_ib_recv_added_to_cache, RDS_FRAG_SIZE);
 }
 
 /* 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
                        atomic_dec(&rds_ib_allocation);
                        return NULL;
                }
+               rds_ib_stats_inc(s_ib_rx_total_incs);
        }
        INIT_LIST_HEAD(&ibinc->ii_frags);
        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
        cache_item = rds_ib_recv_cache_get(&ic->i_cache_frags);
        if (cache_item) {
                frag = container_of(cache_item, struct rds_page_frag, f_cache_entry);
+               atomic_sub(RDS_FRAG_SIZE / SZ_1K, &ic->i_cache_allocs);
+               rds_ib_stats_add(s_ib_recv_added_to_cache, RDS_FRAG_SIZE);
        } else {
                frag = kmem_cache_alloc(rds_ib_frag_slab, slab_mask);
                if (!frag)
@@ -290,6 +295,7 @@ static struct rds_page_frag *rds_ib_refill_one_frag(struct rds_ib_connection *ic
                        kmem_cache_free(rds_ib_frag_slab, frag);
                        return NULL;
                }
+               rds_ib_stats_inc(s_ib_rx_total_frags);
        }
 
        INIT_LIST_HEAD(&frag->f_item);
index 7e78dca1f252c671741443cdf660f38da6c575a0..9252ad126335971fa202e5aee6e2babb55d969e0 100644 (file)
@@ -55,6 +55,8 @@ static const char *const rds_ib_stat_names[] = {
        "ib_rx_refill_from_cq",
        "ib_rx_refill_from_thread",
        "ib_rx_alloc_limit",
+       "ib_rx_total_frags",
+       "ib_rx_total_incs",
        "ib_rx_credit_updates",
        "ib_ack_sent",
        "ib_ack_send_failure",