memory: don't zero the translation length for invalid translations
In spdk_mem_map_translate() we used to set the translation length to 0 if the provided memory region wasn't registered. This doesn't really have any use case and is now removed, which means that the translation length parameter will only be updated for those memory regions that were successfully translated. This serves as a minor optimization and code cleanup. Change-Id: I4c953f17e3f2181266bdcc71cf7e30c7244541f2 Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/438446 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
668c8c57be
commit
b45683c7a3
@ -1084,7 +1084,8 @@ int spdk_mem_map_clear_translation(struct spdk_mem_map *map, uint64_t vaddr, uin
|
||||
* \param map Memory map.
|
||||
* \param vaddr Virtual address.
|
||||
* \param size Contains the size of the memory region pointed to by vaddr.
|
||||
* Updated with the size of the memory region for which the translation is valid.
|
||||
* If vaddr is successfully translated, then this is updated with the size of
|
||||
* the memory region for which the translation is valid.
|
||||
*
|
||||
* \return the translation of vaddr stored in the map, or default_translation
|
||||
* as specified in spdk_mem_map_alloc() if vaddr is not present in the map.
|
||||
|
@ -591,16 +591,10 @@ spdk_mem_map_translate(const struct spdk_mem_map *map, uint64_t vaddr, uint64_t
|
||||
uint64_t idx_256tb;
|
||||
uint64_t idx_1gb;
|
||||
uint64_t vfn_2mb;
|
||||
uint64_t total_size = 0;
|
||||
uint64_t cur_size;
|
||||
uint64_t prev_translation;
|
||||
uint64_t orig_translation;
|
||||
|
||||
if (size != NULL) {
|
||||
total_size = *size;
|
||||
*size = 0;
|
||||
}
|
||||
|
||||
if (spdk_unlikely(vaddr & ~MASK_256TB)) {
|
||||
DEBUG_PRINT("invalid usermode virtual address %p\n", (void *)vaddr);
|
||||
return map->default_translation;
|
||||
@ -616,19 +610,18 @@ spdk_mem_map_translate(const struct spdk_mem_map *map, uint64_t vaddr, uint64_t
|
||||
}
|
||||
|
||||
cur_size = VALUE_2MB - _2MB_OFFSET(vaddr);
|
||||
if (size != NULL) {
|
||||
*size = cur_size;
|
||||
}
|
||||
|
||||
map_2mb = &map_1gb->map[idx_1gb];
|
||||
if (size == NULL || map->ops.are_contiguous == NULL ||
|
||||
map_2mb->translation_2mb == map->default_translation) {
|
||||
if (size != NULL) {
|
||||
*size = cur_size;
|
||||
}
|
||||
return map_2mb->translation_2mb;
|
||||
}
|
||||
|
||||
orig_translation = map_2mb->translation_2mb;
|
||||
prev_translation = orig_translation;
|
||||
while (cur_size < total_size) {
|
||||
while (cur_size < *size) {
|
||||
vfn_2mb++;
|
||||
idx_256tb = MAP_256TB_IDX(vfn_2mb);
|
||||
idx_1gb = MAP_1GB_IDX(vfn_2mb);
|
||||
|
Loading…
Reference in New Issue
Block a user