From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id A566469FC for ; Wed, 11 Jan 2017 11:39:23 +0100 (CET) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP; 11 Jan 2017 02:39:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,345,1477983600"; d="scan'208";a="47773018" Received: from irsmsx152.ger.corp.intel.com ([163.33.192.66]) by orsmga004.jf.intel.com with ESMTP; 11 Jan 2017 02:39:21 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.38]) by IRSMSX152.ger.corp.intel.com ([169.254.6.191]) with mapi id 14.03.0248.002; Wed, 11 Jan 2017 10:39:20 +0000 From: "Ananyev, Konstantin" To: Sergey Vyazmitinov , "olivier.matz@6wind.com" CC: "Yigit, Ferruh" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] kni: use bulk functions to allocate and free mbufs Thread-Index: AQHSa7pPEQBwXRRYgEaYoel1utU/h6EzFUKA Date: Wed, 11 Jan 2017 10:39:20 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772583F103987@irsmsx105.ger.corp.intel.com> References: <1483048216-2936-1-git-send-email-s.vyazmitinov@brain4net.com> In-Reply-To: <1483048216-2936-1-git-send-email-s.vyazmitinov@brain4net.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] kni: use bulk functions to allocate and free mbufs 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, 11 Jan 2017 10:39:24 -0000 Hi Sergey, ... > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > index 4476d75..707c300 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -1261,6 +1261,38 @@ static inline void rte_pktmbuf_free(struct rte_mbu= f *m) > } >=20 > /** > + * Free n packets mbuf back into its original mempool. > + * > + * Free each mbuf, and all its segments in case of chained buffers. Each > + * segment is added back into its original mempool. > + * > + * @param mp > + * The packets mempool. > + * @param mbufs > + * The packets mbufs array to be freed. > + * @param n > + * Number of packets. > + */ > +static inline void rte_pktmbuf_free_bulk(struct rte_mempool *mp, > + struct rte_mbuf **mbufs, unsigned n) > +{ > + struct rte_mbuf *mbuf, *m_next; > + unsigned i; > + for (i =3D 0; i < n; ++i) { > + mbuf =3D mbufs[i]; > + __rte_mbuf_sanity_check(mbuf, 1); > + > + mbuf =3D mbuf->next; > + while (mbuf !=3D NULL) { > + m_next =3D mbuf->next; > + rte_pktmbuf_free_seg(mbuf); > + mbuf =3D m_next; > + } I think you forgot to call __rte_pktmbuf_prefree_seg(mbufs[i]); somewhere h= ere. Konstantin > + } > + rte_mempool_put_bulk(mp, (void * const *)mbufs, n); > +} > + > +/** > * Creates a "clone" of the given packet mbuf. > * > * Walks through all segments of the given packet mbuf, and for each of = them: > diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_me= mpool.h > index d315d42..e612a0a 100644 > --- a/lib/librte_mempool/rte_mempool.h > +++ b/lib/librte_mempool/rte_mempool.h > @@ -1497,6 +1497,12 @@ rte_mempool_get(struct rte_mempool *mp, void **obj= _p) > return rte_mempool_get_bulk(mp, obj_p, 1); > } >=20 > +static inline int __attribute__((always_inline)) > +rte_mempool_get_n(struct rte_mempool *mp, void **obj_p, int n) > +{ > + return rte_mempool_get_bulk(mp, obj_p, n); > +} > + > /** > * Return the number of entries in the mempool. > * > -- > 2.7.4