From 42035f6605355a5014f590199f5d58f74005f032 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sat, 26 Mar 2022 15:42:09 +0100 Subject: [PATCH] sar: A_NET_SOFT: Add new metric: softnet backlog length Signed-off-by: Sebastien GODARD --- activity.c | 4 ++-- pr_stats.c | 2 ++ rd_stats.c | 5 +++-- rd_stats.h | 3 ++- sa_common.c | 7 +++++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/activity.c b/activity.c index eff8ba1..0053987 100644 --- a/activity.c +++ b/activity.c @@ -1837,7 +1837,7 @@ struct activity softnet_act = { .f_print_avg = print_softnet_stats, #endif #if defined(SOURCE_SAR) || defined(SOURCE_SADF) - .hdr_line = "CPU;total/s;dropd/s;squeezd/s;rx_rps/s;flw_lim/s", + .hdr_line = "CPU;total/s;dropd/s;squeezd/s;rx_rps/s;flw_lim/s;blg_len", #endif .gtypes_nr = {STATS_SOFTNET_ULL, STATS_SOFTNET_UL, STATS_SOFTNET_U}, .ftypes_nr = {0, 0, 0}, @@ -1854,7 +1854,7 @@ struct activity softnet_act = { #endif .name = "A_NET_SOFT", .item_list_sz = 0, - .g_nr = 2, + .g_nr = 3, .nr_ini = -1, .nr2 = 1, .nr_max = NR_CPUS + 1, diff --git a/pr_stats.c b/pr_stats.c index 2cd29fc..6d4de97 100644 --- a/pr_stats.c +++ b/pr_stats.c @@ -3078,6 +3078,8 @@ __print_funct_t print_softnet_stats(struct activity *a, int prev, int curr, S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv), S_VALUE(ssnp->received_rps, ssnc->received_rps, itv), S_VALUE(ssnp->flow_limit, ssnc->flow_limit, itv)); + cprintf_u64(NO_UNIT, 1, 9, + (unsigned long long) ssnc->backlog_len); printf("\n"); } } diff --git a/rd_stats.c b/rd_stats.c index bcaa890..0bee03c 100644 --- a/rd_stats.c +++ b/rd_stats.c @@ -2813,15 +2813,16 @@ int read_softnet(struct stats_softnet *st_softnet, __nr_t nr_alloc, while (fgets(line, sizeof(line), fp) != NULL) { - i = sscanf(line, "%x %x %x %*x %*x %*x %*x %*x %*x %x %x %*x %x", + i = sscanf(line, "%x %x %x %*x %*x %*x %*x %*x %*x %x %x %x %x", &(st_softnet_read.processed), &(st_softnet_read.dropped), &(st_softnet_read.time_squeeze), &(st_softnet_read.received_rps), &(st_softnet_read.flow_limit), + &(st_softnet_read.backlog_len), &cpu_id); - if (i == 6) { + if (i == 7) { /* Corresponding CPU read in file */ cpu = cpu_id + 1; } diff --git a/rd_stats.h b/rd_stats.h index d79e8f7..e9560d4 100644 --- a/rd_stats.h +++ b/rd_stats.h @@ -711,12 +711,13 @@ struct stats_softnet { unsigned int time_squeeze; unsigned int received_rps; unsigned int flow_limit; + unsigned int backlog_len; }; #define STATS_SOFTNET_SIZE (sizeof(struct stats_softnet)) #define STATS_SOFTNET_ULL 0 #define STATS_SOFTNET_UL 0 -#define STATS_SOFTNET_U 5 +#define STATS_SOFTNET_U 6 /* Structure for pressure-stall CPU statistics */ struct stats_psi_cpu { diff --git a/sa_common.c b/sa_common.c index ef631f3..035c07d1 100644 --- a/sa_common.c +++ b/sa_common.c @@ -3240,7 +3240,8 @@ void get_global_soft_statistics(struct activity *a, int prev, int curr, ssnp = (struct stats_softnet *) ((char *) a->buf[prev] + i * a->msize); if ((ssnp->processed + ssnp->dropped + ssnp->time_squeeze + - ssnp->received_rps + ssnp->flow_limit == 0) && !WANT_SINCE_BOOT(flags)) { + ssnp->received_rps + ssnp->flow_limit + ssnp->backlog_len == 0) && + !WANT_SINCE_BOOT(flags)) { /* * No previous sample for current CPU: Don't display it unless * we want stats since last boot time. @@ -3252,7 +3253,7 @@ void get_global_soft_statistics(struct activity *a, int prev, int curr, } if (ssnc->processed + ssnc->dropped + ssnc->time_squeeze + - ssnc->received_rps + ssnc->flow_limit == 0) { + ssnc->received_rps + ssnc->flow_limit + ssnc->backlog_len == 0) { /* Assume current CPU is offline */ *ssnc = *ssnp; offline_cpu_bitmap[i >> 3] |= 1 << (i & 0x07); @@ -3263,12 +3264,14 @@ void get_global_soft_statistics(struct activity *a, int prev, int curr, ssnc_all->time_squeeze += ssnc->time_squeeze; ssnc_all->received_rps += ssnc->received_rps; ssnc_all->flow_limit += ssnc->flow_limit; + ssnc_all->backlog_len += ssnc->backlog_len; ssnp_all->processed += ssnp->processed; ssnp_all->dropped += ssnp->dropped; ssnp_all->time_squeeze += ssnp->time_squeeze; ssnp_all->received_rps += ssnp->received_rps; ssnp_all->flow_limit += ssnp->flow_limit; + ssnp_all->backlog_len += ssnp->backlog_len; } } -- 2.40.0