From 01bed940fec4f97f516a11b55e05c1b1f2803af2 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Thu, 24 Aug 2017 14:43:34 -0700 Subject: [PATCH] env: Remove old translation reference counting Memory is now reference counted at a higher level. Change-Id: I61b24db7b92a129686775eddbff3a48814c842fe Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/375644 Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris Tested-by: SPDK Automated Test System --- lib/env_dpdk/memory.c | 29 +---------------------------- test/lib/env/memory/memory_ut.c | 7 +------ 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/lib/env_dpdk/memory.c b/lib/env_dpdk/memory.c index 9fdb97517..79a02d1af 100644 --- a/lib/env_dpdk/memory.c +++ b/lib/env_dpdk/memory.c @@ -57,9 +57,6 @@ #define MAP_128TB_IDX(vfn_2mb) ((vfn_2mb) >> (SHIFT_1GB - SHIFT_2MB)) #define MAP_1GB_IDX(vfn_2mb) ((vfn_2mb) & ((1ULL << (SHIFT_1GB - SHIFT_2MB + 1)) - 1)) -/* Max value for a 16-bit ref count. */ -#define VTOPHYS_MAX_REF_COUNT (0xFFFF) - /* Translation of a single 2MB page. */ struct map_2mb { uint64_t translation_2mb; @@ -71,7 +68,6 @@ struct map_2mb { */ struct map_1gb { struct map_2mb map[1ULL << (SHIFT_1GB - SHIFT_2MB + 1)]; - uint16_t ref_count[1ULL << (SHIFT_1GB - SHIFT_2MB + 1)]; }; /* Top-level map table indexed by bits [30..46] of the virtual address. @@ -378,7 +374,6 @@ spdk_mem_map_get_map_1gb(struct spdk_mem_map *map, uint64_t vfn_2mb) for (i = 0; i < SPDK_COUNTOF(map_1gb->map); i++) { map_1gb->map[i].translation_2mb = map->default_translation; } - memset(map_1gb->ref_count, 0, sizeof(map_1gb->ref_count)); map->map_128tb.map[idx_128tb] = map_1gb; } } @@ -402,7 +397,6 @@ spdk_mem_map_set_translation(struct spdk_mem_map *map, uint64_t vaddr, uint64_t struct map_1gb *map_1gb; uint64_t idx_1gb; struct map_2mb *map_2mb; - uint16_t *ref_count; /* For now, only 2 MB-aligned registrations are supported */ if ((uintptr_t)vaddr & ~MASK_128TB) { @@ -427,18 +421,8 @@ spdk_mem_map_set_translation(struct spdk_mem_map *map, uint64_t vaddr, uint64_t idx_1gb = MAP_1GB_IDX(vfn_2mb); map_2mb = &map_1gb->map[idx_1gb]; - ref_count = &map_1gb->ref_count[idx_1gb]; - - if (*ref_count == VTOPHYS_MAX_REF_COUNT) { - DEBUG_PRINT("ref count for %p already at %d\n", - (void *)vaddr, VTOPHYS_MAX_REF_COUNT); - return -EBUSY; - } - map_2mb->translation_2mb = translation; - (*ref_count)++; - size -= VALUE_2MB; vfn_2mb++; } @@ -453,7 +437,6 @@ spdk_mem_map_clear_translation(struct spdk_mem_map *map, uint64_t vaddr, uint64_ struct map_1gb *map_1gb; uint64_t idx_1gb; struct map_2mb *map_2mb; - uint16_t *ref_count; /* For now, only 2 MB-aligned registrations are supported */ if ((uintptr_t)vaddr & ~MASK_128TB) { @@ -478,17 +461,7 @@ spdk_mem_map_clear_translation(struct spdk_mem_map *map, uint64_t vaddr, uint64_ idx_1gb = MAP_1GB_IDX(vfn_2mb); map_2mb = &map_1gb->map[idx_1gb]; - ref_count = &map_1gb->ref_count[idx_1gb]; - - if (*ref_count == 0) { - DEBUG_PRINT("vaddr %p not registered\n", (void *)vaddr); - return -EINVAL; - } - - (*ref_count)--; - if (*ref_count == 0) { - map_2mb->translation_2mb = map->default_translation; - } + map_2mb->translation_2mb = map->default_translation; size -= VALUE_2MB; vfn_2mb++; diff --git a/test/lib/env/memory/memory_ut.c b/test/lib/env/memory/memory_ut.c index 30a667da3..a96c327f7 100644 --- a/test/lib/env/memory/memory_ut.c +++ b/test/lib/env/memory/memory_ut.c @@ -134,12 +134,7 @@ test_mem_map_translation(void) rc = spdk_mem_map_set_translation(map, 0, 3 * VALUE_2MB, 0); CU_ASSERT(rc == 0); - /* - * Clear translation for the middle page of the larger region. - * It was set twice, so clear it twice. - */ - rc = spdk_mem_map_clear_translation(map, VALUE_2MB, VALUE_2MB); - CU_ASSERT(rc == 0); + /* Clear translation for the middle page of the larger region. */ rc = spdk_mem_map_clear_translation(map, VALUE_2MB, VALUE_2MB); CU_ASSERT(rc == 0);