]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
RDS: added stats to track and display receive side memory usage
authorVenkat Venkatsubra <venkat.x.venkatsubra@oracle.com>
Thu, 8 Aug 2013 05:15:05 +0000 (22:15 -0700)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Wed, 8 Jul 2015 20:59:41 +0000 (13:59 -0700)
Added these stats:
1. per-connection stat for number of receive buffers in cache
2. global stat for the same across all connections
3. number of bytes in socket receive buffer
Since stats are implemented using per-cpu variables and RDS currently
does unsigned arithmetic to add them up, separate counters (one for
addition and one for subtraction) are used for (2) and (3).
In the future we might change it to signed computation.

Orabug: 17045536

Signed-off-by: Venkat Venkatsubra <venkat.x.venkatsubra@oracle.com>
Signed-off-by: Bang Nguyen <bang.nguyen@oracle.com>
(cherry picked from commit 4631300fcf86d459d5dbb09791ff9198c51feab1)

net/rds/ib.h
net/rds/ib_recv.c
net/rds/ib_stats.c
net/rds/rds.h
net/rds/recv.c
net/rds/stats.c

index e85b31a8acfb54386ecff4be74e1cb088cd52b7d..e1bc804f040594a0c9387e3e62a928d2e5bb7461 100644 (file)
@@ -391,6 +391,8 @@ struct rds_ib_statistics {
        uint64_t        s_ib_srq_refills;
        uint64_t        s_ib_srq_empty_refills;
        uint64_t        s_ib_failed_apm;
+       uint64_t        s_ib_recv_added_to_cache;
+       uint64_t        s_ib_recv_removed_from_cache;
 };
 
 extern struct workqueue_struct *rds_ib_wq;
@@ -553,6 +555,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 8b746f1a937c1d89e617cea8f4d6d45805c959ea..1bd9cfcbddb3d760b62704722459ba78bb059965 100644 (file)
@@ -207,7 +207,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_inc(&ic->i_cache_allocs);
+       atomic_add(PAGE_SIZE/1024, &ic->i_cache_allocs);
+       rds_ib_stats_add(s_ib_recv_added_to_cache, PAGE_SIZE);
 }
 
 /* Recycle inc after freeing attached frags */
@@ -285,7 +286,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_dec(&ic->i_cache_allocs);
+               atomic_sub(PAGE_SIZE/1024, &ic->i_cache_allocs);
+               rds_ib_stats_add(s_ib_recv_removed_from_cache, PAGE_SIZE);
        } else {
                frag = kmem_cache_alloc(rds_ib_frag_slab, slab_mask);
                if (!frag)
index c93cc19eb617ebf8cd8b37b1cb6c52c935e08412..2be25a21cdc2317954eab026439794706529c9ec 100644 (file)
@@ -81,6 +81,8 @@ static char *rds_ib_stat_names[] = {
        "ib_srq_refills",
        "ib_srq_empty_refills",
        "ib_apm_reconnect",
+       "ib_recv_cache_added",
+       "ib_recv_cache_removed",
 };
 
 unsigned int rds_ib_stats_info_copy(struct rds_info_iterator *iter,
index a5a362d6e872bca4c22f92e312505f62eae517e4..0e1eb2dfd10980c6ea7bc85850373b93f031dea2 100644 (file)
@@ -617,6 +617,8 @@ struct rds_statistics {
        uint64_t        s_cong_send_error;
        uint64_t        s_cong_send_blocked;
        uint64_t        s_qos_threshold_exceeded;
+       uint64_t        s_recv_bytes_added_to_socket;
+       uint64_t        s_recv_bytes_removed_from_socket;
 };
 
 /* af_rds.c */
index e990f124f7e774a9d1bb3f28b8428e35fa756852..d2fa84bf8d81f45613c50ffbc2473a3178b50034 100644 (file)
@@ -114,6 +114,10 @@ static void rds_recv_rcvbuf_delta(struct rds_sock *rs, struct sock *sk,
                return;
 
        rs->rs_rcv_bytes += delta;
+       if (delta > 0)
+               rds_stats_add(s_recv_bytes_added_to_socket, delta);
+       else
+               rds_stats_add(s_recv_bytes_removed_from_socket, -delta);
        now_congested = rs->rs_rcv_bytes > rds_sk_rcvbuf(rs);
 
        rdsdebug("rs %p (%pI4:%u) recv bytes %d buf %d "
index e341b37c4f78fd2f12bd1acfd5ee5c7546eaed9b..0b9a6c365ad4ad367e791acab4234310e3716e23 100644 (file)
@@ -76,6 +76,8 @@ static char *rds_stat_names[] = {
        "cong_send_error",
        "cong_send_blocked",
        "qos_threshold_exceeded",
+       "recv_bytes_added_to_sock",
+       "recv_bytes_freed_fromsock",
 };
 
 void rds_stats_info_copy(struct rds_info_iterator *iter,