@@ -78,22 +78,17 @@ struct action_flow_keys {
78
78
struct sw_flow_key key [OVS_DEFERRED_ACTION_THRESHOLD ];
79
79
};
80
80
81
- struct ovs_pcpu_storage {
82
- struct action_fifo action_fifos ;
83
- struct action_flow_keys flow_keys ;
84
- int exec_level ;
85
- };
86
-
87
- static DEFINE_PER_CPU (struct ovs_pcpu_storage , ovs_pcpu_storage ) ;
81
+ static struct action_fifo __percpu * action_fifos ;
82
+ static struct action_flow_keys __percpu * flow_keys ;
83
+ static DEFINE_PER_CPU (int , exec_actions_level );
88
84
89
85
/* Make a clone of the 'key', using the pre-allocated percpu 'flow_keys'
90
86
* space. Return NULL if out of key spaces.
91
87
*/
92
88
static struct sw_flow_key * clone_key (const struct sw_flow_key * key_ )
93
89
{
94
- struct ovs_pcpu_storage * ovs_pcpu = this_cpu_ptr (& ovs_pcpu_storage );
95
- struct action_flow_keys * keys = & ovs_pcpu -> flow_keys ;
96
- int level = ovs_pcpu -> exec_level ;
90
+ struct action_flow_keys * keys = this_cpu_ptr (flow_keys );
91
+ int level = this_cpu_read (exec_actions_level );
97
92
struct sw_flow_key * key = NULL ;
98
93
99
94
if (level <= OVS_DEFERRED_ACTION_THRESHOLD ) {
@@ -137,9 +132,10 @@ static struct deferred_action *add_deferred_actions(struct sk_buff *skb,
137
132
const struct nlattr * actions ,
138
133
const int actions_len )
139
134
{
140
- struct action_fifo * fifo = this_cpu_ptr ( & ovs_pcpu_storage . action_fifos ) ;
135
+ struct action_fifo * fifo ;
141
136
struct deferred_action * da ;
142
137
138
+ fifo = this_cpu_ptr (action_fifos );
143
139
da = action_fifo_put (fifo );
144
140
if (da ) {
145
141
da -> skb = skb ;
@@ -1612,13 +1608,13 @@ static int clone_execute(struct datapath *dp, struct sk_buff *skb,
1612
1608
1613
1609
if (actions ) { /* Sample action */
1614
1610
if (clone_flow_key )
1615
- __this_cpu_inc (ovs_pcpu_storage . exec_level );
1611
+ __this_cpu_inc (exec_actions_level );
1616
1612
1617
1613
err = do_execute_actions (dp , skb , clone ,
1618
1614
actions , len );
1619
1615
1620
1616
if (clone_flow_key )
1621
- __this_cpu_dec (ovs_pcpu_storage . exec_level );
1617
+ __this_cpu_dec (exec_actions_level );
1622
1618
} else { /* Recirc action */
1623
1619
clone -> recirc_id = recirc_id ;
1624
1620
ovs_dp_process_packet (skb , clone );
@@ -1654,7 +1650,7 @@ static int clone_execute(struct datapath *dp, struct sk_buff *skb,
1654
1650
1655
1651
static void process_deferred_actions (struct datapath * dp )
1656
1652
{
1657
- struct action_fifo * fifo = this_cpu_ptr (& ovs_pcpu_storage . action_fifos );
1653
+ struct action_fifo * fifo = this_cpu_ptr (action_fifos );
1658
1654
1659
1655
/* Do not touch the FIFO in case there is no deferred actions. */
1660
1656
if (action_fifo_is_empty (fifo ))
@@ -1685,7 +1681,7 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
1685
1681
{
1686
1682
int err , level ;
1687
1683
1688
- level = __this_cpu_inc_return (ovs_pcpu_storage . exec_level );
1684
+ level = __this_cpu_inc_return (exec_actions_level );
1689
1685
if (unlikely (level > OVS_RECURSION_LIMIT )) {
1690
1686
net_crit_ratelimited ("ovs: recursion limit reached on datapath %s, probable configuration error\n" ,
1691
1687
ovs_dp_name (dp ));
@@ -1702,6 +1698,27 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
1702
1698
process_deferred_actions (dp );
1703
1699
1704
1700
out :
1705
- __this_cpu_dec (ovs_pcpu_storage . exec_level );
1701
+ __this_cpu_dec (exec_actions_level );
1706
1702
return err ;
1707
1703
}
1704
+
1705
+ int action_fifos_init (void )
1706
+ {
1707
+ action_fifos = alloc_percpu (struct action_fifo );
1708
+ if (!action_fifos )
1709
+ return - ENOMEM ;
1710
+
1711
+ flow_keys = alloc_percpu (struct action_flow_keys );
1712
+ if (!flow_keys ) {
1713
+ free_percpu (action_fifos );
1714
+ return - ENOMEM ;
1715
+ }
1716
+
1717
+ return 0 ;
1718
+ }
1719
+
1720
+ void action_fifos_exit (void )
1721
+ {
1722
+ free_percpu (action_fifos );
1723
+ free_percpu (flow_keys );
1724
+ }
0 commit comments