[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <40b83649-a254-40b4-a8aa-33cc3c7b4157@redhat.com>
Date: Thu, 15 May 2025 11:12:12 +0200
From: Paolo Abeni <pabeni@...hat.com>
To: chia-yu.chang@...ia-bell-labs.com, horms@...nel.org,
donald.hunter@...il.com, xandfury@...il.com, netdev@...r.kernel.org,
dave.taht@...il.com, jhs@...atatu.com, kuba@...nel.org,
stephen@...workplumber.org, xiyou.wangcong@...il.com, jiri@...nulli.us,
davem@...emloft.net, edumazet@...gle.com, andrew+netdev@...n.ch,
ast@...erby.net, liuhangbin@...il.com, shuah@...nel.org,
linux-kselftest@...r.kernel.org, ij@...nel.org, ncardwell@...gle.com,
koen.de_schepper@...ia-bell-labs.com, g.white@...lelabs.com,
ingemar.s.johansson@...csson.com, mirja.kuehlewind@...csson.com,
cheshire@...le.com, rs.ietf@....at, Jason_Livingood@...cast.com,
vidhi_goel@...le.com
Subject: Re: [PATCH v15 net-next 2/5] sched: Dump configuration and statistics
of dualpi2 qdisc
On 5/9/25 11:47 PM, chia-yu.chang@...ia-bell-labs.com wrote:
> From: Chia-Yu Chang <chia-yu.chang@...ia-bell-labs.com>
>
> The configuration and statistics dump of the DualPI2 Qdisc provides
> information related to both queues, such as packet numbers and queuing
> delays in the L-queue and C-queue, as well as general information such as
> probability value, WRR credits, memory usage, packet marking counters, max
> queue size, etc.
>
> The following patch includes enqueue/dequeue for DualPI2.
>
> Signed-off-by: Chia-Yu Chang <chia-yu.chang@...ia-bell-labs.com>
> ---
> include/uapi/linux/pkt_sched.h | 15 ++++++
> net/sched/sch_dualpi2.c | 86 ++++++++++++++++++++++++++++++++++
> 2 files changed, 101 insertions(+)
>
> diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
> index f897819b1624..bc248fd49f6f 100644
> --- a/include/uapi/linux/pkt_sched.h
> +++ b/include/uapi/linux/pkt_sched.h
> @@ -1263,4 +1263,19 @@ enum {
>
> #define TCA_DUALPI2_MAX (__TCA_DUALPI2_MAX - 1)
>
> +struct tc_dualpi2_xstats {
> + __u32 prob; /* current probability */
> + __u32 delay_c; /* current delay in C queue */
> + __u32 delay_l; /* current delay in L queue */
> + __u32 packets_in_c; /* number of packets enqueued in C queue */
> + __u32 packets_in_l; /* number of packets enqueued in L queue */
> + __u32 maxq; /* maximum queue size */
> + __u32 ecn_mark; /* packets marked with ecn*/
> + __u32 step_marks; /* ECN marks due to the step AQM */
> + __s32 credit; /* current c_protection credit */
> + __u32 memory_used; /* Memory used of both queues */
> + __u32 max_memory_used; /* Maximum used memory */
> + __u32 memory_limit; /* Memory limit of both queues */
> +};
> +
> #endif
> diff --git a/net/sched/sch_dualpi2.c b/net/sched/sch_dualpi2.c
> index 4bc75c0b3436..81e238b5aaa9 100644
> --- a/net/sched/sch_dualpi2.c
> +++ b/net/sched/sch_dualpi2.c
> @@ -123,6 +123,14 @@ static u32 dualpi2_scale_alpha_beta(u32 param)
> return tmp;
> }
>
> +static u32 dualpi2_unscale_alpha_beta(u32 param)
> +{
> + u64 tmp = ((u64)param * NSEC_PER_SEC << ALPHA_BETA_SCALING);
> +
> + do_div(tmp, MAX_PROB);
> + return tmp;
> +}
> +
> static ktime_t next_pi2_timeout(struct dualpi2_sched_data *q)
> {
> return ktime_add_ns(ktime_get_ns(), q->pi2_tupdate);
> @@ -440,6 +448,82 @@ static int dualpi2_init(struct Qdisc *sch, struct nlattr *opt,
> return 0;
> }
>
> +static u32 convert_ns_to_usec(u64 ns)
> +{
> + do_div(ns, NSEC_PER_USEC);
> + return ns;
> +}
> +
> +static int dualpi2_dump(struct Qdisc *sch, struct sk_buff *skb)
> +{
> + struct dualpi2_sched_data *q = qdisc_priv(sch);
> + struct nlattr *opts;
> +
> + opts = nla_nest_start_noflag(skb, TCA_OPTIONS);
> + if (!opts)
> + goto nla_put_failure;
> +
> + if (nla_put_u32(skb, TCA_DUALPI2_LIMIT, READ_ONCE(sch->limit)) ||
> + nla_put_u32(skb, TCA_DUALPI2_MEMORY_LIMIT,
> + READ_ONCE(q->memory_limit)) ||
> + nla_put_u32(skb, TCA_DUALPI2_TARGET,
> + convert_ns_to_usec(READ_ONCE(q->pi2_target))) ||
> + nla_put_u32(skb, TCA_DUALPI2_TUPDATE,
> + convert_ns_to_usec(READ_ONCE(q->pi2_tupdate))) ||
> + nla_put_u32(skb, TCA_DUALPI2_ALPHA,
> + dualpi2_unscale_alpha_beta(READ_ONCE(q->pi2_alpha))) ||
> + nla_put_u32(skb, TCA_DUALPI2_BETA,
> + dualpi2_unscale_alpha_beta(READ_ONCE(q->pi2_beta))) ||
> + nla_put_u32(skb, TCA_DUALPI2_STEP_THRESH,
> + READ_ONCE(q->step_in_packets) ?
> + READ_ONCE(q->step_thresh) :
> + convert_ns_to_usec(READ_ONCE(q->step_thresh))) ||
> + nla_put_u32(skb, TCA_DUALPI2_MIN_QLEN_STEP,
> + READ_ONCE(q->min_qlen_step)) ||
> + nla_put_u8(skb, TCA_DUALPI2_COUPLING,
> + READ_ONCE(q->coupling_factor)) ||
> + nla_put_u8(skb, TCA_DUALPI2_DROP_OVERLOAD,
> + READ_ONCE(q->drop_overload)) ||
> + (READ_ONCE(q->step_in_packets) &&
> + nla_put_flag(skb, TCA_DUALPI2_STEP_PACKETS)) ||
> + nla_put_u8(skb, TCA_DUALPI2_DROP_EARLY,
> + READ_ONCE(q->drop_early)) ||
> + nla_put_u8(skb, TCA_DUALPI2_C_PROTECTION,
> + READ_ONCE(q->c_protection_wc)) ||
> + nla_put_u8(skb, TCA_DUALPI2_ECN_MASK, READ_ONCE(q->ecn_mask)) ||
> + nla_put_u8(skb, TCA_DUALPI2_SPLIT_GSO, READ_ONCE(q->split_gso)))
> + goto nla_put_failure;
> +
> + return nla_nest_end(skb, opts);
> +
> +nla_put_failure:
> + nla_nest_cancel(skb, opts);
> + return -1;
> +}
> +
> +static int dualpi2_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
> +{
> + struct dualpi2_sched_data *q = qdisc_priv(sch);
> + struct tc_dualpi2_xstats st = {
> + .prob = READ_ONCE(q->pi2_prob),
> + .packets_in_c = q->packets_in_c,
> + .packets_in_l = q->packets_in_l,
> + .maxq = q->maxq,
> + .ecn_mark = q->ecn_mark,
> + .credit = q->c_protection_credit,
> + .step_marks = q->step_marks,
> + .memory_used = q->memory_used,
> + .max_memory_used = q->max_memory_used,
> + .memory_limit = q->memory_limit,
> + };
> + u64 qc, ql;
> +
> + get_queue_delays(q, &qc, &ql);
> + st.delay_l = convert_ns_to_usec(ql);
> + st.delay_c = convert_ns_to_usec(qc);
Both delay_l and delay_c are u32. AFAICS, on pathological situations
both could overrun.
/P
Powered by blists - more mailing lists