[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKa-r6s69JbQX7ZuGiz37bbfQYWs+r6odhVB7Ygct8DYN=ApJQ@mail.gmail.com>
Date: Fri, 21 Mar 2025 18:14:50 +0100
From: Davide Caratti <dcaratti@...hat.com>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: netdev@...r.kernel.org, linux-rt-devel@...ts.linux.dev,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>, Jamal Hadi Salim <jhs@...atatu.com>,
Cong Wang <xiyou.wangcong@...il.com>, Jiri Pirko <jiri@...nulli.us>
Subject: Re: [PATCH net-next 13/18] net/sched: act_mirred: Move the recursion
counter struct netdev_xmit.
hi,
On Sun, Mar 9, 2025 at 3:48 PM Sebastian Andrzej Siewior
<bigeasy@...utronix.de> wrote:
>
> mirred_nest_level is a per-CPU variable and relies on disabled BH for its
> locking. Without per-CPU locking in local_bh_disable() on PREEMPT_RT
> this data structure requires explicit locking.
>
> Move mirred_nest_level to struct netdev_xmit as u8, provide wrappers.
>
> Cc: Jamal Hadi Salim <jhs@...atatu.com>
> Cc: Cong Wang <xiyou.wangcong@...il.com>
> Cc: Jiri Pirko <jiri@...nulli.us>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
> ---
> include/linux/netdevice_xmit.h | 3 +++
> net/sched/act_mirred.c | 28 +++++++++++++++++++++++++---
> 2 files changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/netdevice_xmit.h b/include/linux/netdevice_xmit.h
> index 3bbbc1a9860a3..4793ec42b1faa 100644
> --- a/include/linux/netdevice_xmit.h
> +++ b/include/linux/netdevice_xmit.h
> @@ -11,6 +11,9 @@ struct netdev_xmit {
> #if IS_ENABLED(CONFIG_NF_DUP_NETDEV)
> u8 nf_dup_skb_recursion;
> #endif
> +#if IS_ENABLED(CONFIG_NET_ACT_MIRRED)
> + u8 sched_mirred_nest;
> +#endif
> };
>
> #endif
> diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
> index 5b38143659249..8d8cfac6cc6af 100644
> --- a/net/sched/act_mirred.c
> +++ b/net/sched/act_mirred.c
> @@ -30,7 +30,29 @@ static LIST_HEAD(mirred_list);
> static DEFINE_SPINLOCK(mirred_list_lock);
>
> #define MIRRED_NEST_LIMIT 4
> -static DEFINE_PER_CPU(unsigned int, mirred_nest_level);
> +
> +#ifndef CONFIG_PREEMPT_RT
> +static u8 tcf_mirred_nest_level_inc_return(void)
> +{
> + return __this_cpu_inc_return(softnet_data.xmit.sched_mirred_nest);
> +}
> +
> +static void tcf_mirred_nest_level_dec(void)
> +{
> + __this_cpu_dec(softnet_data.xmit.sched_mirred_nest);
> +}
> +
> +#else
> +static u8 tcf_mirred_nest_level_inc_return(void)
> +{
> + return current->net_xmit.nf_dup_skb_recursion++;
> +}
> +
> +static void tcf_mirred_nest_level_dec(void)
> +{
> + current->net_xmit.nf_dup_skb_recursion--;
> +}
> +#endif
sorry for reviewing this late - but shouldn't we use sched_mirred_nest
instead of nf_dup_skb_recursion in case CONFIG_PREEMPT_RT is set?
thanks,
--
davide
Powered by blists - more mailing lists