env/vtophys: mark exceptional cases as unlikely
Make sure the compiler arranges the fast path as the fallthrough case by annotating the checks in spdk_vtophys(). Change-Id: If0fc3149297131894b5c7a94bff31bf8ee40326e Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
f314f0ca4f
commit
b08738fe92
@ -44,6 +44,7 @@
|
||||
#include <rte_eal_memconfig.h>
|
||||
|
||||
#include "spdk/assert.h"
|
||||
#include "spdk/likely.h"
|
||||
|
||||
/* x86-64 userspace virtual addresses use only the low 47 bits [0..46],
|
||||
* which is enough to cover 128 TB.
|
||||
@ -329,7 +330,7 @@ spdk_vtophys(void *buf)
|
||||
uint64_t vaddr, vfn_2mb, paddr_2mb;
|
||||
|
||||
vaddr = (uint64_t)buf;
|
||||
if (vaddr & ~MASK_128TB) {
|
||||
if (spdk_unlikely(vaddr & ~MASK_128TB)) {
|
||||
printf("invalid usermode virtual address %p\n", buf);
|
||||
return SPDK_VTOPHYS_ERROR;
|
||||
}
|
||||
@ -339,7 +340,7 @@ spdk_vtophys(void *buf)
|
||||
idx_1gb = MAP_1GB_IDX(vfn_2mb);
|
||||
|
||||
map_1gb = vtophys_map_128tb.map[idx_128tb];
|
||||
if (!map_1gb) {
|
||||
if (spdk_unlikely(!map_1gb)) {
|
||||
return SPDK_VTOPHYS_ERROR;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user