From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <sthemmin@microsoft.com>,
Stephen Hemminger <stephen@networkplumber.org>
Subject: [RFC iproute2-next 5/5] ss: use correct slab statistics
Date: Wed, 2 May 2018 13:28:01 -0700 [thread overview]
Message-ID: <20180502202801.5255-6-stephen@networkplumber.org> (raw)
In-Reply-To: <20180502202801.5255-1-stephen@networkplumber.org>
From: Stephen Hemminger <sthemmin@microsoft.com>
The slabinfo names changed years ago, and ss statistics were broken.
This changes to use current slab names and handle TCP IPv6.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
misc/ss.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 97304cd8abfc..66c767cc415b 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -742,12 +742,12 @@ static int get_slabstat(struct slabstat *s)
{
char buf[256];
FILE *fp;
- int cnt;
+ int *stats = (int *) s;
static int slabstat_valid;
static const char * const slabstat_ids[] = {
- "sock",
- "tcp_tw_bucket",
- "tcp_open_request",
+ "sock_inode_cache",
+ "tw_sock_TCP",
+ "request_sock_TCP",
};
if (slabstat_valid)
@@ -759,24 +759,23 @@ static int get_slabstat(struct slabstat *s)
if (!fp)
return -1;
- cnt = sizeof(*s)/sizeof(int);
-
if (!fgets(buf, sizeof(buf), fp)) {
fclose(fp);
return -1;
}
+
while (fgets(buf, sizeof(buf), fp) != NULL) {
- int i;
+ int i, v;
for (i = 0; i < ARRAY_SIZE(slabstat_ids); i++) {
- if (memcmp(buf, slabstat_ids[i], strlen(slabstat_ids[i])) == 0) {
- sscanf(buf, "%*s%d", ((int *)s) + i);
- cnt--;
+ if (memcmp(buf, slabstat_ids[i], strlen(slabstat_ids[i])) != 0)
+ continue;
+
+ if (sscanf(buf, "%*s%d", &v) == 1) {
+ stats[i] += v;
break;
}
}
- if (cnt <= 0)
- break;
}
slabstat_valid = 1;
--
2.17.0
prev parent reply other threads:[~2018-05-02 20:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-02 20:27 [RFC iproute2-next 0/5] ss statistics fixes Stephen Hemminger
2018-05-02 20:27 ` [RFC iproute2-next 1/5] ss: make args to get_snmp_int const Stephen Hemminger
2018-05-02 20:27 ` [RFC iproute2-next 2/5] ss: make tcp_mem long Stephen Hemminger
2018-05-02 21:08 ` Eric Dumazet
2018-05-02 21:29 ` Stephen Hemminger
2018-05-02 20:27 ` [RFC iproute2-next 3/5] ss: use sockstat to get TCP bind ports Stephen Hemminger
2018-05-02 20:28 ` [RFC iproute2-next 4/5] ss: don't look for skbuff_head_cache Stephen Hemminger
2018-05-02 20:28 ` Stephen Hemminger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180502202801.5255-6-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=netdev@vger.kernel.org \
--cc=sthemmin@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).