From: Sebastien GODARD Date: Fri, 14 Oct 2016 13:35:18 +0000 (+0200) Subject: sar: Add softnet statistics (part 1): Basic definitions and structures X-Git-Tag: v11.5.2~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=091f484d953d78036c7c999bf2b942cc8947f91e;p=sysstat sar: Add softnet statistics (part 1): Basic definitions and structures Add new switch (-n SOFT) to sar. This option will tell sar to parse /proc/net/softnet_stat file and display corresponding software-based network processing statistics. This first patch defines the needed structures, constants and functions prototypes. sar's help message is also updated. Signed-off-by: Sebastien GODARD --- diff --git a/activity.c b/activity.c index db51517..e087e8d 100644 --- a/activity.c +++ b/activity.c @@ -1413,7 +1413,7 @@ struct activity filesystem_act = { /* Fibre Channel HBA usage activity */ struct activity fchost_act = { .id = A_NET_FC, - .options = AO_CLOSE_MARKUP + AO_GRAPH_PER_ITEM, + .options = AO_GRAPH_PER_ITEM, .magic = ACTIVITY_MAGIC_BASE, .group = G_DISK, #ifdef SOURCE_SADC @@ -1446,6 +1446,42 @@ struct activity fchost_act = { .bitmap = NULL }; +/* Softnet activity */ +struct activity softnet_act = { + .id = A_NET_SOFT, + .options = AO_CLOSE_MARKUP + AO_GRAPH_PER_ITEM, + .magic = ACTIVITY_MAGIC_BASE, + .group = G_DEFAULT, +#ifdef SOURCE_SADC + .f_count_index = 0, /* wrap_get_cpu_nr() */ + .f_count2 = NULL, + .f_read = wrap_read_softnet, +#endif +#ifdef SOURCE_SAR + .f_print = print_softnet_stats, + .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", +#endif +#ifdef SOURCE_SADF + .f_render = render_softnet_stats, + .f_xml_print = xml_print_softnet_stats, + .f_json_print = json_print_softnet_stats, + .f_svg_print = svg_print_softnet_stats, + .name = "A_NET_SOFT", + .g_nr = 2, +#endif + .nr = -1, + .nr2 = 1, + .nr_max = NR_CPUS, + .fsize = STATS_SOFTNET_SIZE, + .msize = STATS_SOFTNET_SIZE, + .opt_flags = 0, + .buf = {NULL, NULL, NULL}, + .bitmap = NULL +}; + #ifdef SOURCE_SADC /* * Array of functions used to count number of items. @@ -1501,7 +1537,8 @@ struct activity *act[NR_ACT] = { &net_icmp6_act, &net_eicmp6_act, &net_udp6_act, - &fchost_act, /* AO_CLOSE_MARKUP */ + &fchost_act, + &softnet_act, /* AO_CLOSE_MARKUP */ /* */ /* */ &pwr_cpufreq_act, diff --git a/json_stats.c b/json_stats.c index f45254e..b0ba12e 100644 --- a/json_stats.c +++ b/json_stats.c @@ -2233,3 +2233,30 @@ close_json_markup: json_markup_network(tab, CLOSE_JSON_MARKUP); } } + +/* + *************************************************************************** + * Display softnet statistics in JSON. + * + * IN: + * @a Activity structure with statistics. + * @curr Index in array for current sample statistics. + * @tab Indentation in output. + * @itv Interval of time in jiffies. + *************************************************************************** + */ +__print_funct_t json_print_softnet_stats(struct activity *a, int curr, int tab, + unsigned long long itv) +{ + if (!IS_SELECTED(a->options) || (a->nr <= 0)) + goto close_json_markup; + + json_markup_network(tab, OPEN_JSON_MARKUP); + + /* FIXME */ + +close_json_markup: + if (CLOSE_MARKUP(a->options)) { + json_markup_network(tab, CLOSE_JSON_MARKUP); + } +} diff --git a/json_stats.h b/json_stats.h index 086ee7b..c5eed2b 100644 --- a/json_stats.h +++ b/json_stats.h @@ -91,5 +91,7 @@ __print_funct_t json_print_filesystem_stats (struct activity *, int, int, unsigned long long); __print_funct_t json_print_fchost_stats (struct activity *, int, int, unsigned long long); +__print_funct_t json_print_softnet_stats + (struct activity *, int, int, unsigned long long); #endif /* _XML_STATS_H */ diff --git a/pr_stats.c b/pr_stats.c index ed2761c..c09c9c6 100644 --- a/pr_stats.c +++ b/pr_stats.c @@ -2725,3 +2725,20 @@ __print_funct_t print_fchost_stats(struct activity *a, int prev, int curr, cprintf_in(IS_STR, " %s\n", sfcc->fchost_name, 0); } } + +/* + *************************************************************************** + * Display softnet statistics. + * + * IN: + * @a Activity structure with statistics. + * @prev Index in array where stats used as reference are. + * @curr Index in array for current sample statistics. + * @itv Interval of time in jiffies. + *************************************************************************** + */ +__print_funct_t print_softnet_stats(struct activity *a, int prev, int curr, + unsigned long long itv) +{ + /* FIXME */ +} diff --git a/pr_stats.h b/pr_stats.h index d695d43..b90b253 100644 --- a/pr_stats.h +++ b/pr_stats.h @@ -92,6 +92,8 @@ __print_funct_t print_filesystem_stats (struct activity *, int, int, unsigned long long); __print_funct_t print_fchost_stats (struct activity *, int, int, unsigned long long); +__print_funct_t print_softnet_stats + (struct activity *, int, int, unsigned long long); /* Functions used to display average statistics */ __print_funct_t print_avg_memory_stats diff --git a/rd_stats.h b/rd_stats.h index a57e6c5..57d1bdb 100644 --- a/rd_stats.h +++ b/rd_stats.h @@ -58,6 +58,7 @@ #define NET_SOCKSTAT6 "/proc/net/sockstat6" #define NET_RPC_NFS "/proc/net/rpc/nfs" #define NET_RPC_NFSD "/proc/net/rpc/nfsd" +#define NET_SOFTNET "/proc/net/softnet_stat" #define LOADAVG "/proc/loadavg" #define VMSTAT "/proc/vmstat" #define NET_SNMP "/proc/net/snmp" @@ -568,6 +569,17 @@ struct stats_fchost { #define STATS_FCHOST_SIZE (sizeof(struct stats_fchost)) +/* Structure for softnet statistics */ +struct stats_softnet { + unsigned long long processed __attribute__ ((aligned (16))); + unsigned long long dropped __attribute__ ((aligned (16))); + unsigned long long time_squeeze __attribute__ ((aligned (16))); + unsigned long long received_rps __attribute__ ((aligned (16))); + unsigned long long flow_limit __attribute__ ((aligned (16))); +}; + +#define STATS_SOFTNET_SIZE (sizeof(struct stats_softnet)) + /* *************************************************************************** * Prototypes for functions used to read system statistics diff --git a/rndr_stats.c b/rndr_stats.c index f30b668..501b31a 100644 --- a/rndr_stats.c +++ b/rndr_stats.c @@ -2984,3 +2984,21 @@ __print_funct_t render_fchost_stats(struct activity *a, int isdb, char *pre, NULL); } } + +/* + *************************************************************************** + * Display softnet statistics in selected format. + * + * IN: + * @a Activity structure with statistics. + * @isdb Flag, true if db printing, false if ppc printing. + * @pre Prefix string for output entries + * @curr Index in array for current sample statistics. + * @itv Interval of time in jiffies. + *************************************************************************** + */ +__print_funct_t render_softnet_stats(struct activity *a, int isdb, char *pre, + int curr, unsigned long long itv) +{ + /* FIXME */ +} diff --git a/rndr_stats.h b/rndr_stats.h index 12f2714..a8cf1c2 100644 --- a/rndr_stats.h +++ b/rndr_stats.h @@ -122,5 +122,7 @@ __print_funct_t render_filesystem_stats (struct activity *, int, char *, int, unsigned long long); __print_funct_t render_fchost_stats (struct activity *, int, char *, int, unsigned long long); +__print_funct_t render_softnet_stats + (struct activity *, int, char *, int, unsigned long long); #endif /* _RNDR_STATS_H */ diff --git a/sa.h b/sa.h index 2cfb4b5..591cf85 100644 --- a/sa.h +++ b/sa.h @@ -20,7 +20,7 @@ */ /* Number of activities */ -#define NR_ACT 38 +#define NR_ACT 39 /* The value below is used for sanity check */ #define MAX_NR_ACT 256 @@ -66,6 +66,7 @@ #define A_PWR_USB 36 #define A_FILESYSTEM 37 #define A_NET_FC 38 +#define A_NET_SOFT 39 /* Macro used to flag an activity that should be collected */ @@ -187,6 +188,7 @@ #define K_FREQ "FREQ" #define K_MOUNT "MOUNT" #define K_FC "FC" +#define K_SOFT "SOFT" #define K_INT "INT" #define K_DISK "DISK" @@ -1068,6 +1070,8 @@ __read_funct_t wrap_read_filesystem (struct activity *); __read_funct_t wrap_read_fchost (struct activity *); +__read_funct_t wrap_read_softnet + (struct activity *); /* Other functions */ void allocate_bitmaps diff --git a/sa_common.c b/sa_common.c index d8bc089..e58f0a1 100644 --- a/sa_common.c +++ b/sa_common.c @@ -1878,6 +1878,9 @@ int parse_sar_n_opt(char *argv[], int *opt, struct activity *act[]) else if (!strcmp(t, K_FC)) { SELECT_ACTIVITY(A_NET_FC); } + else if (!strcmp(t, K_SOFT)) { + SELECT_ACTIVITY(A_NET_SOFT); + } else if (!strcmp(t, K_ALL)) { SELECT_ACTIVITY(A_NET_DEV); SELECT_ACTIVITY(A_NET_EDEV); @@ -1898,6 +1901,7 @@ int parse_sar_n_opt(char *argv[], int *opt, struct activity *act[]) SELECT_ACTIVITY(A_NET_EICMP6); SELECT_ACTIVITY(A_NET_UDP6); SELECT_ACTIVITY(A_NET_FC); + SELECT_ACTIVITY(A_NET_SOFT); } else return 1; diff --git a/sa_wrap.c b/sa_wrap.c index 140c5c0..dc5b6cf 100644 --- a/sa_wrap.c +++ b/sa_wrap.c @@ -901,6 +901,27 @@ __read_funct_t wrap_read_fchost(struct activity *a) return; } +/* + *************************************************************************** + * Read softnet statistics. + * + * IN: + * @a Activity structure. + * + * OUT: + * @a Activity structure with statistics. + *************************************************************************** + */ +__read_funct_t wrap_read_softnet(struct activity *a) +{ + struct stats_softnet *st_softnet + = (struct stats_softnet *) a->_buf0; + + /* Read softnet stats */ + /* FIXME */ + + return; +} /* *************************************************************************** diff --git a/sar.c b/sar.c index 9c4e7e2..978460f 100644 --- a/sar.c +++ b/sar.c @@ -170,7 +170,8 @@ void display_help(char *progname) "\t\tICMP6\tICMP traffic\t(v6)\n" "\t\tEICMP6\tICMP traffic\t(v6) (errors)\n" "\t\tUDP6\tUDP traffic\t(v6)\n" - "\t\tFC\tFibre channel HBAs\n")); + "\t\tFC\tFibre channel HBAs\n" + "\t\tSOFT\tSoftware-based network processing\n")); printf(_("\t-q\tQueue length and load average statistics\n")); printf(_("\t-R\tMemory statistics\n")); printf(_("\t-r [ ALL ]\n" diff --git a/svg_stats.c b/svg_stats.c index bcbd83c..939edb4 100644 --- a/svg_stats.c +++ b/svg_stats.c @@ -4744,3 +4744,25 @@ __print_funct_t svg_print_fchost_stats(struct activity *a, int curr, int action, free_graphs(out, outsize, spmin, spmax); } } + +/* + *************************************************************************** + * Display softnet statistics in SVG. + * + * IN: + * @a Activity structure with statistics. + * @curr Index in array for current sample statistics. + * @action Action expected from current function. + * @svg_p SVG specific parameters: Current graph number (.@graph_no), + * flag indicating that a restart record has been previously + * found (.@restart) and time used for the X axis origin + * (@ust_time_ref). + * @itv Interval of time in jiffies (unused here). + * @record_hdr Pointer on record header of current stats sample. + *************************************************************************** + */ +__print_funct_t svg_print_softnet_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p, + unsigned long long itv, struct record_header *record_hdr) +{ + /* FIXME */ +} diff --git a/svg_stats.h b/svg_stats.h index e92749a..0cdbf76 100644 --- a/svg_stats.h +++ b/svg_stats.h @@ -116,5 +116,8 @@ __print_funct_t svg_print_filesystem_stats __print_funct_t svg_print_fchost_stats (struct activity *, int, int, struct svg_parm *, unsigned long long, struct record_header *); +__print_funct_t svg_print_softnet_stats + (struct activity *, int, int, struct svg_parm *, unsigned long long, + struct record_header *); #endif /* _SVG_STATS_H */ diff --git a/xml_stats.c b/xml_stats.c index 7b57c6d..f18d41b 100644 --- a/xml_stats.c +++ b/xml_stats.c @@ -2118,3 +2118,30 @@ close_xml_markup: xml_markup_network(tab, CLOSE_XML_MARKUP); } } + +/* + *************************************************************************** + * Display softnet statistics in XML. + * + * IN: + * @a Activity structure with statistics. + * @curr Index in array for current sample statistics. + * @tab Indentation in XML output. + * @itv Interval of time in jiffies. + *************************************************************************** + */ +__print_funct_t xml_print_softnet_stats(struct activity *a, int curr, int tab, + unsigned long long itv) +{ + if (!IS_SELECTED(a->options) || (a->nr <= 0)) + goto close_xml_markup; + + xml_markup_network(tab, OPEN_XML_MARKUP); + + /* FIXME */ + +close_xml_markup: + if (CLOSE_MARKUP(a->options)) { + xml_markup_network(tab, CLOSE_XML_MARKUP); + } +} diff --git a/xml_stats.h b/xml_stats.h index 6ac7dea..5642195 100644 --- a/xml_stats.h +++ b/xml_stats.h @@ -91,5 +91,7 @@ __print_funct_t xml_print_filesystem_stats (struct activity *, int, int, unsigned long long); __print_funct_t xml_print_fchost_stats (struct activity *, int, int, unsigned long long); +__print_funct_t xml_print_softnet_stats + (struct activity *, int, int, unsigned long long); #endif /* _XML_STATS_H */