From: Stephen Hemminger <stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
To: "dev-VfR2kkLFssw@public.gmane.org" <dev-VfR2kkLFssw@public.gmane.org>
Subject: [PATCH] mempool: don't leak ring on failure
Date: Tue, 24 Jun 2014 08:49:48 -0700 [thread overview]
Message-ID: <20140624084948.6d4ab3cd@nehalam.linuxnetplumber.net> (raw)
If mempool can not be created because of insufficient memory
it returns an error but has already created a ring (and leaves it
behind). This prevents code from trying one mempool size and then
retrying with a smaller size if the bigger size fails.
Reordering to do ring creation after getting memory fixes
the problem.
Signed-off-by: Stephen Hemminger <stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
--- a/lib/librte_mempool/rte_mempool.c 2014-06-24 08:20:28.513771717 -0700
+++ b/lib/librte_mempool/rte_mempool.c 2014-06-24 08:20:28.513771717 -0700
@@ -473,15 +473,6 @@ rte_mempool_xmem_create(const char *name
rte_rwlock_write_lock(RTE_EAL_MEMPOOL_RWLOCK);
- /* allocate the ring that will be used to store objects */
- /* Ring functions will return appropriate errors if we are
- * running as a secondary process etc., so no checks made
- * in this function for that condition */
- rte_snprintf(rg_name, sizeof(rg_name), RTE_MEMPOOL_MZ_FORMAT, name);
- r = rte_ring_create(rg_name, rte_align32pow2(n+1), socket_id, rg_flags);
- if (r == NULL)
- goto exit;
-
/*
* reserve a memory zone for this mempool: private data is
* cache-aligned
@@ -542,6 +533,15 @@ rte_mempool_xmem_create(const char *name
startaddr = (void*)addr;
}
+ /* allocate the ring that will be used to store objects */
+ /* Ring functions will return appropriate errors if we are
+ * running as a secondary process etc., so no checks made
+ * in this function for that condition */
+ rte_snprintf(rg_name, sizeof(rg_name), RTE_MEMPOOL_MZ_FORMAT, name);
+ r = rte_ring_create(rg_name, rte_align32pow2(n+1), socket_id, rg_flags);
+ if (r == NULL)
+ goto exit;
+
/* init the mempool structure */
mp = startaddr;
memset(mp, 0, sizeof(*mp));
next reply other threads:[~2014-06-24 15:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-24 15:49 Stephen Hemminger [this message]
[not found] ` <20140624084948.6d4ab3cd-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2014-06-24 16:16 ` [PATCH] mempool: don't leak ring on failure Ananyev, Konstantin
[not found] ` <2601191342CEEE43887BDE71AB977258213340B1-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-06-24 17:40 ` Stephen Hemminger
[not found] ` <20140624104057.1fa81fd6-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2014-06-24 17:48 ` Ananyev, Konstantin
2014-06-24 17:41 ` Richardson, Bruce
2014-06-25 7:46 ` Olivier MATZ
[not found] ` <53AA7E64.5060707-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-06-25 8:01 ` Olivier MATZ
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140624084948.6d4ab3cd@nehalam.linuxnetplumber.net \
--to=stephen-otpzqlsittunbdjkjebofr2eb7je58tq@public.gmane.org \
--cc=dev-VfR2kkLFssw@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.