From patchwork Thu Apr 4 15:44:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 13618017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5C39CD129B for ; Thu, 4 Apr 2024 15:46:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63ADA6B009E; Thu, 4 Apr 2024 11:46:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EA456B009F; Thu, 4 Apr 2024 11:46:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48AD36B00A0; Thu, 4 Apr 2024 11:46:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2810C6B009E for ; Thu, 4 Apr 2024 11:46:21 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E95B8C0F5C for ; Thu, 4 Apr 2024 15:46:20 +0000 (UTC) X-FDA: 81972276120.11.AE9E25A Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf24.hostedemail.com (Postfix) with ESMTP id BDBAF180010 for ; Thu, 4 Apr 2024 15:46:18 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Oj3C3Ewi; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf24.hostedemail.com: domain of aleksander.lobakin@intel.com designates 192.198.163.12 as permitted sender) smtp.mailfrom=aleksander.lobakin@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712245579; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TWULREaDYd0GhQ+xj1jSHJEQCjdrCYSQBfrRSSrbhK4=; b=PqVNTB/eOvhqmhbF1GaYp9NZJNcrhWp57Ftdyr8TrGVHsg9aGKgJTnVTQXycFt/VU5wEtg sF+AqA3jfKQ5Yz2pxB4BDLaWrDzQ8jrMZVchVBpv5U1qcZGPwUo0Fais4TTOqIgh8XrZo3 /Zg/5Oo0XlnEjjw+VyHa4R7dhCiw5Bg= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Oj3C3Ewi; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf24.hostedemail.com: domain of aleksander.lobakin@intel.com designates 192.198.163.12 as permitted sender) smtp.mailfrom=aleksander.lobakin@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712245579; a=rsa-sha256; cv=none; b=C9ZAECLPuUAFtKOW3kSElmMwOA7x4lo9KF1oNVsv2EMFMqnTUvMb/sfhU/VWHZ105vfoB+ 7aEhyfGTRY44Zo8ay8Zf4kHZkYtUlvFMH4Lu6PnVUNJypxEgNZQDVmF7VV8vqxKceUjZY6 ua+FdJjPNGGOONZCW0oqlX5ok4gZ1iY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712245579; x=1743781579; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zVEgMieKOqlQ10EzIrZ/nTBJY74dbSjTG4wpdzvMuBc=; b=Oj3C3Ewi8fjlcwpgiRNPBMSF7LQNgNK+QSwmSVyBapNSb1iwGN/nac0V QOYogmscx9untcsLvb7w3/jDZtA+aS1XaDtQo0uDZ0ErmHBDVcX5GLosp 7Czu1PcQeq/seUgVa4yKuL4uaoKRyIo8z179nI5HcyVBmbbDw4g2RO6J0 QF4OP4LwbgJ8g+TiOjn5UknOwYi/QMe4nuE296TJaUmtIodhePTUH50jS DEONl0YzYDtMExDi36EYjCGTEyZq1QJxCiUILThaCVEsjhOfwuHzacG7d f7YGOraAN373c1x4NNyDjcBqAs/w2yTg4ozjtha2iSSOztDM9CRn1yqi/ w==; X-CSE-ConnectionGUID: 2yx3tDKtRiWH2OCxcg32tw== X-CSE-MsgGUID: vsso1ZvTRR6gHx6P3vMASA== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="11312278" X-IronPort-AV: E=Sophos;i="6.07,179,1708416000"; d="scan'208";a="11312278" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Apr 2024 08:46:18 -0700 X-CSE-ConnectionGUID: GqwZ3y4WS0adSW3xkpnDgQ== X-CSE-MsgGUID: kipuvfN9ShqhUig8GjCFNg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,179,1708416000"; d="scan'208";a="23288218" Received: from newjersey.igk.intel.com ([10.102.20.203]) by fmviesa005.fm.intel.com with ESMTP; 04 Apr 2024 08:46:14 -0700 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , Alexander Duyck , Yunsheng Lin , Jesper Dangaard Brouer , Ilias Apalodimas , Christoph Lameter , Vlastimil Babka , Andrew Morton , nex.sw.ncis.osdt.itp.upstreaming@intel.com, netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v9 8/9] iavf: pack iavf_ring more efficiently Date: Thu, 4 Apr 2024 17:44:01 +0200 Message-ID: <20240404154402.3581254-9-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240404154402.3581254-1-aleksander.lobakin@intel.com> References: <20240404154402.3581254-1-aleksander.lobakin@intel.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: BDBAF180010 X-Stat-Signature: 97z8yz8jpnbe15iszbt3ahbih5d5qqdr X-Rspam-User: X-HE-Tag: 1712245578-580839 X-HE-Meta: U2FsdGVkX1+0hYrB4mjJxxvtQhmgidleyYn3kPSmRK7oEy3Uqde1cgteHFDEH6R5JZT9P0uE3XRowMsvkpnE6maPWjiLfUwz4SjkxlgbrOtFMr8veqC38rSofbdEC4xnOeSoS6Fw0RGQ0Qx6+ipteW5sryVKma+dtMgPg29YAf9+t5N/Y4Qt9B+T66qUepMtO9sS++LTxNzkfmGJKB1+MnTqZh1EwvxIbgybugZLd6JWSvxrM3I/qGfU98ZN/G85Eg6KyMESC5xax0Jxmmq0QCElP/7V4FpGWGWRbUJ8T9Kf/sF72JI/igHxvwv0nwEJndci/0DmFHnTS0c2mg0aiQ5SEpgIaq69DxMcQujsRHldkJ/I9ec2SLb9vTjIkhKOaf8ycXQWUBjA+E4XBTEPwoX2kJz3+LyuT4lHaGcWWjAye6SjXdZkjYHJhtnbgcgOsLHidmnIy/ssjbAT/du2ailEAAW8wrrrFrd6KZhMMtxyRYJsFUPU/Zo9qGwbYNJcI4IRkpPs6C/a/vmiTuW23q3hT2zab8rkNeA3oR0/f0oNvsfeGSwjwSCBFFVa35yB/L7cEOYypy1T54slvvui2nskPro1lsA+6fstyiRp43KWtCuZD9RvCaZ8Xp68sbxEyZYqbsloaTpfKkhPmcwx7uojflWZBfiAjJZ16pa5/3+SW0Jh52+VmTl7l45V1T514GNkyJA+HTVcQeX55H8scl7/xpB1hhQ5JB4K0gYSfp6oCvi7MrI6HqEf3aQsfSS0B9+Ri7Wg8S4FrvqbT3wP7QOzP8TvpR11OPDHh7f6pUe4tM+bvmgKyDm5FZ9cOvd31sld2sSugkJmm3pI1XkVXWFjUnPybfaUUVDKEqHlkFiY77/z/BU8IWHKRQKQx/+Jo6V3noCIX2Vp95ON+bjETtWKjFbqc/StwzDQeVFujn47kKICBpDpP0BbAr5Ki3et85dyED9QTDmG/GG0Lf5 nL/a6t0o RYizQDx4sH6GE7/OChopR7+vBJFGB7Ri59WpIjeGwFdVvV12FIh2a+bhTspD0qtBREdJ9PXF+j4gKWcE3vCXJbCGqM4BQkDg3Qk4hLnOTef8ITgFPe2SuIYt5Ek3Wkf+Wv4jtZkSxAl2pReUIdc6OvJCwBZu8mVSmWX6jeSMRwVroeUT5C8CgrOHfkyxyP8N3qNjUbrTx5CEOyyQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Before replacing the Rx buffer management with libie, clean up &iavf_ring a bit. There are several fields not used anywhere in the code -- simply remove them. Move ::tail up to remove a hole. Replace ::arm_wb boolean with 1-bit flag in ::flags to free 1 more byte. Finally, move ::prev_pkt_ctr out of &iavf_tx_queue_stats -- it doesn't belong there (used for Tx stall detection). Place it next to the stats on the ring itself to fill the 4-byte slot. The result: no holes and all the hot fields fit into the first 64-byte cacheline. Signed-off-by: Alexander Lobakin --- drivers/net/ethernet/intel/iavf/iavf_txrx.h | 22 +++------------------ drivers/net/ethernet/intel/iavf/iavf_txrx.c | 12 +++++------ 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.h b/drivers/net/ethernet/intel/iavf/iavf_txrx.h index e01777531635..ed559fa6f214 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.h +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.h @@ -227,7 +227,6 @@ struct iavf_tx_queue_stats { u64 tx_done_old; u64 tx_linearize; u64 tx_force_wb; - int prev_pkt_ctr; u64 tx_lost_interrupt; }; @@ -237,12 +236,6 @@ struct iavf_rx_queue_stats { u64 alloc_buff_failed; }; -enum iavf_ring_state_t { - __IAVF_TX_FDIR_INIT_DONE, - __IAVF_TX_XPS_INIT_DONE, - __IAVF_RING_STATE_NBITS /* must be last */ -}; - /* some useful defines for virtchannel interface, which * is the only remaining user of header split */ @@ -264,10 +257,8 @@ struct iavf_ring { struct iavf_tx_buffer *tx_bi; struct iavf_rx_buffer *rx_bi; }; - DECLARE_BITMAP(state, __IAVF_RING_STATE_NBITS); - u16 queue_index; /* Queue number of ring */ - u8 dcb_tc; /* Traffic class of ring */ u8 __iomem *tail; + u16 queue_index; /* Queue number of ring */ /* high bit set means dynamic, use accessors routines to read/write. * hardware only supports 2us resolution for the ITR registers. @@ -277,22 +268,14 @@ struct iavf_ring { u16 itr_setting; u16 count; /* Number of descriptors */ - u16 reg_idx; /* HW register index of the ring */ /* used in interrupt processing */ u16 next_to_use; u16 next_to_clean; - u8 atr_sample_rate; - u8 atr_count; - - bool ring_active; /* is ring online or not */ - bool arm_wb; /* do something to arm write back */ - u8 packet_stride; - u16 flags; #define IAVF_TXR_FLAGS_WB_ON_ITR BIT(0) -/* BIT(1) is free, was IAVF_RXR_FLAGS_BUILD_SKB_ENABLED */ +#define IAVF_TXR_FLAGS_ARM_WB BIT(1) /* BIT(2) is free */ #define IAVF_TXRX_FLAGS_VLAN_TAG_LOC_L2TAG1 BIT(3) #define IAVF_TXR_FLAGS_VLAN_TAG_LOC_L2TAG2 BIT(4) @@ -306,6 +289,7 @@ struct iavf_ring { struct iavf_rx_queue_stats rx_stats; }; + int prev_pkt_ctr; /* For Tx stall detection */ unsigned int size; /* length of descriptor ring in bytes */ dma_addr_t dma; /* physical address of ring */ diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethernet/intel/iavf/iavf_txrx.c index a14f7f211150..1a27fa613f6d 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c @@ -185,7 +185,7 @@ void iavf_detect_recover_hung(struct iavf_vsi *vsi) * pending work. */ packets = tx_ring->stats.packets & INT_MAX; - if (tx_ring->tx_stats.prev_pkt_ctr == packets) { + if (tx_ring->prev_pkt_ctr == packets) { iavf_force_wb(vsi, tx_ring->q_vector); continue; } @@ -194,7 +194,7 @@ void iavf_detect_recover_hung(struct iavf_vsi *vsi) * to iavf_get_tx_pending() */ smp_rmb(); - tx_ring->tx_stats.prev_pkt_ctr = + tx_ring->prev_pkt_ctr = iavf_get_tx_pending(tx_ring, true) ? packets : -1; } } @@ -320,7 +320,7 @@ static bool iavf_clean_tx_irq(struct iavf_vsi *vsi, ((j / WB_STRIDE) == 0) && (j > 0) && !test_bit(__IAVF_VSI_DOWN, vsi->state) && (IAVF_DESC_UNUSED(tx_ring) != tx_ring->count)) - tx_ring->arm_wb = true; + tx_ring->flags |= IAVF_TXR_FLAGS_ARM_WB; } /* notify netdev of completed buffers */ @@ -675,7 +675,7 @@ int iavf_setup_tx_descriptors(struct iavf_ring *tx_ring) tx_ring->next_to_use = 0; tx_ring->next_to_clean = 0; - tx_ring->tx_stats.prev_pkt_ctr = -1; + tx_ring->prev_pkt_ctr = -1; return 0; err: @@ -1491,8 +1491,8 @@ int iavf_napi_poll(struct napi_struct *napi, int budget) clean_complete = false; continue; } - arm_wb |= ring->arm_wb; - ring->arm_wb = false; + arm_wb |= !!(ring->flags & IAVF_TXR_FLAGS_ARM_WB); + ring->flags &= ~IAVF_TXR_FLAGS_ARM_WB; } /* Handle case where we are called by netpoll with a budget of 0 */