DPDK patches and discussions
 help / color / mirror / Atom feed
From: Seth Howell <seth.howell@intel.com>
To: anatoly.burakov@intel.com
Cc: dev@dpdk.org, stable@dpdk.org,
	Seth Howell <seth.howell@intel.com>,
	Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Subject: [dpdk-dev] [PATCH v2] malloc: notify primary process about hotplug in secondary
Date: Fri,  7 Dec 2018 13:10:42 -0700	[thread overview]
Message-ID: <20181207201042.372870-1-seth.howell@intel.com> (raw)
In-Reply-To: <20181204170610.250124-1-seth.howell@intel.com>

When secondary process hotplugs memory, it sends a request
to primary, which then performs the real mmap() and sends
sync requests to all secondary processes. Upon receiving
such sync request, each secondary process will notify the
upper layers of hotplugged memory (and will call all
locally registered event callbacks).

In the end we'll end up with memory event callbacks fired
in all the processes except the primary, which is a bug.

This gets critical if memory is hotplugged while a VFIO
device is attached, as the VFIO memory registration -
which is done from a memory event callback present in the
primary process only - is never called.

After this patch, a primary process fires memory event
callbacks before secondary processes start their
synchronizations - both for hotplug and hotremove.

Fixes: 07dcbfe0101f ("malloc: support multiprocess memory hotplug")

Signed-off-by: Seth Howell <seth.howell@intel.com>
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
---
 lib/librte_eal/common/malloc_mp.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/librte_eal/common/malloc_mp.c b/lib/librte_eal/common/malloc_mp.c
index 5f2d4e0be..f3a13353b 100644
--- a/lib/librte_eal/common/malloc_mp.c
+++ b/lib/librte_eal/common/malloc_mp.c
@@ -209,6 +209,8 @@ handle_alloc_request(const struct malloc_mp_req *m,
 
 	map_addr = ms[0]->addr;
 
+	eal_memalloc_mem_event_notify(RTE_MEM_EVENT_ALLOC, map_addr, alloc_sz);
+
 	/* we have succeeded in allocating memory, but we still need to sync
 	 * with other processes. however, since DPDK IPC is single-threaded, we
 	 * send an asynchronous request and exit this callback.
@@ -258,6 +260,9 @@ handle_request(const struct rte_mp_msg *msg, const void *peer __rte_unused)
 	if (m->t == REQ_TYPE_ALLOC) {
 		ret = handle_alloc_request(m, entry);
 	} else if (m->t == REQ_TYPE_FREE) {
+		eal_memalloc_mem_event_notify(RTE_MEM_EVENT_FREE,
+				m->free_req.addr, m->free_req.len);
+
 		ret = malloc_heap_free_pages(m->free_req.addr,
 				m->free_req.len);
 	} else {
@@ -436,6 +441,9 @@ handle_sync_response(const struct rte_mp_msg *request,
 		memset(&rb_msg, 0, sizeof(rb_msg));
 
 		/* we've failed to sync, so do a rollback */
+		eal_memalloc_mem_event_notify(RTE_MEM_EVENT_FREE,
+				state->map_addr, state->map_len);
+
 		rollback_expand_heap(state->ms, state->ms_len, state->elem,
 				state->map_addr, state->map_len);
 
-- 
2.17.2

  parent reply	other threads:[~2018-12-07 20:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04 17:06 [dpdk-dev] [PATCH] " Seth Howell
2018-12-05 10:36 ` Burakov, Anatoly
2018-12-07 20:06 ` Seth Howell
2018-12-07 20:10 ` Seth Howell [this message]
2018-12-10 10:49   ` [dpdk-dev] [PATCH v2] " Burakov, Anatoly
2018-12-20 14:26     ` [dpdk-dev] [dpdk-stable] " 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=20181207201042.372870-1-seth.howell@intel.com \
    --to=seth.howell@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dariusz.stojaczyk@intel.com \
    --cc=dev@dpdk.org \
    --cc=stable@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).