Skip to content

Commit e13e4e4

Browse files
gal-pressmanNipaLocal
authored and
NipaLocal
committed
Revert "openvswitch: Use nested-BH locking for ovs_pcpu_storage"
This reverts commit 6723183. Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Gal Pressman <gal@nvidia.com> Signed-off-by: NipaLocal <nipa@local>
1 parent 290b23c commit e13e4e4

File tree

3 files changed

+29
-59
lines changed

3 files changed

+29
-59
lines changed

net/openvswitch/actions.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@
3939
#include "flow_netlink.h"
4040
#include "openvswitch_trace.h"
4141

42+
struct deferred_action {
43+
struct sk_buff *skb;
44+
const struct nlattr *actions;
45+
int actions_len;
46+
47+
/* Store pkt_key clone when creating deferred action. */
48+
struct sw_flow_key pkt_key;
49+
};
50+
4251
#define MAX_L2_LEN (VLAN_ETH_HLEN + 3 * MPLS_HLEN)
4352
struct ovs_frag_data {
4453
unsigned long dst;
@@ -55,10 +64,28 @@ struct ovs_frag_data {
5564

5665
static DEFINE_PER_CPU(struct ovs_frag_data, ovs_frag_data_storage);
5766

58-
DEFINE_PER_CPU(struct ovs_pcpu_storage, ovs_pcpu_storage) = {
59-
.bh_lock = INIT_LOCAL_LOCK(bh_lock),
67+
#define DEFERRED_ACTION_FIFO_SIZE 10
68+
#define OVS_RECURSION_LIMIT 5
69+
#define OVS_DEFERRED_ACTION_THRESHOLD (OVS_RECURSION_LIMIT - 2)
70+
struct action_fifo {
71+
int head;
72+
int tail;
73+
/* Deferred action fifo queue storage. */
74+
struct deferred_action fifo[DEFERRED_ACTION_FIFO_SIZE];
75+
};
76+
77+
struct action_flow_keys {
78+
struct sw_flow_key key[OVS_DEFERRED_ACTION_THRESHOLD];
79+
};
80+
81+
struct ovs_pcpu_storage {
82+
struct action_fifo action_fifos;
83+
struct action_flow_keys flow_keys;
84+
int exec_level;
6085
};
6186

87+
static DEFINE_PER_CPU(struct ovs_pcpu_storage, ovs_pcpu_storage);
88+
6289
/* Make a clone of the 'key', using the pre-allocated percpu 'flow_keys'
6390
* space. Return NULL if out of key spaces.
6491
*/

net/openvswitch/datapath.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,11 @@ void ovs_dp_detach_port(struct vport *p)
244244
/* Must be called with rcu_read_lock. */
245245
void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)
246246
{
247-
struct ovs_pcpu_storage *ovs_pcpu = this_cpu_ptr(&ovs_pcpu_storage);
248247
const struct vport *p = OVS_CB(skb)->input_vport;
249248
struct datapath *dp = p->dp;
250249
struct sw_flow *flow;
251250
struct sw_flow_actions *sf_acts;
252251
struct dp_stats_percpu *stats;
253-
bool ovs_pcpu_locked = false;
254252
u64 *stats_counter;
255253
u32 n_mask_hit;
256254
u32 n_cache_hit;
@@ -292,26 +290,10 @@ void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)
292290

293291
ovs_flow_stats_update(flow, key->tp.flags, skb);
294292
sf_acts = rcu_dereference(flow->sf_acts);
295-
/* This path can be invoked recursively: Use the current task to
296-
* identify recursive invocation - the lock must be acquired only once.
297-
* Even with disabled bottom halves this can be preempted on PREEMPT_RT.
298-
* Limit the locking to RT to avoid assigning `owner' if it can be
299-
* avoided.
300-
*/
301-
if (IS_ENABLED(CONFIG_PREEMPT_RT) && ovs_pcpu->owner != current) {
302-
local_lock_nested_bh(&ovs_pcpu_storage.bh_lock);
303-
ovs_pcpu->owner = current;
304-
ovs_pcpu_locked = true;
305-
}
306-
307293
error = ovs_execute_actions(dp, skb, sf_acts, key);
308294
if (unlikely(error))
309295
net_dbg_ratelimited("ovs: action execution error on datapath %s: %d\n",
310296
ovs_dp_name(dp), error);
311-
if (ovs_pcpu_locked) {
312-
ovs_pcpu->owner = NULL;
313-
local_unlock_nested_bh(&ovs_pcpu_storage.bh_lock);
314-
}
315297

316298
stats_counter = &stats->n_hit;
317299

@@ -689,13 +671,7 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
689671
sf_acts = rcu_dereference(flow->sf_acts);
690672

691673
local_bh_disable();
692-
local_lock_nested_bh(&ovs_pcpu_storage.bh_lock);
693-
if (IS_ENABLED(CONFIG_PREEMPT_RT))
694-
this_cpu_write(ovs_pcpu_storage.owner, current);
695674
err = ovs_execute_actions(dp, packet, sf_acts, &flow->key);
696-
if (IS_ENABLED(CONFIG_PREEMPT_RT))
697-
this_cpu_write(ovs_pcpu_storage.owner, NULL);
698-
local_unlock_nested_bh(&ovs_pcpu_storage.bh_lock);
699675
local_bh_enable();
700676
rcu_read_unlock();
701677

net/openvswitch/datapath.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -173,39 +173,6 @@ struct ovs_net {
173173
bool xt_label;
174174
};
175175

176-
struct deferred_action {
177-
struct sk_buff *skb;
178-
const struct nlattr *actions;
179-
int actions_len;
180-
181-
/* Store pkt_key clone when creating deferred action. */
182-
struct sw_flow_key pkt_key;
183-
};
184-
185-
#define DEFERRED_ACTION_FIFO_SIZE 10
186-
#define OVS_RECURSION_LIMIT 5
187-
#define OVS_DEFERRED_ACTION_THRESHOLD (OVS_RECURSION_LIMIT - 2)
188-
189-
struct action_fifo {
190-
int head;
191-
int tail;
192-
/* Deferred action fifo queue storage. */
193-
struct deferred_action fifo[DEFERRED_ACTION_FIFO_SIZE];
194-
};
195-
196-
struct action_flow_keys {
197-
struct sw_flow_key key[OVS_DEFERRED_ACTION_THRESHOLD];
198-
};
199-
200-
struct ovs_pcpu_storage {
201-
struct action_fifo action_fifos;
202-
struct action_flow_keys flow_keys;
203-
int exec_level;
204-
struct task_struct *owner;
205-
local_lock_t bh_lock;
206-
};
207-
DECLARE_PER_CPU(struct ovs_pcpu_storage, ovs_pcpu_storage);
208-
209176
/**
210177
* enum ovs_pkt_hash_types - hash info to include with a packet
211178
* to send to userspace.

0 commit comments

Comments
 (0)