[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240417131404.GX2320920@kernel.org>
Date: Wed, 17 Apr 2024 14:14:04 +0100
From: Simon Horman <horms@...nel.org>
To: Eric Dumazet <edumazet@...gle.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Jamal Hadi Salim <jhs@...atatu.com>,
Cong Wang <xiyou.wangcong@...il.com>, Jiri Pirko <jiri@...nulli.us>,
netdev@...r.kernel.org, eric.dumazet@...il.com
Subject: Re: [PATCH net-next 04/14] net_sched: sch_choke: implement lockless
choke_dump()
On Mon, Apr 15, 2024 at 01:20:44PM +0000, Eric Dumazet wrote:
> Instead of relying on RTNL, choke_dump() can use READ_ONCE()
> annotations, paired with WRITE_ONCE() ones in choke_change().
>
> Also use READ_ONCE(q->limit) in choke_enqueue() as the value
> could change from choke_change().
Hi Eric,
I'm wondering if you could expand on why q->limit needs this treatment
but not other fields, f.e. q->parms.qth_min (aka p->qth_min).
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> ---
> include/net/red.h | 10 +++++-----
> net/sched/sch_choke.c | 23 ++++++++++++-----------
> 2 files changed, 17 insertions(+), 16 deletions(-)
>
> diff --git a/include/net/red.h b/include/net/red.h
...
> @@ -244,7 +244,7 @@ static inline void red_set_parms(struct red_parms *p,
> max_P = red_maxp(Plog);
> max_P *= delta; /* max_P = (qth_max - qth_min)/2^Plog */
> }
> - p->max_P = max_P;
> + WRITE_ONCE(p->max_P, max_P);
> max_p_delta = max_P / delta;
> max_p_delta = max(max_p_delta, 1U);
> p->max_P_reciprocal = reciprocal_value(max_p_delta);
A little further down in this function p->Scell_log is set.
I think it also needs the WRITE_ONCE() treatment as it
is read in choke_dump().
> diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c
...
> @@ -431,15 +431,16 @@ static int choke_init(struct Qdisc *sch, struct nlattr *opt,
> static int choke_dump(struct Qdisc *sch, struct sk_buff *skb)
> {
> struct choke_sched_data *q = qdisc_priv(sch);
> + u8 Wlog = READ_ONCE(q->parms.Wlog);
> struct nlattr *opts = NULL;
> struct tc_red_qopt opt = {
> - .limit = q->limit,
> - .flags = q->flags,
> - .qth_min = q->parms.qth_min >> q->parms.Wlog,
> - .qth_max = q->parms.qth_max >> q->parms.Wlog,
> - .Wlog = q->parms.Wlog,
> - .Plog = q->parms.Plog,
> - .Scell_log = q->parms.Scell_log,
> + .limit = READ_ONCE(q->limit),
> + .flags = READ_ONCE(q->flags),
> + .qth_min = READ_ONCE(q->parms.qth_min) >> Wlog,
> + .qth_max = READ_ONCE(q->parms.qth_max) >> Wlog,
> + .Wlog = Wlog,
> + .Plog = READ_ONCE(q->parms.Plog),
> + .Scell_log = READ_ONCE(q->parms.Scell_log),
> };
>
> opts = nla_nest_start_noflag(skb, TCA_OPTIONS);
Powered by blists - more mailing lists