diff mbox series

[ovs-dev,V3,13/24] datapath: select vport upcall portid directly

Message ID 20200916173311.30956-14-gvrose8192@gmail.com
State Changes Requested
Headers show
Series Add support for Linux kernels up to 5.8.x | expand

Commit Message

Gregory Rose Sept. 16, 2020, 5:33 p.m. UTC
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

Upstream commit:
    commit 90ce9f23a886bdef7a4b7a9bd52c7a50a6a81635
    Author: Tonghao Zhang <xiangxia.m.yue@gmail.com>
    Date:   Thu Nov 7 00:34:28 2019 +0800

    net: openvswitch: select vport upcall portid directly

    The commit 69c51582ff786 ("dpif-netlink: don't allocate per
    thread netlink sockets"), in Open vSwitch ovs-vswitchd, has
    changed the number of allocated sockets to just one per port
    by moving the socket array from a per handler structure to
    a per datapath one. In the kernel datapath, a vport will have
    only one socket in most case, if so select it directly in
    fast-path.

    Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
    Acked-by: Pravin B Shelar <pshelar@ovn.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Reviewed-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
---
 datapath/vport.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Yi-Hung Wei Sept. 29, 2020, 9:44 p.m. UTC | #1
On Wed, Sep 16, 2020 at 10:34 AM Greg Rose <gvrose8192@gmail.com> wrote:
>
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>
> Upstream commit:
>     commit 90ce9f23a886bdef7a4b7a9bd52c7a50a6a81635
>     Author: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>     Date:   Thu Nov 7 00:34:28 2019 +0800
>
>     net: openvswitch: select vport upcall portid directly
>
>     The commit 69c51582ff786 ("dpif-netlink: don't allocate per
>     thread netlink sockets"), in Open vSwitch ovs-vswitchd, has
>     changed the number of allocated sockets to just one per port
>     by moving the socket array from a per handler structure to
>     a per datapath one. In the kernel datapath, a vport will have
>     only one socket in most case, if so select it directly in
>     fast-path.
>
>     Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>     Acked-by: Pravin B Shelar <pshelar@ovn.org>
>     Signed-off-by: David S. Miller <davem@davemloft.net>
>
> Cc: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> Reviewed-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> Signed-off-by: Greg Rose <gvrose8192@gmail.com>
> ---
LGTM
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
diff mbox series

Patch

diff --git a/datapath/vport.c b/datapath/vport.c
index f929282dc..bd62c5612 100644
--- a/datapath/vport.c
+++ b/datapath/vport.c
@@ -507,8 +507,9 @@  u32 ovs_vport_find_upcall_portid(const struct vport *vport, struct sk_buff *skb)
 
 	ids = rcu_dereference(vport->upcall_portids);
 
-	if (ids->n_ids == 1 && ids->ids[0] == 0)
-		return 0;
+	/* If there is only one portid, select it in the fast-path. */
+	if (ids->n_ids == 1)
+		return ids->ids[0];
 
 	hash = skb_get_hash(skb);
 	ids_index = hash - ids->n_ids * reciprocal_divide(hash, ids->rn_ids);