Revert "env: Use rte_malloc in spdk_mem_register code path when possible"
This reverts commit 6d6052ac96
.
This approach is no longer necessary given the patch immediately
preceeding this one.
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Change-Id: I5aab14346fa5a14dbf33c94ffcf88b045cdb4999
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2512
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
cf450c0d7c
commit
76aed8e4ff
@ -36,7 +36,6 @@
|
|||||||
#include "env_internal.h"
|
#include "env_internal.h"
|
||||||
|
|
||||||
#include <rte_config.h>
|
#include <rte_config.h>
|
||||||
#include <rte_malloc.h>
|
|
||||||
#include <rte_memory.h>
|
#include <rte_memory.h>
|
||||||
#include <rte_eal_memconfig.h>
|
#include <rte_eal_memconfig.h>
|
||||||
|
|
||||||
@ -344,11 +343,7 @@ spdk_mem_map_free(struct spdk_mem_map **pmap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < sizeof(map->map_256tb.map) / sizeof(map->map_256tb.map[0]); i++) {
|
for (i = 0; i < sizeof(map->map_256tb.map) / sizeof(map->map_256tb.map[0]); i++) {
|
||||||
if (g_legacy_mem) {
|
free(map->map_256tb.map[i]);
|
||||||
rte_free(map->map_256tb.map[i]);
|
|
||||||
} else {
|
|
||||||
free(map->map_256tb.map[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_destroy(&map->mutex);
|
pthread_mutex_destroy(&map->mutex);
|
||||||
@ -579,23 +574,7 @@ spdk_mem_map_get_map_1gb(struct spdk_mem_map *map, uint64_t vfn_2mb)
|
|||||||
/* Recheck to make sure nobody else got the mutex first. */
|
/* Recheck to make sure nobody else got the mutex first. */
|
||||||
map_1gb = map->map_256tb.map[idx_256tb];
|
map_1gb = map->map_256tb.map[idx_256tb];
|
||||||
if (!map_1gb) {
|
if (!map_1gb) {
|
||||||
/* Some of the existing apps use TCMalloc hugepage
|
map_1gb = malloc(sizeof(struct map_1gb));
|
||||||
* allocator and register this tcmalloc allocated
|
|
||||||
* hugepage memory with SPDK in the mmap hook. Since
|
|
||||||
* this function is called in the spdk_mem_register
|
|
||||||
* code path we can't do a malloc here otherwise that
|
|
||||||
* would cause a livelock. So we use the dpdk provided
|
|
||||||
* allocator instead, which avoids this cyclic
|
|
||||||
* dependency. Note this is only guaranteed to work when
|
|
||||||
* DPDK dynamic memory allocation is disabled (--legacy-mem),
|
|
||||||
* which then is a requirement for anyone using TCMalloc in
|
|
||||||
* this way.
|
|
||||||
*/
|
|
||||||
if (g_legacy_mem) {
|
|
||||||
map_1gb = rte_malloc(NULL, sizeof(struct map_1gb), 0);
|
|
||||||
} else {
|
|
||||||
map_1gb = malloc(sizeof(struct map_1gb));
|
|
||||||
}
|
|
||||||
if (map_1gb) {
|
if (map_1gb) {
|
||||||
/* initialize all entries to default translation */
|
/* initialize all entries to default translation */
|
||||||
for (i = 0; i < SPDK_COUNTOF(map_1gb->map); i++) {
|
for (i = 0; i < SPDK_COUNTOF(map_1gb->map); i++) {
|
||||||
|
14
test/env/memory/memory_ut.c
vendored
14
test/env/memory/memory_ut.c
vendored
@ -52,20 +52,6 @@ DEFINE_STUB(rte_mem_event_callback_register, int,
|
|||||||
(const char *name, rte_mem_event_callback_t clb, void *arg), 0);
|
(const char *name, rte_mem_event_callback_t clb, void *arg), 0);
|
||||||
DEFINE_STUB(rte_mem_virt2iova, rte_iova_t, (const void *virtaddr), 0);
|
DEFINE_STUB(rte_mem_virt2iova, rte_iova_t, (const void *virtaddr), 0);
|
||||||
|
|
||||||
void *
|
|
||||||
rte_malloc(const char *type, size_t size, unsigned align)
|
|
||||||
{
|
|
||||||
CU_ASSERT(type == NULL);
|
|
||||||
CU_ASSERT(align == 0);
|
|
||||||
return malloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
rte_free(void *ptr)
|
|
||||||
{
|
|
||||||
free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_mem_map_notify(void *cb_ctx, struct spdk_mem_map *map,
|
test_mem_map_notify(void *cb_ctx, struct spdk_mem_map *map,
|
||||||
enum spdk_mem_map_notify_action action,
|
enum spdk_mem_map_notify_action action,
|
||||||
|
Loading…
Reference in New Issue
Block a user