qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

exec: introduce qemu_xxhash{2,4,5,6,7}

Before moving them all to include/qemu/xxhash.h.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

authored by

Emilio G. Cota and committed by
Richard Henderson
c971d8fa e132fde2

+39 -18
+31 -10
include/exec/tb-hash-xx.h
··· 42 42 #define PRIME32_4 668265263U 43 43 #define PRIME32_5 374761393U 44 44 45 - #define TB_HASH_XX_SEED 1 45 + #define QEMU_XXHASH_SEED 1 46 46 47 47 /* 48 48 * xxhash32, customized for input variables that are not guaranteed to be 49 49 * contiguous in memory. 50 50 */ 51 51 static inline uint32_t 52 - tb_hash_func7(uint64_t a0, uint64_t b0, uint32_t e, uint32_t f, uint32_t g) 52 + qemu_xxhash7(uint64_t ab, uint64_t cd, uint32_t e, uint32_t f, uint32_t g) 53 53 { 54 - uint32_t v1 = TB_HASH_XX_SEED + PRIME32_1 + PRIME32_2; 55 - uint32_t v2 = TB_HASH_XX_SEED + PRIME32_2; 56 - uint32_t v3 = TB_HASH_XX_SEED + 0; 57 - uint32_t v4 = TB_HASH_XX_SEED - PRIME32_1; 58 - uint32_t a = a0 >> 32; 59 - uint32_t b = a0; 60 - uint32_t c = b0 >> 32; 61 - uint32_t d = b0; 54 + uint32_t v1 = QEMU_XXHASH_SEED + PRIME32_1 + PRIME32_2; 55 + uint32_t v2 = QEMU_XXHASH_SEED + PRIME32_2; 56 + uint32_t v3 = QEMU_XXHASH_SEED + 0; 57 + uint32_t v4 = QEMU_XXHASH_SEED - PRIME32_1; 58 + uint32_t a = ab >> 32; 59 + uint32_t b = ab; 60 + uint32_t c = cd >> 32; 61 + uint32_t d = cd; 62 62 uint32_t h32; 63 63 64 64 v1 += a * PRIME32_2; ··· 96 96 h32 ^= h32 >> 16; 97 97 98 98 return h32; 99 + } 100 + 101 + static inline uint32_t qemu_xxhash2(uint64_t ab) 102 + { 103 + return qemu_xxhash7(ab, 0, 0, 0, 0); 104 + } 105 + 106 + static inline uint32_t qemu_xxhash4(uint64_t ab, uint64_t cd) 107 + { 108 + return qemu_xxhash7(ab, cd, 0, 0, 0); 109 + } 110 + 111 + static inline uint32_t qemu_xxhash5(uint64_t ab, uint64_t cd, uint32_t e) 112 + { 113 + return qemu_xxhash7(ab, cd, e, 0, 0); 114 + } 115 + 116 + static inline uint32_t qemu_xxhash6(uint64_t ab, uint64_t cd, uint32_t e, 117 + uint32_t f) 118 + { 119 + return qemu_xxhash7(ab, cd, e, f, 0); 99 120 } 100 121 101 122 #endif /* EXEC_TB_HASH_XX_H */
+1 -1
include/exec/tb-hash.h
··· 61 61 uint32_t tb_hash_func(tb_page_addr_t phys_pc, target_ulong pc, uint32_t flags, 62 62 uint32_t cf_mask, uint32_t trace_vcpu_dstate) 63 63 { 64 - return tb_hash_func7(phys_pc, pc, flags, cf_mask, trace_vcpu_dstate); 64 + return qemu_xxhash7(phys_pc, pc, flags, cf_mask, trace_vcpu_dstate); 65 65 } 66 66 67 67 #endif
+1 -1
tests/qht-bench.c
··· 105 105 106 106 static uint32_t h(unsigned long v) 107 107 { 108 - return tb_hash_func7(v, 0, 0, 0, 0); 108 + return qemu_xxhash2(v); 109 109 } 110 110 111 111 static uint32_t hval(unsigned long v)
+6 -6
util/qsp.c
··· 135 135 * without it we still get a pretty unique hash. 136 136 */ 137 137 static inline 138 - uint32_t do_qsp_callsite_hash(const QSPCallSite *callsite, uint64_t a) 138 + uint32_t do_qsp_callsite_hash(const QSPCallSite *callsite, uint64_t ab) 139 139 { 140 - uint64_t b = (uint64_t)(uintptr_t)callsite->obj; 140 + uint64_t cd = (uint64_t)(uintptr_t)callsite->obj; 141 141 uint32_t e = callsite->line; 142 142 uint32_t f = callsite->type; 143 143 144 - return tb_hash_func7(a, b, e, f, 0); 144 + return qemu_xxhash6(ab, cd, e, f); 145 145 } 146 146 147 147 static inline ··· 169 169 static uint32_t qsp_entry_no_thread_obj_hash(const QSPEntry *entry) 170 170 { 171 171 const QSPCallSite *callsite = entry->callsite; 172 - uint64_t a = g_str_hash(callsite->file); 173 - uint64_t b = callsite->line; 172 + uint64_t ab = g_str_hash(callsite->file); 173 + uint64_t cd = callsite->line; 174 174 uint32_t e = callsite->type; 175 175 176 - return tb_hash_func7(a, b, e, 0, 0); 176 + return qemu_xxhash5(ab, cd, e); 177 177 } 178 178 179 179 static bool qsp_callsite_cmp(const void *ap, const void *bp)