Subject: Re: [PATCH net-next v2 09/12] ethtool: rss: support dumping RSS contexts

From: Jakub Kicinski <[email-masked]>
Date: Tue, 6 Aug 2024 08:23:16 -0700

On Tue, 6 Aug 2024 15:24:50 +0100 Edward Cree wrote:
> > +	if (!ctx->ctx_idx) {
> > +		ret = rss_dump_one_ctx(skb, cb, dev, 0);
> > +		if (ret)
> > +			return ret;
> > +		ctx->ctx_idx++;
> > +	}  
> 
> Maybe comment this block with something like "context 0 is
>  not stored in the XArray" to make clear why this is split
>  out from a loop that looks like it should be able to handle
>  it.

Will do.

> > +
> > +	for (; xa_find(&dev->ethtool->rss_ctx, &ctx->ctx_idx,
> > +		       ULONG_MAX, XA_PRESENT); ctx->ctx_idx++) {
> > +		ret = rss_dump_one_ctx(skb, cb, dev, ctx->ctx_idx);
> > +		if (ret)
> > +			return ret;
> > +	}
> > +	ctx->ctx_idx = 0;  
> 
> Feels like there has to be a way to do this with
>  xa_for_each_start()?  Something like (untested):

It may work in the current code but I prefer to stay away from xarray
iterators in netlink code. They cause too many bugs. They do not
invalidate / move the index past the end of the array once they are
done. Which means if the dump ever gets called again after finishing
we'll re-dump the last element.