On Tue, Feb 4, 2014 at 11:10 AM, Jarno Rajahalme <jrajaha...@nicira.com> wrote:
> Change ovs_dp_cmd_get() and ovs_flow_cmd_get() to only take the
> rcu_read_lock(), instead of ovs_lock(), as nothing need to be changed.
> This was done by ovs_vport_cmd_get() already.
>
ovs_dp_cmd_get() and ovs_flow_cmd_get() does blocking kmalloc,
therefore we can use rcu locking.
I do not think ovs_vport_cmd_get() is need to be lockless, we can just
take ovs-lock there to not depend on emergency memory pool.


> Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com>
> ---
>  datapath/datapath.c |   17 ++++++-----------
>  1 file changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/datapath/datapath.c b/datapath/datapath.c
> index 7992330..bafe486 100644
> --- a/datapath/datapath.c
> +++ b/datapath/datapath.c
> @@ -918,29 +918,27 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct 
> genl_info *info)
>         if (err)
>                 return err;
>
> -       ovs_lock();
> +       rcu_read_lock();
>         dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
>         if (!dp) {
>                 err = -ENODEV;
>                 goto unlock;
>         }
> -
>         flow = ovs_flow_tbl_lookup(&dp->table, &key);
>         if (!flow || !ovs_flow_cmp_unmasked_key(flow, &match)) {
>                 err = -ENOENT;
>                 goto unlock;
>         }
> -
>         reply = ovs_flow_cmd_build_info(flow, dp, info, OVS_FLOW_CMD_NEW);
>         if (IS_ERR(reply)) {
>                 err = PTR_ERR(reply);
>                 goto unlock;
>         }
> +       rcu_read_unlock();
>
> -       ovs_unlock();
>         return genlmsg_reply(reply, info);
>  unlock:
> -       ovs_unlock();
> +       rcu_read_unlock();
>         return err;
>  }
>
> @@ -1384,24 +1382,23 @@ static int ovs_dp_cmd_get(struct sk_buff *skb, struct 
> genl_info *info)
>         struct datapath *dp;
>         int err;
>
> -       ovs_lock();
> +       rcu_read_lock();
>         dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs);
>         if (IS_ERR(dp)) {
>                 err = PTR_ERR(dp);
>                 goto unlock;
>         }
> -
>         reply = ovs_dp_cmd_build_info(dp, info, OVS_DP_CMD_NEW);
>         if (IS_ERR(reply)) {
>                 err = PTR_ERR(reply);
>                 goto unlock;
>         }
> +       rcu_read_unlock();
>
> -       ovs_unlock();
>         return genlmsg_reply(reply, info);
>
>  unlock:
> -       ovs_unlock();
> +       rcu_read_unlock();
>         return err;
>  }
>
> @@ -1741,13 +1738,11 @@ static int ovs_vport_cmd_get(struct sk_buff *skb, 
> struct genl_info *info)
>         err = PTR_ERR(vport);
>         if (IS_ERR(vport))
>                 goto exit_unlock;
> -
>         reply = ovs_vport_cmd_build_info(vport, info->snd_portid,
>                                          info->snd_seq, OVS_VPORT_CMD_NEW);
>         err = PTR_ERR(reply);
>         if (IS_ERR(reply))
>                 goto exit_unlock;
> -
>         rcu_read_unlock();
>
>         return genlmsg_reply(reply, info);
> --
> 1.7.10.4
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to