Andrei Gudkov <gudkov.and...@huawei.com> wrote: > In sampling mode, a new metric is collected and reported: > number of pages entirely filled with zeroes.
Good idea. > @@ -331,11 +336,20 @@ static uint32_t compute_page_hash(void *ptr) > v2 = QEMU_XXHASH_SEED + XXH_PRIME64_2; > v3 = QEMU_XXHASH_SEED + 0; > v4 = QEMU_XXHASH_SEED - XXH_PRIME64_1; > - for (i = 0; i < TARGET_PAGE_SIZE / 8; i += 4) { > - v1 = XXH64_round(v1, p[i + 0]); > - v2 = XXH64_round(v2, p[i + 1]); > - v3 = XXH64_round(v3, p[i + 2]); > - v4 = XXH64_round(v4, p[i + 3]); > + if (ptr) { It smells like a hack, that is only going to be used once in the program. But the only other option that I can think is repeating the function for the zero case. No way to win here. > + for (i = 0; i < TARGET_PAGE_SIZE / 8; i += 4) { > + v1 = XXH64_round(v1, p[i + 0]); > + v2 = XXH64_round(v2, p[i + 1]); > + v3 = XXH64_round(v3, p[i + 2]); > + v4 = XXH64_round(v4, p[i + 3]); > + } > + } else { > + for (i = 0; i < TARGET_PAGE_SIZE / 8; i += 4) { > + v1 = XXH64_round(v1, 0); > + v2 = XXH64_round(v2, 0); > + v3 = XXH64_round(v3, 0); > + v4 = XXH64_round(v4, 0); > + } > } > res = XXH64_mergerounds(v1, v2, v3, v4); > res += TARGET_PAGE_SIZE; > @@ -343,6 +357,17 @@ static uint32_t compute_page_hash(void *ptr) > return (uint32_t)(res & UINT32_MAX); > } > > +static uint32_t get_zero_page_hash(void) > +{ > + static uint32_t hash; > + static int is_computed; bool? Later, Juan.