]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/spdk/dpdk/lib/librte_eal/common/malloc_mp.c
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / dpdk / lib / librte_eal / common / malloc_mp.c
index 931c14bc5c5a6c73eb0ce54fb904250d93d42c36..b470565e0d81b6990ab8ceffb3b0bb6e5d81de5c 100644 (file)
@@ -194,13 +194,11 @@ handle_alloc_request(const struct malloc_mp_req *m,
 
        /* we can't know in advance how many pages we'll need, so we malloc */
        ms = malloc(sizeof(*ms) * n_segs);
-
-       memset(ms, 0, sizeof(*ms) * n_segs);
-
        if (ms == NULL) {
                RTE_LOG(ERR, EAL, "Couldn't allocate memory for request state\n");
                goto fail;
        }
+       memset(ms, 0, sizeof(*ms) * n_segs);
 
        elem = alloc_pages_on_heap(heap, ar->page_sz, ar->elt_size, ar->socket,
                        ar->flags, ar->align, ar->bound, ar->contig, ms,
@@ -211,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.
@@ -260,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 {
@@ -438,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);
 
@@ -495,7 +501,7 @@ handle_rollback_response(const struct rte_mp_msg *request,
        /* lock the request */
        pthread_mutex_lock(&mp_request_list.lock);
 
-       memset(&msg, 0, sizeof(0));
+       memset(&msg, 0, sizeof(msg));
 
        entry = find_request_by_id(mpreq->id);
        if (entry == NULL) {