From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Kdn-0005St-1V for qemu-devel@nongnu.org; Tue, 24 May 2016 18:17:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5Kdh-0003gZ-2T for qemu-devel@nongnu.org; Tue, 24 May 2016 18:17:30 -0400 Received: from mail-lb0-x244.google.com ([2a00:1450:4010:c04::244]:35206) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Kdg-0003gU-Qx for qemu-devel@nongnu.org; Tue, 24 May 2016 18:17:25 -0400 Received: by mail-lb0-x244.google.com with SMTP id sh2so1743460lbb.2 for ; Tue, 24 May 2016 15:17:24 -0700 (PDT) References: <1463196873-17737-1-git-send-email-cota@braap.org> <1463196873-17737-14-git-send-email-cota@braap.org> <574367EB.8030101@gmail.com> <20160524220755.GA25193@flamenco> From: Sergey Fedorov Message-ID: <5744D2F1.2050009@gmail.com> Date: Wed, 25 May 2016 01:17:21 +0300 MIME-Version: 1.0 In-Reply-To: <20160524220755.GA25193@flamenco> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 13/18] qht: support parallel writes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Emilio G. Cota" Cc: QEMU Developers , MTTCG Devel , =?UTF-8?Q?Alex_Benn=c3=a9e?= , Paolo Bonzini , Peter Crosthwaite , Richard Henderson On 25/05/16 01:07, Emilio G. Cota wrote: > On Mon, May 23, 2016 at 23:28:27 +0300, Sergey Fedorov wrote: >> What if we turn qht::lock into a mutex and change the function as follows: >> >> static inline >> struct qht_bucket *qht_bucket_lock__no_stale(struct qht *ht, >> uint32_t hash, >> struct qht_map >> **pmap) >> { >> struct qht_bucket *b; >> struct qht_map *map; >> >> map = atomic_rcu_read(&ht->map); >> b = qht_map_to_bucket(map, hash); >> >> qemu_spin_lock(&b->lock); >> /* 'ht->map' access is serialized by 'b->lock' here */ >> if (likely(map == ht->map)) { >> /* no resize in progress; we're done */ >> *pmap = map; >> return b; >> } >> qemu_spin_unlock(&b->lock); >> >> /* resize in progress; retry grabbing 'ht->lock' */ >> qemu_mutex_lock(&ht->lock); >> b = qht_map_to_bucket(ht->map, hash); >> *pmap = ht->map; >> qemu_spin_lock(&b->lock); >> qemu_mutex_unlock(&ht->lock); >> >> return b; >> } >> >> >> With this implementation we could: >> (1) get rid of qht_map::stale >> (2) don't waste cycles waiting for resize to complete > I'll include this in v6. How is it by perf? Regards, Sergey