netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@idosch.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, idosch@nvidia.com, mkubecek@suse.cz
Subject: Re: [RFC ethtool 6/6] netlink: add support for standard stats
Date: Sat, 17 Apr 2021 22:22:57 +0300	[thread overview]
Message-ID: <YHs1kSQWxJf03uqV@shredder.lan> (raw)
In-Reply-To: <20210417114728.660490a4@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>

On Sat, Apr 17, 2021 at 11:47:28AM -0700, Jakub Kicinski wrote:
> On Sat, 17 Apr 2021 21:14:40 +0300 Ido Schimmel wrote:
> > > +	if (!is_json_context()) {
> > > +		fprintf(stdout, "rmon-%s-etherStatsPkts",
> > > +			mnl_attr_get_type(hist) == ETHTOOL_A_STATS_GRP_HIST_RX ?
> > > +			"rx" : "tx");
> > > +
> > > +		if (low && hi) {
> > > +			fprintf(stdout, "%uto%uOctets: %llu\n", low, hi, val);
> > > +		} else if (hi) {
> > > +			fprintf(stdout, "%uOctets: %llu\n", hi, val);
> > > +		} else if (low) {
> > > +			fprintf(stdout, "%utoMaxOctets: %llu\n", low, val);
> > > +		} else {
> > > +			fprintf(stderr, "invalid kernel response - bad histogram entry bounds\n");
> > > +			return 1;
> > > +		}
> > > +	} else {
> > > +		open_json_object(NULL);
> > > +		print_uint(PRINT_JSON, "low", NULL, low);
> > > +		print_uint(PRINT_JSON, "high", NULL, hi);
> > > +		print_u64(PRINT_JSON, "val", NULL, val);  
> > 
> > In the non-JSON output you distinguish between Rx/Tx, but it's missing
> > from the JSON output as can be seen in your example:
> > 
> > ```
> >        "pktsNtoM": [
> >          {
> >            "low": 0,
> >            "high": 64,
> >            "val": 1
> >          },
> >          {
> >            "low": 128,
> >            "high": 255,
> >            "val": 1
> >          },
> >          {
> >            "low": 1024,
> >            "high": 0,
> >            "val": 0
> >          }
> >        ]
> > ```
> > 
> > I see that mlxsw and mlx5 only support Rx, but it's going to be
> > confusing with bnxt that supports both Rx and Tx.
> 
> Good catch! I added Tx last minute (even though it's non standard).
> I'll split split into two arrays - "rx-pktsNtoM" and "tx-pktsNtoM",
> sounds good? Or we can add a layer: ["pktsNtoM"]["rx"] etc.

I'm fine with both, but I think the first form will be easier when
working with jq to extract Rx/Tx. It is also more inline with the
current nesting of the netlink attributes.

> 
> > Made me think about the structure of these attributes. Currently you
> > have:
> > 
> > ETHTOOL_A_STATS_GRP_HIST_RX
> > 	ETHTOOL_A_STATS_GRP_HIST_BKT_LOW
> > 	ETHTOOL_A_STATS_GRP_HIST_BKT_HI
> > 	ETHTOOL_A_STATS_GRP_HIST_VAL
> > 
> > ETHTOOL_A_STATS_GRP_HIST_TX
> > 	ETHTOOL_A_STATS_GRP_HIST_BKT_LOW
> > 	ETHTOOL_A_STATS_GRP_HIST_BKT_HI
> > 	ETHTOOL_A_STATS_GRP_HIST_VAL
> > 
> > Did you consider:
> > 
> > ETHTOOL_A_STATS_GRP_HIST
> > 	ETHTOOL_A_STATS_GRP_HIST_BKT_LOW
> > 	ETHTOOL_A_STATS_GRP_HIST_BKT_HI
> > 	ETHTOOL_A_STATS_GRP_HIST_VAL
> > 	ETHTOOL_A_STATS_GRP_HIST_BKT_UNITS
> > 	ETHTOOL_A_STATS_GRP_HIST_TYPE
> 
> I went back and forth on that. The reason I put the direction in the
> type is that normal statistics don't have an extra _TYPE or direction.
> 
> It will also be easier to break the stats out to arrays if they are
> typed on the outside, see below.
> 
> > So you will have something like:
> > 
> > ETHTOOL_A_STATS_GRP_HIST_BKT_UNITS_BYTES
> 
> Histogram has two dimensions, what's the second dimension for bytes?
> Time? Packet arrival?

Not sure what you mean. Here you are counting how many Rx/Tx packets are
between N to M bytes in length. I meant to add two attributes. One that
tells user space that you are counting Rx/Tx packets and the second that
N to M are in bytes.

But given your comment below about this histogram probably being a one
time thing, I think maybe staying with the current attributes is OK.
There is no need to over-engineer it if we don't see ourselves adding
new histograms.

Anyway, these histograms are under ETHTOOL_A_STATS_GRP that should give
user space all the context about what is being counted.

> 
> > ETHTOOL_A_STATS_GRP_HIST_VAL_TYPE_RX_PACKETS
> > ETHTOOL_A_STATS_GRP_HIST_VAL_TYPE_TX_PACKETS
> > 
> > And it will allow you to get rid of the special casing of the RMON stuff
> > below:
> > 
> > ```
> > 	if (id == ETHTOOL_STATS_RMON) {
> > 		open_json_array("pktsNtoM", "");
> > 
> > 		mnl_attr_for_each_nested(attr, grp) {
> > 			s = mnl_attr_get_type(attr);
> > 			if (s != ETHTOOL_A_STATS_GRP_HIST_RX &&
> > 			    s != ETHTOOL_A_STATS_GRP_HIST_TX)
> > 				continue;
> > 
> > 			if (parse_rmon_hist(attr))
> > 				goto err_close_rmon;
> > 		}
> > 		close_json_array("");
> > 	}
> > ```
> 
> We can drop the if, but we still need a separate for() loop
> to be able to place those entries in a JSON array.
> 
> > I don't know how many histograms we are going to have as part of RFCs,
> > but at least mlxsw also supports histograms of the Tx queue depth and
> > latency. Not to be exposed by this interface, but shows the importance
> > of encoding the units.
> 
> TBH I hope we'll never use the hist for anything else. Sadly the
> bucketing of various drivers is really different (at least 6
> variants). But the overarching goal is a common interface for common
> port stats.

  reply	other threads:[~2021-04-17 19:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 16:02 [RFC ethtool 0/6] ethtool: add FEC & std stats support Jakub Kicinski
2021-04-16 16:02 ` [RFC ethtool 1/6] update UAPI header copies Jakub Kicinski
2021-04-16 16:02 ` [RFC ethtool 2/6] json: simplify array print API Jakub Kicinski
2021-04-16 16:02 ` [RFC ethtool 3/6] netlink: add FEC support Jakub Kicinski
2021-04-16 16:02 ` [RFC ethtool 4/6] netlink: fec: support displaying statistics Jakub Kicinski
2021-04-16 16:02 ` [RFC ethtool 5/6] ethtool: add nlchk for redirecting to netlink Jakub Kicinski
2021-04-16 16:02 ` [RFC ethtool 6/6] netlink: add support for standard stats Jakub Kicinski
2021-04-17 18:14   ` Ido Schimmel
2021-04-17 18:47     ` Jakub Kicinski
2021-04-17 19:22       ` Ido Schimmel [this message]
2021-04-17 19:44         ` Jakub Kicinski

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=YHs1kSQWxJf03uqV@shredder.lan \
    --to=idosch@idosch.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    /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).