malloc: notify primary process about hotplug in secondary
PATCH 1/1 malloc: notify primary process about hotplug in secondary
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.
--- lib/librte_eal/common/malloc_mp.c | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/librte_eal/common/malloc_mp.c +8 -0
@@ -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);
Signature · 1 line
2.17.2
Quoted 15 lines · Seth Howell
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.
Quoted 5 lines
After this patch, a primary process fires memory event callbacks before secondary processes start their synchronizations - both for hotplug and hotremove.
Change-Id: I60de33913f58bc2454069c3844826c92cb043fff
This is internal tag, please don't include it in the patch. Also, misses Fixes: tag, and Cc: [email protected] (since this bug goes back to 18.05).
Quoted 3 lines
Signed-off-by Seth Howell <[email protected]>Signed-off-by Darek Stojaczyk <[email protected]>---
Otherwise,
Signature · 2 lines
Thanks, Anatoly
PATCH 1/1 malloc: notify primary process about hotplug in secondary
In reply to Seth HowellWhen 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.
--- lib/librte_eal/common/malloc_mp.c | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/librte_eal/common/malloc_mp.c +8 -0
@@ -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);
Signature · 1 line
2.17.2
PATCH v2 1/1 malloc: notify primary process about hotplug in secondary
In reply to Seth HowellWhen 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.
--- lib/librte_eal/common/malloc_mp.c | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/librte_eal/common/malloc_mp.c +8 -0
@@ -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);
Signature · 1 line
2.17.2
Quoted 19 lines · Seth Howell
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.
Quoted 5 lines
Fixes 07dcbfe0101f ("malloc: support multiprocess memory hotplug")Signed-off-by Seth Howell <[email protected]>Signed-off-by Darek Stojaczyk <[email protected]>---
Lost my review tag...
Signature · 2 lines
Thanks, Anatoly
Thomas Monjalon
Applied10/12/2018 11:49, Burakov, Anatoly:
Quoted 22 lines · Seth Howell
Quoted 21 lines
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")
Quoted 7 lines
Quoted 3 lines
Signed-off-by Seth Howell <[email protected]>Signed-off-by Darek Stojaczyk <[email protected]>---
Lost my review tag...
Reviewed-by Anatoly Burakov <[email protected]>
+Cc: [email protected]
Applied, thanks