From patchwork Mon Jan 4 16:36:53 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: 1422177 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com 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 4D8hFJ0Zpfz9sVr for ; Tue, 5 Jan 2021 03:40:20 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id A219686974; Mon, 4 Jan 2021 16:40:18 +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 kPpUGv3+ytb2; Mon, 4 Jan 2021 16:40:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 952EE869CB; Mon, 4 Jan 2021 16:38:44 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 76B13C08A1; Mon, 4 Jan 2021 16:38:44 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3C230C1E71 for ; Mon, 4 Jan 2021 16:38:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 2572686948 for ; Mon, 4 Jan 2021 16:38:43 +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 33jX1yQp4NOm for ; Mon, 4 Jan 2021 16:38:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by whitealder.osuosl.org (Postfix) with ESMTPS id E04A286A04 for ; Mon, 4 Jan 2021 16:38:01 +0000 (UTC) IronPort-SDR: u9/TFwzZIrV22dtXrpq4owbvYli8HSLrMVJ9mQ2TYZcx/wARhYuLB0UUhYS5UJOKAh+chs/V0l Hs1494bK5yPA== X-IronPort-AV: E=McAfee;i="6000,8403,9854"; a="177130176" X-IronPort-AV: E=Sophos;i="5.78,474,1599548400"; d="scan'208";a="177130176" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2021 08:38:01 -0800 IronPort-SDR: 79iFgTc8Ifack/TZTTkk7xNPbPA8mvWpis2H3nkR9IS2uGgZWLLrZfInaGNSyoubysJRt+Qc0F C4KK7WqAi0dw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,474,1599548400"; d="scan'208";a="462000503" Received: from silpixa00400633.ir.intel.com ([10.237.213.44]) by fmsmga001.fm.intel.com with ESMTP; 04 Jan 2021 08:38:00 -0800 From: Harry van Haaren To: ovs-dev@openvswitch.org Date: Mon, 4 Jan 2021 16:36:53 +0000 Message-Id: <20210104163653.2218575-17-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210104163653.2218575-1-harry.van.haaren@intel.com> References: <20201216181033.572425-2-harry.van.haaren@intel.com> <20210104163653.2218575-1-harry.van.haaren@intel.com> MIME-Version: 1.0 Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v8 16/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 --- NEWS | 2 ++ lib/netdev.c | 31 ++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index b5b140512..7eeb51cfc 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,8 @@ Post-v2.14.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. - The environment variable OVS_UNBOUND_CONF, if set, is now used as the DNS resolver's (unbound) configuration file. - Linux datapath: 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); } } }