BPF List
 help / color / mirror / Atom feed
From: Amery Hung <ameryhung@gmail.com>
To: netdev@vger.kernel.org
Cc: bpf@vger.kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	alexei.starovoitov@gmail.com, martin.lau@kernel.org,
	kuba@kernel.org, edumazet@google.com, xiyou.wangcong@gmail.com,
	jhs@mojatatu.com, sinquersw@gmail.com, toke@redhat.com,
	juntong.deng@outlook.com, jiri@resnulli.us, stfomichev@gmail.com,
	ekarani.silvestre@ccc.ufcg.edu.br, yangpeihao@sjtu.edu.cn,
	yepeilin.cs@gmail.com, ameryhung@gmail.com, kernel-team@meta.com
Subject: [PATCH bpf-next v6 06/11] bpf: net_sched: Support updating bstats
Date: Wed, 19 Mar 2025 14:53:53 -0700	[thread overview]
Message-ID: <20250319215358.2287371-7-ameryhung@gmail.com> (raw)
In-Reply-To: <20250319215358.2287371-1-ameryhung@gmail.com>

From: Amery Hung <amery.hung@bytedance.com>

Add a kfunc to update Qdisc bstats when an skb is dequeued. The kfunc is
only available in .dequeue programs.

Signed-off-by: Amery Hung <amery.hung@bytedance.com>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
 net/sched/bpf_qdisc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/net/sched/bpf_qdisc.c b/net/sched/bpf_qdisc.c
index 5f4ab4877535..5aff83d7d1d8 100644
--- a/net/sched/bpf_qdisc.c
+++ b/net/sched/bpf_qdisc.c
@@ -254,6 +254,15 @@ __bpf_kfunc void bpf_qdisc_reset_destroy_epilogue(struct Qdisc *sch)
 	qdisc_watchdog_cancel(&q->watchdog);
 }
 
+/* bpf_qdisc_bstats_update - Update Qdisc basic statistics
+ * @sch: The qdisc from which an skb is dequeued.
+ * @skb: The skb to be dequeued.
+ */
+__bpf_kfunc void bpf_qdisc_bstats_update(struct Qdisc *sch, const struct sk_buff *skb)
+{
+	bstats_update(&sch->bstats, skb);
+}
+
 __bpf_kfunc_end_defs();
 
 BTF_KFUNCS_START(qdisc_kfunc_ids)
@@ -264,6 +273,7 @@ BTF_ID_FLAGS(func, bpf_dynptr_from_skb, KF_TRUSTED_ARGS)
 BTF_ID_FLAGS(func, bpf_qdisc_watchdog_schedule, KF_TRUSTED_ARGS)
 BTF_ID_FLAGS(func, bpf_qdisc_init_prologue, KF_TRUSTED_ARGS)
 BTF_ID_FLAGS(func, bpf_qdisc_reset_destroy_epilogue, KF_TRUSTED_ARGS)
+BTF_ID_FLAGS(func, bpf_qdisc_bstats_update, KF_TRUSTED_ARGS)
 BTF_KFUNCS_END(qdisc_kfunc_ids)
 
 BTF_SET_START(qdisc_common_kfunc_set)
@@ -279,6 +289,7 @@ BTF_SET_END(qdisc_enqueue_kfunc_set)
 
 BTF_SET_START(qdisc_dequeue_kfunc_set)
 BTF_ID(func, bpf_qdisc_watchdog_schedule)
+BTF_ID(func, bpf_qdisc_bstats_update)
 BTF_SET_END(qdisc_dequeue_kfunc_set)
 
 enum qdisc_ops_kf_flags {
-- 
2.47.1


  parent reply	other threads:[~2025-03-19 21:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-19 21:53 [PATCH bpf-next v6 00/11] bpf qdisc Amery Hung
2025-03-19 21:53 ` [PATCH bpf-next v6 01/11] bpf: Add struct_ops context information to struct bpf_prog_aux Amery Hung
2025-03-21  0:10   ` Martin KaFai Lau
2025-03-19 21:53 ` [PATCH bpf-next v6 02/11] bpf: Prepare to reuse get_ctx_arg_idx Amery Hung
2025-03-19 21:53 ` [PATCH bpf-next v6 03/11] bpf: net_sched: Support implementation of Qdisc_ops in bpf Amery Hung
2025-03-19 21:53 ` [PATCH bpf-next v6 04/11] bpf: net_sched: Add basic bpf qdisc kfuncs Amery Hung
2025-03-19 21:53 ` [PATCH bpf-next v6 05/11] bpf: net_sched: Add a qdisc watchdog timer Amery Hung
2025-03-19 21:53 ` Amery Hung [this message]
2025-03-19 21:53 ` [PATCH bpf-next v6 07/11] bpf: net_sched: Disable attaching bpf qdisc to non root Amery Hung
2025-03-19 21:53 ` [PATCH bpf-next v6 08/11] libbpf: Support creating and destroying qdisc Amery Hung
2025-03-19 21:53 ` [PATCH bpf-next v6 09/11] selftests/bpf: Add a basic fifo qdisc test Amery Hung
2025-03-19 21:53 ` [PATCH bpf-next v6 10/11] selftests/bpf: Add a bpf fq qdisc to selftest Amery Hung
2025-03-19 21:53 ` [PATCH bpf-next v6 11/11] selftests/bpf: Test attaching bpf qdisc to mq and non root Amery Hung
2025-03-21  0:10 ` [PATCH bpf-next v6 00/11] bpf qdisc patchwork-bot+netdevbpf

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=20250319215358.2287371-7-ameryhung@gmail.com \
    --to=ameryhung@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=edumazet@google.com \
    --cc=ekarani.silvestre@ccc.ufcg.edu.br \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=juntong.deng@outlook.com \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sinquersw@gmail.com \
    --cc=stfomichev@gmail.com \
    --cc=toke@redhat.com \
    --cc=xiyou.wangcong@gmail.com \
    --cc=yangpeihao@sjtu.edu.cn \
    --cc=yepeilin.cs@gmail.com \
    /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