On 11 Jun 2026, at 6:58, Adrian Moreno wrote:

> A future patch will introduce a per-flow_table mutex that will protect
> flow operations independently. In preparation for that, this patch
> introduces a flow_table lockdep macro, and modifies some function
> signatures to allow lockdep assertions to run.
>
> For now, the actual lockdep check logic is a no-op, but adding the
> infrastructure helps reduce the size of the upcoming patch.
>
> Signed-off-by: Adrian Moreno <[email protected]>

Hi Adrian,

See some comments below, and maybe address the Sashiko comment in the
commit message.

Cheers,

Eelco

[...]

> diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
> index e78c28dd5d9d..72ad3ed12675 100644
> --- a/net/openvswitch/datapath.c
> +++ b/net/openvswitch/datapath.c
> @@ -840,15 +840,16 @@ static size_t ovs_flow_cmd_msg_size(const struct 
> sw_flow_actions *acts,
>               + nla_total_size_64bit(8); /* OVS_FLOW_ATTR_USED */
>  }
>
> -/* Called with ovs_mutex or RCU read lock. */
> +/* Called with table->lock or RCU read lock. */
>  static int ovs_flow_cmd_fill_stats(const struct sw_flow *flow,
> +                                const struct flow_table *table,

Should 'table' come before 'flow' to be consistent with
ovs_flow_tbl_insert() and ovs_flow_tbl_remove()? This applies
to all functions in this patch adding the 'table' parameter.

>                                  struct sk_buff *skb)
>  {
>       struct ovs_flow_stats stats;
>       __be16 tcp_flags;
>       unsigned long used;

[...]

> diff --git a/net/openvswitch/flow_table.h b/net/openvswitch/flow_table.h
> index 6211bcc72655..3e5e9845c28a 100644
> --- a/net/openvswitch/flow_table.h
> +++ b/net/openvswitch/flow_table.h
> @@ -72,6 +72,22 @@ struct flow_table {
>
>  extern struct kmem_cache *flow_stats_cache;
>
> +static inline int lockdep_ovs_tbl_is_held(const struct flow_table *table
> +                                       __always_unused)
> +{
> +     return 1;
> +}
> +
> +#define ASSERT_OVS_TBL(tbl)   WARN_ON(!lockdep_ovs_tbl_is_held(tbl))
> +
> +/* Lock-protected update-allowed dereferences.*/
> +#define ovs_tbl_dereference(p, tbl)  \
> +     rcu_dereference_protected(p, lockdep_ovs_tbl_is_held(tbl))
> +
> +/* Read dereferences can be protected by either RCU, table lock. */

nit; This comment reads odd, maybe;

/* Read dereferences can be protected by either RCU or table lock. */

> +#define rcu_dereference_ovs_tbl(p, tbl) \
> +     rcu_dereference_check(p, lockdep_ovs_tbl_is_held(tbl))
> +
>  int ovs_flow_init(void);
>  void ovs_flow_exit(void);

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to