From patchwork Thu Aug 20 22:49:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 1348681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Ag5s5xbj; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BXg4V0QJgz9sPB for ; Fri, 21 Aug 2020 08:56:26 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 37F5C22E3F; Thu, 20 Aug 2020 22:56:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G77WIAivyUA0; Thu, 20 Aug 2020 22:56:11 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 70FF024BEF; Thu, 20 Aug 2020 22:51:14 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 46AC4C08A6; Thu, 20 Aug 2020 22:51:14 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id A2F61C0894 for ; Thu, 20 Aug 2020 22:51:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 803FD24BE6 for ; Thu, 20 Aug 2020 22:51:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4ME8-HM0+LVo for ; Thu, 20 Aug 2020 22:51:05 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by silver.osuosl.org (Postfix) with ESMTPS id 9E51423039 for ; Thu, 20 Aug 2020 22:50:21 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id r11so83079pfl.11 for ; Thu, 20 Aug 2020 15:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=E0drZVeVbZgspvJfN7scw8ild6W58u3pdaw4p4uyuqI=; b=Ag5s5xbjklE1K4lFEo2VRanJu2zOrW9bofsXQp8j5W763/u+6BkF3QJ9fNcZxnh6lT kCmgn+ERRJ638oUeF800xa+Lj0BURsWubCkc4OQEZDTyYpUAnYzSknXq865lqqFfm7Bj J5Kgn+fJNKTiJoalUGo/9BRgRK1Pvib/H55040WxjG8S+b4b0gEBhXj6StTsNpx4ruuF A70G3jqGThKiwRwQQoJa/MqdURa9GThyVQHQwDIfvD/0LGMffzUQi6XP9/5Uu0ij4nf5 9mgzCwPVYEkzSUHgJs+y1w+QcKJ2qsGC58Tko+91czkNTYqxww3TYpgy1OEMPYZd80O7 Z/Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=E0drZVeVbZgspvJfN7scw8ild6W58u3pdaw4p4uyuqI=; b=niLJKtBjjC7PUZEVGxgxP2ciuSL9X+Ysx0igXQNnQj0yhvxh7asX8HfSJQmWlRkX/W ykIKK0FA/yTJrWM8Ecis8/HIdf/7yBMjqJAY1cgQsG59kqURIHD6xiBuHLUq64Wt/YoZ PNUipB2is3UsXjQRJAnIL9jPxUr9OSIuJLFLQaawOo/2j/i7Zaag7DWRCN+t4B/kOW3u sPID72ro06yTR+15Ow7BBVanrHWz0fk+TOoQQRW6BGOylGAFOX46vBvIRN9OJEjFi8wa Xz+0IXbAgfqjeunnQsCceWijd6rvObjMZaaNcsNILpH/GiFC1SP0QYc31H1y0rC+1ZCi 8CvQ== X-Gm-Message-State: AOAM533KUDE/2OW3oP1csoqzav6mziEDb0wwQ23jeHM0SkpszPLnLcuj hR5uR0ymjeio4MjXDx2kdhc+uf4kRNDLEg== X-Google-Smtp-Source: ABdhPJyzQgdaBzO/KNNPUeS0DxGbEBReBP4FzGk2co9stDLvp6AGGbOdkvrAV9TK49+PrunwJ9iomA== X-Received: by 2002:a63:444a:: with SMTP id t10mr231334pgk.33.1597963820661; Thu, 20 Aug 2020 15:50:20 -0700 (PDT) Received: from gizo.domain (97-115-99-106.ptld.qwest.net. [97.115.99.106]) by smtp.gmail.com with ESMTPSA id y6sm116866pfr.61.2020.08.20.15.50.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 15:50:19 -0700 (PDT) From: Greg Rose To: dev@openvswitch.org Date: Thu, 20 Aug 2020 15:49:38 -0700 Message-Id: <1597963790-12362-12-git-send-email-gvrose8192@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597963790-12362-1-git-send-email-gvrose8192@gmail.com> References: <1597963790-12362-1-git-send-email-gvrose8192@gmail.com> Subject: [ovs-dev] [PATCH 11/23] datapath: add likely in flow_lookup X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Tonghao Zhang Upstream commit: commit 0a3e01371db17d753dd92ec4d0fc6247412d3b01 Author: Tonghao Zhang Date: Fri Nov 1 22:23:51 2019 +0800 net: openvswitch: add likely in flow_lookup The most case *index < ma->max, and flow-mask is not NULL. We add un/likely for performance. Signed-off-by: Tonghao Zhang Tested-by: Greg Rose Acked-by: William Tu Acked-by: Pravin B Shelar Signed-off-by: David S. Miller Cc: Tonghao Zhang Signed-off-by: Greg Rose Reviewed-by: Tonghao Zhang --- datapath/flow_table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datapath/flow_table.c b/datapath/flow_table.c index 7efaa80..ca2efe9 100644 --- a/datapath/flow_table.c +++ b/datapath/flow_table.c @@ -541,7 +541,7 @@ static struct sw_flow *flow_lookup(struct flow_table *tbl, struct sw_flow_mask *mask; int i; - if (*index < ma->max) { + if (likely(*index < ma->max)) { mask = rcu_dereference_ovsl(ma->masks[*index]); if (mask) { flow = masked_flow_lookup(ti, key, mask, n_mask_hit); @@ -556,7 +556,7 @@ static struct sw_flow *flow_lookup(struct flow_table *tbl, continue; mask = rcu_dereference_ovsl(ma->masks[i]); - if (!mask) + if (unlikely(!mask)) break; flow = masked_flow_lookup(ti, key, mask, n_mask_hit);