From patchwork Fri Feb 12 17:17:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Van Haaren, Harry" X-Patchwork-Id: 1439958 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.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DcgHs2gyZz9sTD for ; Sat, 13 Feb 2021 04:20:41 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D181E85B8A; Fri, 12 Feb 2021 17:20:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6uO1PgnTcFcM; Fri, 12 Feb 2021 17:20:36 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 846418761F; Fri, 12 Feb 2021 17:19:37 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 61026C1E72; Fri, 12 Feb 2021 17:19:37 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 00451C0891 for ; Fri, 12 Feb 2021 17:19:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id BF8756F99E for ; Fri, 12 Feb 2021 17:19:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PNcEmL3xs3E2 for ; Fri, 12 Feb 2021 17:19:34 +0000 (UTC) Received: by smtp3.osuosl.org (Postfix, from userid 1001) id 76BC46F8CF; Fri, 12 Feb 2021 17:19:34 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by smtp3.osuosl.org (Postfix) with ESMTPS id C555A6F7B3 for ; Fri, 12 Feb 2021 17:17:56 +0000 (UTC) IronPort-SDR: IQ7HjIuCRn2NI2RDeZZdAEyh+l7Ur64CfQwx9xlwc+RfOY1aBgLYHAQA+DbSz9POYvSIf3Zb3o uWvywtvjKtOA== X-IronPort-AV: E=McAfee;i="6000,8403,9893"; a="201595249" X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="201595249" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 09:17:56 -0800 IronPort-SDR: I83lJSyapFqtkrwVTI4yPFsSLnitC+7QMXHPoWNPK91Eq4xjCh1H9vUH0OIT95xxkkUeBxESWO 1MZiWPJ05wKA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="360485252" Received: from silpixa00400633.ir.intel.com ([10.237.213.44]) by orsmga003.jf.intel.com with ESMTP; 12 Feb 2021 09:17:54 -0800 From: Harry van Haaren To: ovs-dev@openvswitch.org Date: Fri, 12 Feb 2021 17:17:17 +0000 Message-Id: <20210212171718.2189798-16-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210212171718.2189798-1-harry.van.haaren@intel.com> References: <20210104163653.2218575-1-harry.van.haaren@intel.com> <20210212171718.2189798-1-harry.van.haaren@intel.com> MIME-Version: 1.0 Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v9 15/16] netdev: Optimize netdev_send_prepare_batch 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: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Optimize for the best case here where all packets will be compatible with 'netdev_flags'. Signed-off-by: Harry van Haaren Co-authored-by: Cian Ferriter Signed-off-by: Cian Ferriter --- v9: rebase 2 --- NEWS | 2 ++ lib/netdev.c | 31 ++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 2ffc155f9..cbdcf53a1 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,8 @@ Post-v2.15.0 CPU supports it. This enhances performance by using the native vpopcount instructions, instead of the emulated version of vpopcount. * Optimize dp_netdev_output by enhancing compiler optimization potential. + * Optimize netdev sending by assuming the happy case, and using fallback + for if the netdev doesnt meet the required HWOL needs of a packet. v2.15.0 - xx xxx xxxx --------------------- diff --git a/lib/netdev.c b/lib/netdev.c index 91e91955c..29a5f1aa9 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -837,20 +837,33 @@ static void netdev_send_prepare_batch(const struct netdev *netdev, struct dp_packet_batch *batch) { - struct dp_packet *packet; - size_t i, size = dp_packet_batch_size(batch); + struct dp_packet *p; + uint32_t i, size = dp_packet_batch_size(batch); + char *err_msg = NULL; - DP_PACKET_BATCH_REFILL_FOR_EACH (i, size, packet, batch) { - char *errormsg = NULL; + for (i = 0; i < size; i++) { + p = batch->packets[i]; + int pkt_ok = netdev_send_prepare_packet(netdev->ol_flags, p, &err_msg); - if (netdev_send_prepare_packet(netdev->ol_flags, packet, &errormsg)) { - dp_packet_batch_refill(batch, packet, i); + if (OVS_UNLIKELY(!pkt_ok)) { + goto refill_loop; + } + } + + return; + +refill_loop: + /* Loop through packets from the start of the batch again. This is the + * exceptional case where packets aren't compatible with 'netdev_flags'. */ + DP_PACKET_BATCH_REFILL_FOR_EACH (i, size, p, batch) { + if (netdev_send_prepare_packet(netdev->ol_flags, p, &err_msg)) { + dp_packet_batch_refill(batch, p, i); } else { - dp_packet_delete(packet); + dp_packet_delete(p); COVERAGE_INC(netdev_send_prepare_drops); VLOG_WARN_RL(&rl, "%s: Packet dropped: %s", - netdev_get_name(netdev), errormsg); - free(errormsg); + netdev_get_name(netdev), err_msg); + free(err_msg); } } }