Re: [PATCH net 5/6] net/sched: Refactor qdisc_graft() for ingress and clsact Qdiscs

From: Peilin Ye
Date: Mon May 08 2023 - 18:24:32 EST


On Mon, May 08, 2023 at 07:29:26AM -0400, Jamal Hadi Salim wrote:
> On Fri, May 5, 2023 at 8:15 PM Peilin Ye <yepeilin.cs@xxxxxxxxx> wrote:
> >
> > Grafting ingress and clsact Qdiscs does not need a for-loop in
> > qdisc_graft(). Refactor it. No functional changes intended.
>
> This one i am not so sure; num_q = 1 implies it will run on the for
> loop only once. I am not sure it improves readability either. Anyways
> for the effort you put into it i am tossing a coin and saying:
> Reviewed-by: Jamal Hadi Salim <jhs@xxxxxxxxxxxx>
> Acked-by: Jamal Hadi Salim <jhs@xxxxxxxxxxxx>

Yeah, it doesn't make much difference itself. I'm just afraid that,
without [5/6], [6/6] would look like:

for (i = 0; i < num_q; i++) {
if (!ingress) {
dev_queue = netdev_get_tx_queue(dev, i);
old = dev_graft_qdisc(dev_queue, new);
else {
old = dev_graft_qdisc(dev_queue, NULL);
}

if (new && i > 0)
qdisc_refcount_inc(new);

if (!ingress) {
qdisc_put(old);
} else {
/* {ingress,clsact}_destroy() "old" before grafting "new" to avoid
* unprotected concurrent accesses to net_device::miniq_{in,e}gress
* pointer(s) in mini_qdisc_pair_swap().
*/
qdisc_notify(net, skb, n, classid, old, new, extack);
qdisc_destroy(old);
}

if (ingress)
dev_graft_qdisc(dev_queue, new);
}

The "!ingress" path doesn't share a single line with "ingress", which
looks a bit weird to me. Personally I'd like to keep [5/6].

Thanks,
Peilin Ye