From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5NOs-0001oe-RZ for qemu-devel@nongnu.org; Tue, 24 May 2016 21:14:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5NOC-0007cw-UH for qemu-devel@nongnu.org; Tue, 24 May 2016 21:14:17 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:42719) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5NOA-0007WI-Af for qemu-devel@nongnu.org; Tue, 24 May 2016 21:13:36 -0400 From: "Emilio G. Cota" Date: Tue, 24 May 2016 21:13:07 -0400 Message-Id: <1464138802-23503-1-git-send-email-cota@braap.org> Subject: [Qemu-devel] [PATCH v6 00/15] tb hash improvements List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU Developers , MTTCG Devel Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Richard Henderson , Sergey Fedorov v5: https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg02366.html v6 applies cleanly on top of tcg-next (8b1fe3f4 "cpu-exec: Clean up 'interrupt_request' reloading", tagged "pull-tcg-20160512"). Changes from v5, mostly from Sergey's review: - processor.h: use #ifdef #elif throughout the file - tb_hash_func: use uint32 for 'flags' param - tb_hash_func5: do 'foo >> 32' instead of 'foo >> 31 >> 1', since foo is a u64. - thread.h: * qemu_spin_locked: remove acquire semantics; simply use atomic_read(). * qemu_spin_trylock: return bool instead of 0 or -EBUSY; this saves a branch. * qemu_spin: + use __sync_lock_test_and_set and __sync_lock_release; drop the patches touching atomic.h. + add unlikely() hint to "while (test_and_set)"; this gives a small speedup under no contention. - qht: * merge the parallel-writes patch into the QHT patch. [Richard: I dropped your reviewed-by since the patch changed quite a bit.] * drop unneeded #includes from qht.h * document qht.h using kerneldoc. * use unsigned int for storing the seqlock version. * fix a couple of typos in the comments at the top of qht.c. * explain better the "no duplicated pointer" policy: while trying to insert an already-existing hash-pointer pair is OK (insert will just return false), it's not OK to insert different hash-pointer pairs that share the same pointer value, but not the hashes. * Add comment about lookups having to be done in an RCU read-critical section. * remove map->stale; simply check ht->map before and after acquiring a bucket lock. * only use atomic_read/set on bucket pointers, not hashes. Reading partially-updated hashes is OK, since we'll retry anyway thanks to the seqlock. Add a comment regarding this at the top of struct qht_bucket. * s/b->n/b->n_buckets/ * define qht_debug_assert, enabled #ifdef QHT_DEBUG. Use it instead of assert(), except in one case (slow path) where g_assert_cmpuint is convenient. * use a mutex for ht->lock instead of a spinlock. This makes the resize code simpler, since holding ht->lock for a bit of time is OK now; other threads won't be busy-waiting. Document that ht->lock needs to be grabbed before b->lock. * use atomic_rcu_read/set instead of open-coding them. * qht_remove: only clear out b->hashes[] and b->pointers[] if they belong to what was the last entry in the chain. * qht_remove: add debug assert against inserting a NULL pointer. Thanks, Emilio