From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id D29511AEE8 for ; Wed, 15 Nov 2017 12:13:47 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id 9so2194212wme.4 for ; Wed, 15 Nov 2017 03:13:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=NJDG1Z0ewSVmpYjCp48cMKSILg8yf/uqcilRsjqCAYQ=; b=RssNaT/RQRAmkDc90R5CTQgpQRyuW3pDiHFvsYLL+9ouG4FTHzpz94Ll35FCkuVZvD dfl6WTuJmdsjedMExIxwQ+8BuK8c4Dx5qhY2ahS3VpSQr1isxdPhGjHMf/A1Ge2w+G7A bqcyI7liTEDMxnMHZXdSXvYtkXGO1lgL0fefQqvzy3RUR6mMHFThxa46XChSIVtoh3FG izlvtbp0nwBSu9WIqAk59r7oCn+HiAVsCdpQm0wgFK/PLMDA82LM8w/9DxL1OeqcXkes bkq76o4okuRpAFtYBOQ5FtFQ6smT7oIKL6MvVIpn+qjzGhRYVBVhkmyOMPqORCCIF/to qC+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=NJDG1Z0ewSVmpYjCp48cMKSILg8yf/uqcilRsjqCAYQ=; b=ACnc0k/uKtj2/kse1jgYWFb7b8xqP4TOaBDd5o/SKn34Ze68cxPl9AwuVbaboXCa63 zr0lR43Uig5O+bOKkE23UXAvQrv32YTjX1e3gg3tAZiQODkFSOTOa/bSPNgXBqpblY20 KGe+Oc2NOhLFXGSW/+ueDA7FGTp9r96Q7845f3MyDw15ha6MP6ObzKsd2aB1EP9b/Gs5 Dnhr+69qeQj8eFqdwJLnUi4B+GJOIlAYW3KbTCWvqV2x+s33nBOomafsIsmqinmc3GKU /16BCKCFHTyl/A15Ih1vyuKIpt/6IFru1UvpM0kHZ7CNFOVFFty+JLu9SIXTWtOYDYJy PPKA== X-Gm-Message-State: AJaThX5ZKSmY4zdCjc8tMilx4ypxtDCSVxNam1ojBSkbi6H/TtqYwU/B 4vs7JO3AxbIpQgsOhFPUYA0= X-Google-Smtp-Source: AGs4zMZUHOVa48nlm7KN1a4p4BywESsJB+FQgwZXqM3feCLD8qwtBECVUYEFn5jjW9mUFvErigHSqQ== X-Received: by 10.80.244.141 with SMTP id s13mr14971480edm.222.1510744427539; Wed, 15 Nov 2017 03:13:47 -0800 (PST) Received: from [10.61.0.167] (bba193485.alshamil.net.ae. [217.165.96.191]) by smtp.gmail.com with ESMTPSA id s26sm17706980eds.68.2017.11.15.03.13.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Nov 2017 03:13:46 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) From: Ilya Matveychikov In-Reply-To: <20171115091413.27119-1-hhaim@cisco.com> Date: Wed, 15 Nov 2017 15:13:45 +0400 Cc: dev@dpdk.org Content-Transfer-Encoding: quoted-printable Message-Id: <1D98684F-B8A9-4037-8534-0D4E3A1FD34C@gmail.com> References: <20171115091413.27119-1-hhaim@cisco.com> To: Hanoh Haim X-Mailer: Apple Mail (2.3273) Subject: Re: [dpdk-dev] [PATCH v3] mbuf: cleanup rte_pktmbuf_lastseg(), fix atomic usage X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Nov 2017 11:13:48 -0000 > On Nov 15, 2017, at 1:14 PM, Hanoh Haim wrote: >=20 > Signed-off-by: Hanoh Haim > --- > lib/librte_mbuf/rte_mbuf.h | 27 +++++++++++++-------------- > 1 file changed, 13 insertions(+), 14 deletions(-) >=20 > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > index 7e326bb..ab110f8 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -1159,6 +1159,15 @@ static inline void rte_pktmbuf_reset(struct = rte_mbuf *m) > __rte_mbuf_sanity_check(m, 1); > } >=20 > + > +static __rte_always_inline void rte_pktmbuf_reset_before_free(struct = rte_mbuf *m) > +{ > + if (m->next !=3D NULL) { > + m->next =3D NULL; > + m->nb_segs =3D 1; > + } > +} > + Probably it will be more clean to add something = __te_pktmbuf_reset_nb_segs() without check for (m->next !=3D NULL) and use it everywhere in mbuf=E2=80=99s = the code, not only in rte_pktmbuf_prefree_seg() function. And I think it will be better to = have separate patch for that. > /** > * Allocate a new mbuf from a mempool. > * > @@ -1323,8 +1332,7 @@ static inline void rte_pktmbuf_detach(struct = rte_mbuf *m) > m->ol_flags =3D 0; >=20 > if (rte_mbuf_refcnt_update(md, -1) =3D=3D 0) { > - md->next =3D NULL; > - md->nb_segs =3D 1; Using rte_pktmbuf_reset_before_free() here adds unnecessary check for = m->next in that path. > + rte_pktmbuf_reset_before_free(md); > rte_mbuf_refcnt_set(md, 1); > rte_mbuf_raw_free(md); > } > @@ -1354,25 +1362,16 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m) > if (RTE_MBUF_INDIRECT(m)) > rte_pktmbuf_detach(m); >=20 > - if (m->next !=3D NULL) { > - m->next =3D NULL; > - m->nb_segs =3D 1; > - } > - > + rte_pktmbuf_reset_before_free(m); > return m; >=20 > - } else if (rte_atomic16_add_return(&m->refcnt_atomic, -1) =3D=3D= 0) { > - > + } else if (rte_mbuf_refcnt_update(m, -1) =3D=3D 0) { >=20 > if (RTE_MBUF_INDIRECT(m)) > rte_pktmbuf_detach(m); >=20 > - if (m->next !=3D NULL) { > - m->next =3D NULL; > - m->nb_segs =3D 1; > - } > + rte_pktmbuf_reset_before_free(m); > rte_mbuf_refcnt_set(m, 1); > - > return m; > } > return NULL; > --=20 > 2.9.3 >=20