From patchwork Thu Apr 18 11:36:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 13634542 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 E4DBAC4345F for ; Thu, 18 Apr 2024 11:37:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77D386B00AA; Thu, 18 Apr 2024 07:37:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 72CA26B00AB; Thu, 18 Apr 2024 07:37:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A8236B00AC; Thu, 18 Apr 2024 07:37:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3AB2C6B00AA for ; Thu, 18 Apr 2024 07:37:12 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F352DC11DC for ; Thu, 18 Apr 2024 11:37:11 +0000 (UTC) X-FDA: 82022451462.24.D46861C Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by imf25.hostedemail.com (Postfix) with ESMTP id DAB61A0006 for ; Thu, 18 Apr 2024 11:37:09 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=eRpOu6iu; spf=pass (imf25.hostedemail.com: domain of aleksander.lobakin@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=aleksander.lobakin@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713440230; 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=pKflrl/bdnJLDzZgaZqM51kd7pXqZmTCfFQXc/M/qlo=; b=Msw11kaU9SfWGKmbz4L76jQWSmgJSLdEVQZG3usOPsJznkugfVlaN0CUKfz3eyrbAC0jRs AW+6fw1K2Ge6TntQ5eXTSjqhwHFvwBN6SYpNShtaeW3T+9wf26Rnlt9Qn5kZWSO6NWk07P 9NvM7Hx8AX0LzXOboPX0fiXWEie5FkA= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=eRpOu6iu; spf=pass (imf25.hostedemail.com: domain of aleksander.lobakin@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=aleksander.lobakin@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713440230; a=rsa-sha256; cv=none; b=7kTdKH5ivQix2SqRdPlJhkcc2nPPutoXfcNirQwewtRBkxOj1xx/od4fTSSykaRtE5vNGU Q4ZOm/PAYeiCAqxu5CFuVbtoDjXIOiZ9ABy063Z3wl8562xsUx6iF2Pq819hKL65ChrOqd 5I/5Uue0mHK5raYSaLrjQneQfiFNeEc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713440230; x=1744976230; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kSrcRx/NAAWdhuB//E1o7Q3AqnsepHC5nNY58kWnwK8=; b=eRpOu6iu72watlOgyqmsoPF4bR8k0rq7W7MSE+co5hH9eOhG4wq8vdWC VK6nbxukwnx8vkNJbLPjVKW7OooLF3Yv2Q6L87xX6XGTvwJ/670YEWaXB 1HosSZGIhsgU10+HT3nVZbKNV9dwFCxvUPX6ezCt3tKXFFb7torzYf5ah 4D31US1PQki9idF3q89b4Ms/IKq3+fb0C39XYnH60KKeRgP1MvylSvCxJ kIK3q5MGAIKAVL1sKG9RMrVf/Q1tYES6rzsFatt0Lvh87BF9on7zBrEP+ QXtKXJxxX19c6IOIc1iMfRvfWxkbH5DHIwejuKg95I+rA8HMaKtz3J2ao g==; X-CSE-ConnectionGUID: m97HKDnXQ1GBjiPbdPBTQw== X-CSE-MsgGUID: a31FTKVvRdC8ZxNIumfOjw== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="19587824" X-IronPort-AV: E=Sophos;i="6.07,212,1708416000"; d="scan'208";a="19587824" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 04:37:09 -0700 X-CSE-ConnectionGUID: K64o/89+TC+ds7zfU2Yybw== X-CSE-MsgGUID: UOs9e55lRzq/XZW8d5CUDA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,212,1708416000"; d="scan'208";a="27586154" Received: from newjersey.igk.intel.com ([10.102.20.203]) by fmviesa004.fm.intel.com with ESMTP; 18 Apr 2024 04:37:05 -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 , Przemek Kitszel , 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 v10 08/10] iavf: pack iavf_ring more efficiently Date: Thu, 18 Apr 2024 13:36:14 +0200 Message-ID: <20240418113616.1108566-9-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240418113616.1108566-1-aleksander.lobakin@intel.com> References: <20240418113616.1108566-1-aleksander.lobakin@intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: DAB61A0006 X-Stat-Signature: fjguz3979pke75gspcm6bc7zq37dgoz6 X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1713440229-938615 X-HE-Meta: U2FsdGVkX199pi+YmSVxsXMnfRDRNYghJ5KA3sqZFhfbD0EhsDw96NaaGNKM2t+aHJV49AX62jBmLPKUoy5X76t0ngpjA4Tda1bzruuu7ArWUGMmuMO2CSNhUDGF01aiGO8TKEFoFS/dBb9TI5PWXC0zzaAEeZHbzevDUjJLs3Y3f1stHtBJMjSLD0PKnD1o71YC6DaSbBJPTWd7EGecrMXs26bXJrfjDBu1j6V7g0NPkLdAL0P4/yflxbOzR87+q7Hd0hVg4eZBrw1FxpK+NLikkHMYE3tmloq5yf2ce/mMfyH+5SyTvpvW90QNoqggYnj+BD4NYGy4oVC7K30MkB/arkDSfUm+7Hmqb1+e6+x9R2gcVcRlt2UJUpQbZh2+zyVhVLjJcGhroZDszRANgzLpkCxzOBqw4tZ6QxYAu3iq02DY+SsXEORoGYDB42dTHRO9bPRU91G+QYn0FRN3eT4ibltw+v31Ab8rBQFfBvItFZw86+SgOdmLjiaxcL4xcrRq+AunMwEZIttPtGNzIatAbMWVYrypsK+TyDoAxe/6uOU0wovR56Y64spoBArhP76C22mIdAi/593RvhWdfjXr6nQt2nlt0NMo07Jt7/vgJNkGxuSIeZzWXnZeQptA1ki/8DXw72fOSC6mZDeKDI2w6zsBue1Z9kz9HOSYVgpzqNURSt10WcpmqsvxAFYBdhdotdkjOYZLGvB/y7qWNF4Sdo7/3YWm3wocG56VhjXZT8eTZ/wDtksOZwixzE7skkxgUkb77dzHQ2Gjv/5SQAmLejtGvlq6TGcJds0Yf4CHInGD1x8DOFTQzO2yTI2F4QCcHydh95AJllwluIJdiuSc8fBaa97OGqB6gWmqBCjaSPv/WmBzexqvvhBsLHIS+xjg5FlZwvqODFMSUuPXH8+RfCNgkEZn68Zi6qyCyu/6ECpLiwHRXYv4BzggwOLZaAo6HZzTaoRJdW1StgI NgH459Qw XXc81kF32ji/IubxljdRf2yni29P5srNjIvZAPdNJ0Smx2DX+YpnqzgZtyrYcLDUYsWTwl18tQn3RunMV6VgtmRMQQsDPArV2aVQg4Mvc8K4QoNKsdv1IRp0+iYYhLF4qBbuCOx/ty/sf2FsWo98Ouzjlgj6OPGOnO5KrBXVfXAxAUqgKdpL9so6uwxrMhnBwKyElrYp2DWKQvc8= 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 c7602c173420..2ec68b51bebe 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 */