Subject: Re: [PATCH v4 net-next 00/12] net: introduce TX H/W shaping API

From: Jakub Kicinski <[email-masked]>
Date: Mon, 26 Aug 2024 19:14:13 -0700

On Fri, 23 Aug 2024 09:51:24 +0200 Paolo Abeni wrote:
> On 8/23/24 02:43, Jakub Kicinski wrote:
> > On Tue, 20 Aug 2024 17:12:21 +0200 Paolo Abeni wrote:  
> >> * Delegation
> >>
> >> A containers wants to limit the aggregate B/W bandwidth of 2 of the 3
> >> queues it owns - the starting configuration is the one from the
> >> previous point:
> >>
> >> SPEC=Documentation/netlink/specs/net_shaper.yaml
> >> ./tools/net/ynl/cli.py --spec $SPEC \
> >> 	--do group --json '{"ifindex":'$IFINDEX',
> >> 			"leaves": [
> >> 			  {"handle": {"scope": "queue", "id":'$QID1' },
> >> 			   "weight": '$W1'},
> >> 			  {"handle": {"scope": "queue", "id":'$QID2' },
> >> 			   "weight": '$W2'}],
> >> 			"root": { "handle": {"scope": "node"},
> >> 				  "parent": {"scope": "node", "id": 0},  
> > 
> > In the delegation use case I was hoping "parent" would be automatic.  
> 
> Currently the parent is automatic/implicit when creating a node directly 
> nested to the the netdev shaper.
> 
> I now see we can use as default parent the current leaves' parent, when 
> that is the same for all the to-be-grouped leaves.
> 
> Actually, if we restrict the group operation to operate only on set of 
> leaves respecting the above, I *guess* we will not lose generality and 
> we could simplify a bit the spec. WDYT?

I remember having a use case in mind where specifying parent would be
very useful. I think it may have been related to atomic changes.
I'm not sure if what I describe below is exactly that case...

Imagine:

Qx -{hierarchy}---\
                   \{hierarchy}-- netdev
Q0-------P0\ SP----/   
Q1--\ RR-P1/
Q2--/

Let's say we own queues 0,1,2 and want to remove the SP layer.
It's convenient to do:

	$node = get($SP-node)
	group(leaves: [Q0, Q1, Q2], parent=$node.parent)

And have the kernel "garbage collect" the old RR node and the old SP
node (since they will now have no children). We want to avoid the
situations where user space has to do complex transitions thru
states which device may not support (make sure Q1, Q2 have right prios,
delete old RR, now we have SP w/ 3 inputs, delete the SP, create a new
group).

For the case above we could technically identify the correct parent by
skipping the nodes which will be garbage collected later. But imagine
that instead of deleting the hierarchy we wanted to move Q1 from P1 
to P0:

	group(leaves: [Q0, Q1], parent=SP, prio=P0)

does the job.

I admit this are somewhat contrived, and I agree that we won't lose
generality, but I think it will narrow the range of hierarchies we
can transition between atomically.