From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 87E2D45E05; Mon, 2 Dec 2024 14:56:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5DE2540270; Mon, 2 Dec 2024 14:56:07 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id CA6C1400D6 for ; Mon, 2 Dec 2024 14:56:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733147765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hOraEoCzkjgYbUTSsKu09FiXOJ/NeByad701QhdIyHs=; b=JkgEEq0a10+N7EC/Z2Y5coO46Z8O1hZ0PcPlP0ANvkr75xKbYTjRaQ5QxOl/CHZKdypjE2 6lqxHu+D/7Y5WfKJsX7tWFD/Em5LkfM9Ycx/l12wuAzgH+zVceVcYontzCQ8yKp37qHO/8 9mEnGGuojQkAOOTwFp/Mqeq4hw+4f28= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-15-1nu4186rOoqdrhv7XXAz0Q-1; Mon, 02 Dec 2024 08:56:02 -0500 X-MC-Unique: 1nu4186rOoqdrhv7XXAz0Q-1 X-Mimecast-MFC-AGG-ID: 1nu4186rOoqdrhv7XXAz0Q Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-53de52547abso3222182e87.3 for ; Mon, 02 Dec 2024 05:56:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733147761; x=1733752561; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hOraEoCzkjgYbUTSsKu09FiXOJ/NeByad701QhdIyHs=; b=L/QhsEZfPE64vpq09puFcbFxQ2moBNB4y5Yve6rdOroLu7PX7MIlTizPEmRpK32GEf c2DDl/BTOO/si5vpg8uCIWlJSYv3CyVW5JnTFhvaKqUwqgKE5gZ2WHUKeeuuvKRwO0Sf nB8kf4SK49NG2HytPQSzFESluO98bmwVPwwY6U0HACcPFrDWuNUm1ptqdLDBKvedGpu8 7d/8EMXqTzKyuZhTdtSaJKDzBByfsE5ijpXZDxG41d7RX/4axU/y2plnpXpIYrwqJHU3 5vfSGPmdXSdHVF+KgSPxUFebOk35QZ1EWmeRGc2y/avUftmFZgxqTI5PHhNnQi8G6Cim iRsQ== X-Gm-Message-State: AOJu0YxO5EoH7XigF/2x1/71kHLl486JWfxxGv9ImxjKugn8NRvPh2d7 l3RPwqInt0PxxTvXwCN7mKkHyswX7HdNRxEWGH1+Fxr/PAh4hXZvdaYp2+sszLAV4fL5hJOGw1+ d+PMOUgU/esm/5kX2/+10yLucwtSsTmWnJWb9J7PDuRw1kTmeZ5TPXdUKKftUlNadSvyN59V7Gb P985R9EqWFHurTnAU= X-Gm-Gg: ASbGncsOIiVJAgFn5IQQfkEujg/Vh1+0S48iXK9mW/xVDLTPlkB0fOkDqHBCVn1cDDa m21cCm0sDSR43QtQwhh70g82us4deiya+Eg== X-Received: by 2002:a05:6512:32c9:b0:53d:eef7:a017 with SMTP id 2adb3069b0e04-53df00cf65emr16227937e87.15.1733147760552; Mon, 02 Dec 2024 05:56:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHADT4sxpekitfeDQM0KQL3hpqMg+VWoRNBMSkmQOB4W76E19zjKghErEHLOG+3KCyV9UzWiNFUpdmCqeKNl2U= X-Received: by 2002:a05:6512:32c9:b0:53d:eef7:a017 with SMTP id 2adb3069b0e04-53df00cf65emr16227915e87.15.1733147760156; Mon, 02 Dec 2024 05:56:00 -0800 (PST) MIME-Version: 1.0 References: <20241122125418.2857301-1-bruce.richardson@intel.com> <20241202112444.1517416-1-bruce.richardson@intel.com> <20241202112444.1517416-12-bruce.richardson@intel.com> In-Reply-To: From: David Marchand Date: Mon, 2 Dec 2024 14:55:48 +0100 Message-ID: Subject: Re: [PATCH v1 11/21] net/_common_intel: add post-Tx buffer free function To: Bruce Richardson Cc: dev@dpdk.org, Ian Stokes , Vladimir Medvedkin , Anatoly Burakov X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: GmJoNQ_BQ2w7fDdE18AkFyeGf6IzXXjFELEaTCvuUSE_1733147761 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Mon, Dec 2, 2024 at 2:24=E2=80=AFPM Bruce Richardson wrote: > > On Mon, Dec 02, 2024 at 01:59:37PM +0100, David Marchand wrote: > > On Mon, Dec 2, 2024 at 12:27=E2=80=AFPM Bruce Richardson > > wrote: > > > > > > The actions taken for post-Tx buffer free for the SSE and AVX drivers > > > for i40e, iavf and ice drivers are all common, so centralize those in > > > common/intel_eth driver. > > > > > > Signed-off-by: Bruce Richardson > > > --- > > > drivers/net/_common_intel/tx.h | 71 +++++++++++++++++++++++= + > > > drivers/net/i40e/i40e_rxtx_vec_common.h | 72 ++++-------------------= -- > > > drivers/net/iavf/iavf_rxtx_vec_common.h | 61 ++++----------------- > > > drivers/net/ice/ice_rxtx_vec_common.h | 61 ++++----------------- > > > 4 files changed, 98 insertions(+), 167 deletions(-) > > > > > > diff --git a/drivers/net/_common_intel/tx.h b/drivers/net/_common_int= el/tx.h > > > index c372d2838b..a930309c05 100644 > > > --- a/drivers/net/_common_intel/tx.h > > > +++ b/drivers/net/_common_intel/tx.h > > > @@ -7,6 +7,7 @@ > > > > > > #include > > > #include > > > +#include > > > > > > /* forward declaration of the common intel (ci) queue structure */ > > > struct ci_tx_queue; > > > @@ -107,4 +108,74 @@ ci_tx_backlog_entry(struct ci_tx_entry *txep, st= ruct rte_mbuf **tx_pkts, uint16_ > > > txep[i].mbuf =3D tx_pkts[i]; > > > } > > > > > > +#define IETH_VPMD_TX_MAX_FREE_BUF 64 > > > + > > > +typedef int (*ci_desc_done_fn)(struct ci_tx_queue *txq, uint16_t idx= ); > > > + > > > +static __rte_always_inline int > > > +ci_tx_free_bufs(struct ci_tx_queue *txq, ci_desc_done_fn desc_done) > > > +{ > > > + struct ci_tx_entry *txep; > > > + uint32_t n; > > > + uint32_t i; > > > + int nb_free =3D 0; > > > + struct rte_mbuf *m, *free[IETH_VPMD_TX_MAX_FREE_BUF]; > > > + > > > + /* check DD bits on threshold descriptor */ > > > + if (!desc_done(txq, txq->tx_next_dd)) > > > + return 0; > > > + > > > + n =3D txq->tx_rs_thresh; > > > + > > > + /* first buffer to free from S/W ring is at index > > > + * tx_next_dd - (tx_rs_thresh-1) > > > + */ > > > + txep =3D &txq->sw_ring[txq->tx_next_dd - (n - 1)]; > > > + > > > + if (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) { > > > + for (i =3D 0; i < n; i++) { > > > + free[i] =3D txep[i].mbuf; > > > + /* no need to reset txep[i].mbuf in vector pa= th */ > > > + } > > > + rte_mempool_put_bulk(free[0]->pool, (void **)free, n)= ; > > > + goto done; > > > + } > > > + > > > + m =3D rte_pktmbuf_prefree_seg(txep[0].mbuf); > > > + if (likely(m !=3D NULL)) { > > > + free[0] =3D m; > > > + nb_free =3D 1; > > > + for (i =3D 1; i < n; i++) { > > > + m =3D rte_pktmbuf_prefree_seg(txep[i].mbuf); > > > + if (likely(m !=3D NULL)) { > > > + if (likely(m->pool =3D=3D free[0]->po= ol)) { > > > + free[nb_free++] =3D m; > > > + } else { > > > + rte_mempool_put_bulk(free[0]-= >pool, > > > + (void *)= free, > > > + nb_free)= ; > > > + free[0] =3D m; > > > + nb_free =3D 1; > > > + } > > > + } > > > + } > > > + rte_mempool_put_bulk(free[0]->pool, (void **)free, nb= _free); > > > + } else { > > > + for (i =3D 1; i < n; i++) { > > > + m =3D rte_pktmbuf_prefree_seg(txep[i].mbuf); > > > + if (m !=3D NULL) > > > + rte_mempool_put(m->pool, m); > > > + } > > > + } > > > > Is it possible to take an extra step and convert to rte_pktmbuf_free_bu= lk? > > > Right now that's not possible without some more severe refactoring - and > even then I'm not convinced that it should be done. The code here is > working off the buffers in the shadow ring directly, where they should be > flattened out to avoid having mbuf chains. Therefore, we are freeing > segment by segment as each buffer has been transmitted. Nevermind, at least, this series removes many copies of this loop. Thanks Bruce. --=20 David Marchand