* [PATCH net-next] net/sched: speedup tc_dump_qdisc() when tcm_handle is provided
@ 2026-05-03 11:45 Eric Dumazet
2026-05-04 19:13 ` Jamal Hadi Salim
2026-05-05 2:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 5+ messages in thread
From: Eric Dumazet @ 2026-05-03 11:45 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Jamal Hadi Salim, Jiri Pirko, netdev, eric.dumazet,
Eric Dumazet
"tc qdisc show ... handle xxx" filtering can be done by the kernel.
A followup patch can do the same for tcm_parent.
iproute2/tc needs a small companion patch.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/sched/sch_api.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index dd0edc9bd4610ec865fc97a81f801a7da020667b..6f7847c5536f16e6754954f0a606581e17257361 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -979,13 +979,17 @@ static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid,
return -EMSGSIZE;
}
-static bool tc_qdisc_dump_ignore(struct Qdisc *q, bool dump_invisible)
+static bool tc_qdisc_dump_ignore(struct Qdisc *q, bool dump_invisible,
+ const struct tcmsg *tcm)
{
if (q->flags & TCQ_F_BUILTIN)
return true;
if ((q->flags & TCQ_F_INVISIBLE) && !dump_invisible)
return true;
-
+ if (tcm) {
+ if (tcm->tcm_handle && tcm->tcm_handle != q->handle)
+ return true;
+ }
return false;
}
@@ -1000,7 +1004,7 @@ static int qdisc_get_notify(struct net *net, struct sk_buff *oskb,
if (!skb)
return -ENOBUFS;
- if (!tc_qdisc_dump_ignore(q, false)) {
+ if (!tc_qdisc_dump_ignore(q, false, NULL)) {
if (tc_fill_qdisc(skb, q, clid, portid, n->nlmsg_seq, 0,
RTM_NEWQDISC, extack) < 0)
goto err_out;
@@ -1030,12 +1034,12 @@ static int qdisc_notify(struct net *net, struct sk_buff *oskb,
if (!skb)
return -ENOBUFS;
- if (old && !tc_qdisc_dump_ignore(old, false)) {
+ if (old && !tc_qdisc_dump_ignore(old, false, NULL)) {
if (tc_fill_qdisc(skb, old, clid, portid, n->nlmsg_seq,
0, RTM_DELQDISC, extack) < 0)
goto err_out;
}
- if (new && !tc_qdisc_dump_ignore(new, false)) {
+ if (new && !tc_qdisc_dump_ignore(new, false, NULL)) {
if (tc_fill_qdisc(skb, new, clid, portid, n->nlmsg_seq,
old ? NLM_F_REPLACE : 0, RTM_NEWQDISC, extack) < 0)
goto err_out;
@@ -1825,21 +1829,24 @@ static int tc_dump_qdisc_root(struct Qdisc *root, struct sk_buff *skb,
int *q_idx_p, int s_q_idx, bool recur,
bool dump_invisible)
{
+ const struct nlmsghdr *nlh = cb->nlh;
int ret = 0, q_idx = *q_idx_p;
+ const struct tcmsg *tcm;
struct Qdisc *q;
int b;
if (!root)
return 0;
+ tcm = nlmsg_data(nlh);
q = root;
if (q_idx < s_q_idx) {
q_idx++;
} else {
- if (!tc_qdisc_dump_ignore(q, dump_invisible))
+ if (!tc_qdisc_dump_ignore(q, dump_invisible, tcm))
ret = tc_fill_qdisc(skb, q, q->parent,
NETLINK_CB(cb->skb).portid,
- cb->nlh->nlmsg_seq, NLM_F_MULTI,
+ nlh->nlmsg_seq, NLM_F_MULTI,
RTM_NEWQDISC, NULL);
if (ret < 0)
goto out;
@@ -1860,10 +1867,10 @@ static int tc_dump_qdisc_root(struct Qdisc *root, struct sk_buff *skb,
q_idx++;
continue;
}
- if (!tc_qdisc_dump_ignore(q, dump_invisible))
+ if (!tc_qdisc_dump_ignore(q, dump_invisible, tcm))
ret = tc_fill_qdisc(skb, q, q->parent,
NETLINK_CB(cb->skb).portid,
- cb->nlh->nlmsg_seq, NLM_F_MULTI,
+ nlh->nlmsg_seq, NLM_F_MULTI,
RTM_NEWQDISC, NULL);
if (ret < 0)
goto out;
@@ -2341,7 +2348,7 @@ static int tc_dump_tclass_qdisc(struct Qdisc *q, struct sk_buff *skb,
{
struct qdisc_dump_args arg;
- if (tc_qdisc_dump_ignore(q, false) ||
+ if (tc_qdisc_dump_ignore(q, false, NULL) ||
*t_p < s_t || !q->ops->cl_ops ||
(tcm->tcm_parent &&
TC_H_MAJ(tcm->tcm_parent) != q->handle)) {
--
2.54.0.545.g6539524ca2-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH net-next] net/sched: speedup tc_dump_qdisc() when tcm_handle is provided
2026-05-03 11:45 [PATCH net-next] net/sched: speedup tc_dump_qdisc() when tcm_handle is provided Eric Dumazet
@ 2026-05-04 19:13 ` Jamal Hadi Salim
2026-05-04 19:20 ` Eric Dumazet
2026-05-05 2:40 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 5+ messages in thread
From: Jamal Hadi Salim @ 2026-05-04 19:13 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
Jiri Pirko, netdev, eric.dumazet
On Sun, May 3, 2026 at 7:45 AM Eric Dumazet <edumazet@google.com> wrote:
>
> "tc qdisc show ... handle xxx" filtering can be done by the kernel.
>
> A followup patch can do the same for tcm_parent.
>
> iproute2/tc needs a small companion patch.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
If you ever redo this for whatever reason, showing the dump of before
and after will be good documentation.
Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
cheers,
jamal
> ---
> net/sched/sch_api.c | 27 +++++++++++++++++----------
> 1 file changed, 17 insertions(+), 10 deletions(-)
>
> diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
> index dd0edc9bd4610ec865fc97a81f801a7da020667b..6f7847c5536f16e6754954f0a606581e17257361 100644
> --- a/net/sched/sch_api.c
> +++ b/net/sched/sch_api.c
> @@ -979,13 +979,17 @@ static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid,
> return -EMSGSIZE;
> }
>
> -static bool tc_qdisc_dump_ignore(struct Qdisc *q, bool dump_invisible)
> +static bool tc_qdisc_dump_ignore(struct Qdisc *q, bool dump_invisible,
> + const struct tcmsg *tcm)
> {
> if (q->flags & TCQ_F_BUILTIN)
> return true;
> if ((q->flags & TCQ_F_INVISIBLE) && !dump_invisible)
> return true;
> -
> + if (tcm) {
> + if (tcm->tcm_handle && tcm->tcm_handle != q->handle)
> + return true;
> + }
> return false;
> }
>
> @@ -1000,7 +1004,7 @@ static int qdisc_get_notify(struct net *net, struct sk_buff *oskb,
> if (!skb)
> return -ENOBUFS;
>
> - if (!tc_qdisc_dump_ignore(q, false)) {
> + if (!tc_qdisc_dump_ignore(q, false, NULL)) {
> if (tc_fill_qdisc(skb, q, clid, portid, n->nlmsg_seq, 0,
> RTM_NEWQDISC, extack) < 0)
> goto err_out;
> @@ -1030,12 +1034,12 @@ static int qdisc_notify(struct net *net, struct sk_buff *oskb,
> if (!skb)
> return -ENOBUFS;
>
> - if (old && !tc_qdisc_dump_ignore(old, false)) {
> + if (old && !tc_qdisc_dump_ignore(old, false, NULL)) {
> if (tc_fill_qdisc(skb, old, clid, portid, n->nlmsg_seq,
> 0, RTM_DELQDISC, extack) < 0)
> goto err_out;
> }
> - if (new && !tc_qdisc_dump_ignore(new, false)) {
> + if (new && !tc_qdisc_dump_ignore(new, false, NULL)) {
> if (tc_fill_qdisc(skb, new, clid, portid, n->nlmsg_seq,
> old ? NLM_F_REPLACE : 0, RTM_NEWQDISC, extack) < 0)
> goto err_out;
> @@ -1825,21 +1829,24 @@ static int tc_dump_qdisc_root(struct Qdisc *root, struct sk_buff *skb,
> int *q_idx_p, int s_q_idx, bool recur,
> bool dump_invisible)
> {
> + const struct nlmsghdr *nlh = cb->nlh;
> int ret = 0, q_idx = *q_idx_p;
> + const struct tcmsg *tcm;
> struct Qdisc *q;
> int b;
>
> if (!root)
> return 0;
>
> + tcm = nlmsg_data(nlh);
> q = root;
> if (q_idx < s_q_idx) {
> q_idx++;
> } else {
> - if (!tc_qdisc_dump_ignore(q, dump_invisible))
> + if (!tc_qdisc_dump_ignore(q, dump_invisible, tcm))
> ret = tc_fill_qdisc(skb, q, q->parent,
> NETLINK_CB(cb->skb).portid,
> - cb->nlh->nlmsg_seq, NLM_F_MULTI,
> + nlh->nlmsg_seq, NLM_F_MULTI,
> RTM_NEWQDISC, NULL);
> if (ret < 0)
> goto out;
> @@ -1860,10 +1867,10 @@ static int tc_dump_qdisc_root(struct Qdisc *root, struct sk_buff *skb,
> q_idx++;
> continue;
> }
> - if (!tc_qdisc_dump_ignore(q, dump_invisible))
> + if (!tc_qdisc_dump_ignore(q, dump_invisible, tcm))
> ret = tc_fill_qdisc(skb, q, q->parent,
> NETLINK_CB(cb->skb).portid,
> - cb->nlh->nlmsg_seq, NLM_F_MULTI,
> + nlh->nlmsg_seq, NLM_F_MULTI,
> RTM_NEWQDISC, NULL);
> if (ret < 0)
> goto out;
> @@ -2341,7 +2348,7 @@ static int tc_dump_tclass_qdisc(struct Qdisc *q, struct sk_buff *skb,
> {
> struct qdisc_dump_args arg;
>
> - if (tc_qdisc_dump_ignore(q, false) ||
> + if (tc_qdisc_dump_ignore(q, false, NULL) ||
> *t_p < s_t || !q->ops->cl_ops ||
> (tcm->tcm_parent &&
> TC_H_MAJ(tcm->tcm_parent) != q->handle)) {
> --
> 2.54.0.545.g6539524ca2-goog
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net-next] net/sched: speedup tc_dump_qdisc() when tcm_handle is provided
2026-05-04 19:13 ` Jamal Hadi Salim
@ 2026-05-04 19:20 ` Eric Dumazet
2026-05-04 19:34 ` Jamal Hadi Salim
0 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2026-05-04 19:20 UTC (permalink / raw)
To: Jamal Hadi Salim
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
Jiri Pirko, netdev, eric.dumazet
On Mon, May 4, 2026 at 12:13 PM Jamal Hadi Salim <jhs@mojatatu.com> wrote:
>
> On Sun, May 3, 2026 at 7:45 AM Eric Dumazet <edumazet@google.com> wrote:
> >
> > "tc qdisc show ... handle xxx" filtering can be done by the kernel.
> >
> > A followup patch can do the same for tcm_parent.
> >
> > iproute2/tc needs a small companion patch.
> >
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
>
> If you ever redo this for whatever reason, showing the dump of before
> and after will be good documentation.
There is no difference in tc output.
One can use strace and look at all the recvmsg() values, but they are
quite verbose :/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net/sched: speedup tc_dump_qdisc() when tcm_handle is provided
2026-05-04 19:20 ` Eric Dumazet
@ 2026-05-04 19:34 ` Jamal Hadi Salim
0 siblings, 0 replies; 5+ messages in thread
From: Jamal Hadi Salim @ 2026-05-04 19:34 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
Jiri Pirko, netdev, eric.dumazet
On Mon, May 4, 2026 at 3:20 PM Eric Dumazet <edumazet@google.com> wrote:
>
> On Mon, May 4, 2026 at 12:13 PM Jamal Hadi Salim <jhs@mojatatu.com> wrote:
> >
> > On Sun, May 3, 2026 at 7:45 AM Eric Dumazet <edumazet@google.com> wrote:
> > >
> > > "tc qdisc show ... handle xxx" filtering can be done by the kernel.
> > >
> > > A followup patch can do the same for tcm_parent.
> > >
> > > iproute2/tc needs a small companion patch.
> > >
> > > Signed-off-by: Eric Dumazet <edumazet@google.com>
> >
> > If you ever redo this for whatever reason, showing the dump of before
> > and after will be good documentation.
>
> There is no difference in tc output.
>
> One can use strace and look at all the recvmsg() values, but they are
> quite verbose :/
Ah, i see it now ;->
cheers,
jamal
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net/sched: speedup tc_dump_qdisc() when tcm_handle is provided
2026-05-03 11:45 [PATCH net-next] net/sched: speedup tc_dump_qdisc() when tcm_handle is provided Eric Dumazet
2026-05-04 19:13 ` Jamal Hadi Salim
@ 2026-05-05 2:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-05-05 2:40 UTC (permalink / raw)
To: Eric Dumazet; +Cc: davem, kuba, pabeni, horms, jhs, jiri, netdev, eric.dumazet
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 3 May 2026 11:45:15 +0000 you wrote:
> "tc qdisc show ... handle xxx" filtering can be done by the kernel.
>
> A followup patch can do the same for tcm_parent.
>
> iproute2/tc needs a small companion patch.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
>
> [...]
Here is the summary with links:
- [net-next] net/sched: speedup tc_dump_qdisc() when tcm_handle is provided
https://git.kernel.org/netdev/net-next/c/c1e5127b577c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-05-05 2:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-03 11:45 [PATCH net-next] net/sched: speedup tc_dump_qdisc() when tcm_handle is provided Eric Dumazet
2026-05-04 19:13 ` Jamal Hadi Salim
2026-05-04 19:20 ` Eric Dumazet
2026-05-04 19:34 ` Jamal Hadi Salim
2026-05-05 2:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox