From: Venkat Venkatsubra Date: Thu, 8 Aug 2013 05:15:05 +0000 (-0700) Subject: RDS: added stats to track and display receive side memory usage X-Git-Tag: v4.1.12-92~293^2^2~50 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=47d7d46bbe9adb5fec9ec24c8c5b467e9ad5687b;p=users%2Fjedix%2Flinux-maple.git RDS: added stats to track and display receive side memory usage 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 Signed-off-by: Bang Nguyen (cherry picked from commit 4631300fcf86d459d5dbb09791ff9198c51feab1) --- diff --git a/net/rds/ib.h b/net/rds/ib.h index e85b31a8acfb5..e1bc804f04059 100644 --- a/net/rds/ib.h +++ b/net/rds/ib.h @@ -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); diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c index 8b746f1a937c1..1bd9cfcbddb3d 100644 --- a/net/rds/ib_recv.c +++ b/net/rds/ib_recv.c @@ -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) diff --git a/net/rds/ib_stats.c b/net/rds/ib_stats.c index c93cc19eb617e..2be25a21cdc23 100644 --- a/net/rds/ib_stats.c +++ b/net/rds/ib_stats.c @@ -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, diff --git a/net/rds/rds.h b/net/rds/rds.h index a5a362d6e872b..0e1eb2dfd1098 100644 --- a/net/rds/rds.h +++ b/net/rds/rds.h @@ -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 */ diff --git a/net/rds/recv.c b/net/rds/recv.c index e990f124f7e77..d2fa84bf8d81f 100644 --- a/net/rds/recv.c +++ b/net/rds/recv.c @@ -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 " diff --git a/net/rds/stats.c b/net/rds/stats.c index e341b37c4f78f..0b9a6c365ad4a 100644 --- a/net/rds/stats.c +++ b/net/rds/stats.c @@ -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,