Skip to content

Commit

Permalink
datapath: Replace __force type cast with rcu_dereference_raw().
Browse files Browse the repository at this point in the history
rcu_dereference_raw() api is cleaner way of accessing RCU pointer
when no locking is required.

Signed-off-by: Pravin B Shelar <[email protected]>
Acked-by: Andy Zhou <[email protected]>
  • Loading branch information
Pravin B Shelar committed Oct 24, 2014
1 parent 4efe455 commit 46051cf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion datapath/datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
ovs_flow_tbl_remove(&dp->table, flow);
ovs_unlock();

reply = ovs_flow_cmd_alloc_info((const struct sw_flow_actions __force *)flow->sf_acts,
reply = ovs_flow_cmd_alloc_info(rcu_dereference_raw(flow->sf_acts),
info, false);

if (likely(reply)) {
Expand Down
8 changes: 4 additions & 4 deletions datapath/flow_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ static void flow_free(struct sw_flow *flow)
{
int node;

kfree((struct sw_flow_actions __force *)flow->sf_acts);
kfree(rcu_dereference_raw(flow->sf_acts));
for_each_node(node)
if (flow->stats[node])
kmem_cache_free(flow_stats_cache,
(struct flow_stats __force *)flow->stats[node]);
rcu_dereference_raw(flow->stats[node]));
kmem_cache_free(flow_cache, flow);
}

Expand Down Expand Up @@ -334,10 +334,10 @@ static void table_instance_destroy(struct table_instance *ti, bool deferred)
* error path. */
void ovs_flow_tbl_destroy(struct flow_table *table)
{
struct table_instance *ti = (struct table_instance __force *)table->ti;
struct table_instance *ti = rcu_dereference_raw(table->ti);

free_percpu(table->mask_cache);
kfree((struct mask_array __force *)table->mask_array);
kfree(rcu_dereference_raw(table->mask_array));
table_instance_destroy(ti, false);
}

Expand Down
2 changes: 1 addition & 1 deletion datapath/vport.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
*/
void ovs_vport_free(struct vport *vport)
{
kfree((struct vport_portids __force *)vport->upcall_portids);
kfree(rcu_dereference_raw(vport->upcall_portids));
free_percpu(vport->percpu_stats);
kfree(vport);
}
Expand Down

0 comments on commit 46051cf

Please sign in to comment.