On 2025-04-17 10:01:17 [+0200], Paolo Abeni wrote:
> @Sebastian: I think the 'owner' assignment could be optimized out at
> compile time for non RT build - will likely not matter for performances,
> but I think it will be 'nicer', could you please update the patches to
> do that?

If we don't assign the `owner' then we can't use the lock even on !RT
because lockdep should complain. What about this then:

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index a3989d450a67f..b8f766978466d 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -294,8 +294,11 @@ void ovs_dp_process_packet(struct sk_buff *skb, struct 
sw_flow_key *key)
        sf_acts = rcu_dereference(flow->sf_acts);
        /* This path can be invoked recursively: Use the current task to
         * identify recursive invocation - the lock must be acquired only once.
+        * Even with disabled bottom halves this can be preempted on PREEMPT_RT.
+        * Limit the provecc to RT to avoid assigning `owner' if it can be
+        * avoided.
         */
-       if (ovs_pcpu->owner != current) {
+       if (IS_ENABLED(CONFIG_PREEMPT_RT) && ovs_pcpu->owner != current) {
                local_lock_nested_bh(&ovs_pcpu_storage.bh_lock);
                ovs_pcpu->owner = current;
                ovs_pcpu_locked = true;
@@ -687,9 +690,11 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, 
struct genl_info *info)
 
        local_bh_disable();
        local_lock_nested_bh(&ovs_pcpu_storage.bh_lock);
-       this_cpu_write(ovs_pcpu_storage.owner, current);
+       if (IS_ENABLED(CONFIG_PREEMPT_RT))
+               this_cpu_write(ovs_pcpu_storage.owner, current);
        err = ovs_execute_actions(dp, packet, sf_acts, &flow->key);
-       this_cpu_write(ovs_pcpu_storage.owner, NULL);
+       if (IS_ENABLED(CONFIG_PREEMPT_RT))
+               this_cpu_write(ovs_pcpu_storage.owner, NULL);
        local_unlock_nested_bh(&ovs_pcpu_storage.bh_lock);
        local_bh_enable();
        rcu_read_unlock();

> Thanks!
> 
> Paolo

Sebastian
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to