From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mail.toke.dk; spf=pass (mailfrom) smtp.mailfrom=intel.com (client-ip=134.134.136.126; helo=mgamail.intel.com; envelope-from=larysa.zaremba@intel.com; receiver=) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=f5wwgnN3 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by mail.toke.dk (Postfix) with ESMTPS id F1EF5A2CB7F for ; Wed, 27 Sep 2023 09:58:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695801505; x=1727337505; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=U8eljhMLEyBIju175yvG4Bi0XR8ptK6pcnPdUl+zPnU=; b=f5wwgnN3OwzE64KgpB0ffiOqRqvtdJZvHzL/0Mmj34nAeaDroSTe7NZj GidMvuZg0ut3AUg1kg1WA2HaJCFtbI1QuFNDiqpd8j2X7tgd+jjrqyiI9 lQRAMz8D46dXCSBrGKr/9km8NmXjC7RbKHmmPYU1ixY9mc32d03oj4di1 3Rlmg7OHWtVCcGT0VafT2LO+HGTaNaKNd28jiiCZ8U5DX4MPBG54VoDl9 X1LzcweGRWn9zTCkLmjl8S7WTP6vDjw87vZ4hQIvhy1Co1IlYfr9NNRqO 1al1P+VaB5s3C1SdaEbI2J/UxpN5sTEi5B8aPLGDiUFVkJgsfAykGitUJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="366818125" X-IronPort-AV: E=Sophos;i="6.03,179,1694761200"; d="scan'208";a="366818125" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2023 00:58:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="725714055" X-IronPort-AV: E=Sophos;i="6.03,179,1694761200"; d="scan'208";a="725714055" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orsmga006.jf.intel.com with ESMTP; 27 Sep 2023 00:58:15 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 60EBD7EAC3; Wed, 27 Sep 2023 08:58:13 +0100 (IST) From: Larysa Zaremba To: bpf@vger.kernel.org Date: Wed, 27 Sep 2023 09:51:14 +0200 Message-ID: <20230927075124.23941-15-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230927075124.23941-1-larysa.zaremba@intel.com> References: <20230927075124.23941-1-larysa.zaremba@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 7RIIANYZ4K5UH2GIPLI4C426P6VNNQIW X-Message-ID-Hash: 7RIIANYZ4K5UH2GIPLI4C426P6VNNQIW X-MailFrom: larysa.zaremba@intel.com X-Mailman-Rule-Hits: member-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address CC: Larysa Zaremba , ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, David Ahern , Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org, Willem de Bruijn , Alexei Starovoitov , Simon Horman , Tariq Toukan , Saeed Mahameed , Maciej Fijalkowski X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] [RFC bpf-next v2 14/24] ice: put XDP meta sources assignment under a static key condition List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Usage of XDP hints requires putting additional information after the xdp_buff. In basic case, only the descriptor has to be copied on a per-packet basis, because xdp_buff permanently resides before per-ring metadata (cached time and VLAN protocol ID). However, in ZC mode, xdp_buffs come from a pool, so memory after such buffer does not contain any reliable information, so everything has to be copied, damaging the performance. Introduce a static key to enable meta sources assignment only when attached XDP program is device-bound. This patch eliminates a 6% performance drop in ZC mode, which was a result of addition of XDP hints to the driver. Signed-off-by: Larysa Zaremba --- drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_main.c | 14 ++++++++++++++ drivers/net/ethernet/intel/ice/ice_txrx.c | 3 ++- drivers/net/ethernet/intel/ice/ice_xsk.c | 3 +++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index 3d0f15f8b2b8..76d22be878a4 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -210,6 +210,7 @@ enum ice_feature { }; DECLARE_STATIC_KEY_FALSE(ice_xdp_locking_key); +DECLARE_STATIC_KEY_FALSE(ice_xdp_meta_key); struct ice_channel { struct list_head list; diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 47e8920e1727..ee0df86d34b7 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -48,6 +48,9 @@ MODULE_PARM_DESC(debug, "netif level (0=none,...,16=all)"); DEFINE_STATIC_KEY_FALSE(ice_xdp_locking_key); EXPORT_SYMBOL(ice_xdp_locking_key); +DEFINE_STATIC_KEY_FALSE(ice_xdp_meta_key); +EXPORT_SYMBOL(ice_xdp_meta_key); + /** * ice_hw_to_dev - Get device pointer from the hardware structure * @hw: pointer to the device HW structure @@ -2634,6 +2637,11 @@ static int ice_xdp_alloc_setup_rings(struct ice_vsi *vsi) return -ENOMEM; } +static bool ice_xdp_prog_has_meta(struct bpf_prog *prog) +{ + return prog && prog->aux->dev_bound; +} + /** * ice_vsi_assign_bpf_prog - set or clear bpf prog pointer on VSI * @vsi: VSI to set the bpf prog on @@ -2644,10 +2652,16 @@ static void ice_vsi_assign_bpf_prog(struct ice_vsi *vsi, struct bpf_prog *prog) struct bpf_prog *old_prog; int i; + if (ice_xdp_prog_has_meta(prog)) + static_branch_inc(&ice_xdp_meta_key); + old_prog = xchg(&vsi->xdp_prog, prog); ice_for_each_rxq(vsi, i) WRITE_ONCE(vsi->rx_rings[i]->xdp_prog, vsi->xdp_prog); + if (ice_xdp_prog_has_meta(old_prog)) + static_branch_dec(&ice_xdp_meta_key); + if (old_prog) bpf_prog_put(old_prog); } diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c index 4fd7614f243d..19fc182d1f4c 100644 --- a/drivers/net/ethernet/intel/ice/ice_txrx.c +++ b/drivers/net/ethernet/intel/ice/ice_txrx.c @@ -572,7 +572,8 @@ ice_run_xdp(struct ice_rx_ring *rx_ring, struct xdp_buff *xdp, if (!xdp_prog) goto exit; - ice_xdp_meta_set_desc(xdp, eop_desc); + if (static_branch_unlikely(&ice_xdp_meta_key)) + ice_xdp_meta_set_desc(xdp, eop_desc); act = bpf_prog_run_xdp(xdp_prog, xdp); switch (act) { diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c index 39775bb6cec1..f92d7d33fde6 100644 --- a/drivers/net/ethernet/intel/ice/ice_xsk.c +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c @@ -773,6 +773,9 @@ static void ice_prepare_pkt_ctx_zc(struct xdp_buff *xdp, union ice_32b_rx_flex_desc *eop_desc, struct ice_rx_ring *rx_ring) { + if (!static_branch_unlikely(&ice_xdp_meta_key)) + return; + XSK_CHECK_PRIV_TYPE(struct ice_xdp_buff); ((struct ice_xdp_buff *)xdp)->pkt_ctx = rx_ring->pkt_ctx; ice_xdp_meta_set_desc(xdp, eop_desc); -- 2.41.0