From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 81B01CE7 for ; Fri, 2 Oct 2015 16:28:00 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 02 Oct 2015 07:27:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,623,1437462000"; d="scan'208";a="817978506" Received: from irsmsx107.ger.corp.intel.com ([163.33.3.99]) by orsmga002.jf.intel.com with ESMTP; 02 Oct 2015 07:27:58 -0700 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.216]) by IRSMSX107.ger.corp.intel.com ([169.254.10.252]) with mapi id 14.03.0248.002; Fri, 2 Oct 2015 15:27:57 +0100 From: "De Lara Guarch, Pablo" To: "Richardson, Bruce" Thread-Topic: [dpdk-dev] [PATCH v3] ring: add function to free a ring Thread-Index: AQHQ/RroOPupi6Hto0i8LVUauDNnIZ5YLQcAgAAVngA= Date: Fri, 2 Oct 2015 14:27:57 +0000 Message-ID: References: <1442930122-119572-1-git-send-email-pablo.de.lara.guarch@intel.com> <1443794485-215546-1-git-send-email-pablo.de.lara.guarch@intel.com> <20151002140950.GB15136@bricha3-MOBL3> In-Reply-To: <20151002140950.GB15136@bricha3-MOBL3> Accept-Language: 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 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v3] ring: add function to free a ring X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Oct 2015 14:28:01 -0000 Hi Bruce, > -----Original Message----- > From: Richardson, Bruce > Sent: Friday, October 02, 2015 3:10 PM > To: De Lara Guarch, Pablo > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH v3] ring: add function to free a ring >=20 > On Fri, Oct 02, 2015 at 03:01:25PM +0100, Pablo de Lara wrote: > > From: "Pablo de Lara" > > > > When creating a ring, a memzone is created to allocate it in memory, > > but the ring could not be freed, as memzones could not be. > > > > Since memzones can be freed now, then rings can be as well, > > taking into account if they were initialized using pre-allocated memory > > (in which case, memory should be freed externally) or using > rte_memzone_reserve > > (with rte_ring_create), freeing the memory with rte_memzone_free. > > > > Signed-off-by: Pablo de Lara > > --- > > Changes in v3: > > - Simplify patch using stored memzone address in ring structure > > - Change copyright date >=20 > I think you need to call out that this patch depends upon > http://dpdk.org/dev/patchwork/patch/7308/ I did below, probably I should have included the patch ID :S >=20 > > > > Changes in v2: > > - Include note in release notes > > - Add error log when ring cannot be freed > > > > This patch depends on patch "rte_ring: store memzone pointer inside rin= g" > > > > doc/guides/rel_notes/release_2_2.rst | 4 +++ > > lib/librte_ring/rte_ring.c | 47 > +++++++++++++++++++++++++++++++++++- > > lib/librte_ring/rte_ring.h | 7 ++++++ > > lib/librte_ring/rte_ring_version.map | 7 ++++++ > > 4 files changed, 64 insertions(+), 1 deletion(-) > > > > diff --git a/doc/guides/rel_notes/release_2_2.rst > b/doc/guides/rel_notes/release_2_2.rst > > index 5687676..24937ac 100644 > > --- a/doc/guides/rel_notes/release_2_2.rst > > +++ b/doc/guides/rel_notes/release_2_2.rst > > @@ -4,6 +4,10 @@ DPDK Release 2.2 > > New Features > > ------------ > > > > +* **Enabled freeing of rte_ring.** > > + > > + New function rte_ring_free() allows the user to free a ring > > + if it was created with rte_ring_create(). > > > > Resolved Issues > > --------------- > > diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c > > index 4e78e14..d80faf3 100644 > > --- a/lib/librte_ring/rte_ring.c > > +++ b/lib/librte_ring/rte_ring.c > > @@ -1,7 +1,7 @@ > > /*- > > * BSD LICENSE > > * > > - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. > > + * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. > > * All rights reserved. > > * > > * Redistribution and use in source and binary forms, with or withou= t > > @@ -209,6 +209,51 @@ rte_ring_create(const char *name, unsigned > count, int socket_id, > > return r; > > } > > > > +/* free the ring */ > > +void > > +rte_ring_free(struct rte_ring *r) > > +{ > > + struct rte_ring_list *ring_list =3D NULL; > > + struct rte_tailq_entry *te; > > + > > + if (r =3D=3D NULL) > > + return; > > + > > + /* > > + * Ring was not created with rte_ring_create, > > + * therefore, there is no memzone to free. > > + */ > > + if (r->memzone =3D=3D NULL) { > > + RTE_LOG(ERR, RING, "Cannot free ring (not created with > rte_ring_create()"); > > + return; > > + } > > + > > + if (rte_memzone_free(r->memzone) !=3D 0) { > > + RTE_LOG(ERR, RING, "Cannot free memory\n"); > > + return; > > + } > > + > > + ring_list =3D RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list); > > + rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK); > > + > > + /* find out tailq entry */ > > + TAILQ_FOREACH(te, ring_list, next) { > > + if (te->data =3D=3D (void *) r) > > + break; > > + } > > + > > + if (te =3D=3D NULL) { > > + rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); > > + return; > > + } > > + > > + TAILQ_REMOVE(ring_list, te, next); > > + > > + rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); > > + > > + rte_free(te); > > +} > > + > > /* > > * change the high water mark. If *count* is 0, water marking is > > * disabled > > diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h > > index df45f3f..fb5a626 100644 > > --- a/lib/librte_ring/rte_ring.h > > +++ b/lib/librte_ring/rte_ring.h > > @@ -304,6 +304,13 @@ int rte_ring_init(struct rte_ring *r, const char > *name, unsigned count, > > */ > > struct rte_ring *rte_ring_create(const char *name, unsigned count, > > int socket_id, unsigned flags); > > +/** > > + * De-allocate all memory used by the ring. > > + * > > + * @param r > > + * Ring to free > > + */ > > +void rte_ring_free(struct rte_ring *r); > > > > /** > > * Change the high water mark. > > diff --git a/lib/librte_ring/rte_ring_version.map > b/lib/librte_ring/rte_ring_version.map > > index 982fdd1..5474b98 100644 > > --- a/lib/librte_ring/rte_ring_version.map > > +++ b/lib/librte_ring/rte_ring_version.map > > @@ -11,3 +11,10 @@ DPDK_2.0 { > > > > local: *; > > }; > > + > > +DPDK_2.2 { > > + global: > > + > > + rte_ring_free; > > + > > +} DPDK_2.0; > > -- > > 2.4.3 > >