DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/2] mem: fix initialization check for malloc heap
Date: Tue, 15 Apr 2014 15:50:59 +0200	[thread overview]
Message-ID: <1397569859-14460-2-git-send-email-david.marchand@6wind.com> (raw)
In-Reply-To: <1397569859-14460-1-git-send-email-david.marchand@6wind.com>

From: Didier Pallard <didier.pallard@6wind.com>

initialised field must be checked against INITIALISED value before
allowing malloc to occur, else some core may pass the test and start
malloc while heap is in INITIALISING state and is not fully initialized.

Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
---
 lib/librte_malloc/malloc_heap.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_malloc/malloc_heap.c b/lib/librte_malloc/malloc_heap.c
index 64668cb..eed8a63 100644
--- a/lib/librte_malloc/malloc_heap.c
+++ b/lib/librte_malloc/malloc_heap.c
@@ -197,7 +197,7 @@ void *
 malloc_heap_alloc(struct malloc_heap *heap,
 		const char *type __attribute__((unused)), size_t size, unsigned align)
 {
-	if (!heap->initialised)
+	if (heap->initialised != INITIALISED)
 		malloc_heap_init(heap);
 
 	size = CACHE_LINE_ROUNDUP(size);
@@ -227,7 +227,7 @@ int
 malloc_heap_get_stats(const struct malloc_heap *heap,
 		struct rte_malloc_socket_stats *socket_stats)
 {
-	if (!heap->initialised)
+	if (heap->initialised != INITIALISED)
 		return -1;
 
 	struct malloc_elem *elem = heap->free_head;
-- 
1.7.10.4

  reply	other threads:[~2014-04-15 13:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-15 13:50 [dpdk-dev] [PATCH 1/2] mem: add write memory barrier before changing heap state David Marchand
2014-04-15 13:50 ` David Marchand [this message]
2014-04-15 14:08 ` Richardson, Bruce
2014-04-16  8:55   ` didier.pallard
2014-04-15 14:44 ` Neil Horman
2014-04-18 12:56   ` [dpdk-dev] [PATCH 0/2] rework heap initialisation David Marchand
2014-04-18 12:56     ` [dpdk-dev] [PATCH 1/2] malloc: get rid of numa_socket field David Marchand
2014-04-18 13:08       ` Neil Horman
2014-04-30  9:46         ` Thomas Monjalon
2014-04-18 12:56     ` [dpdk-dev] [PATCH 2/2] malloc: simplify heap initialisation David Marchand
2014-04-18 13:09       ` Neil Horman
2014-04-30  9:47         ` Thomas Monjalon

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=1397569859-14460-2-git-send-email-david.marchand@6wind.com \
    --to=david.marchand@6wind.com \
    --cc=dev@dpdk.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).