From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8r7T-00011u-Ek for qemu-devel@nongnu.org; Fri, 03 Jun 2016 11:34:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8r7N-0002sk-67 for qemu-devel@nongnu.org; Fri, 03 Jun 2016 11:34:42 -0400 Received: from mail-lf0-x22a.google.com ([2a00:1450:4010:c07::22a]:36763) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8r7M-0002rE-UV for qemu-devel@nongnu.org; Fri, 03 Jun 2016 11:34:37 -0400 Received: by mail-lf0-x22a.google.com with SMTP id b73so56886901lfb.3 for ; Fri, 03 Jun 2016 08:34:36 -0700 (PDT) References: <1464138802-23503-1-git-send-email-cota@braap.org> <1464138802-23503-11-git-send-email-cota@braap.org> <574B487B.5080200@gmail.com> <20160603110149.GB5251@flamenco> From: Sergey Fedorov Message-ID: <5751A38A.2070707@gmail.com> Date: Fri, 3 Jun 2016 18:34:34 +0300 MIME-Version: 1.0 In-Reply-To: <20160603110149.GB5251@flamenco> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v6 10/15] qht: QEMU's fast, resizable and scalable Hash Table 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 , Richard Henderson On 03/06/16 14:01, Emilio G. Cota wrote: > On Sun, May 29, 2016 at 22:52:27 +0300, Sergey Fedorov wrote: >>> +/* >>> + * Find the last valid entry in @head, and swap it with @orig[pos], which has >>> + * just been invalidated. >>> + */ >>> +static inline void qht_bucket_fill_hole(struct qht_bucket *orig, int pos) >>> +{ >>> + struct qht_bucket *b = orig; >>> + struct qht_bucket *prev = NULL; >>> + int i; >>> + >>> + if (qht_entry_is_last(orig, pos)) { >>> + orig->hashes[pos] = 0; >>> + atomic_set(&orig->pointers[pos], NULL); >>> + return; >>> + } >>> + do { >>> + for (i = 0; i < QHT_BUCKET_ENTRIES; i++) { >>> + if (b->pointers[i]) { >>> + continue; >>> + } >>> + if (i > 0) { >>> + return qht_entry_move(orig, pos, b, i - 1); >>> + } >>> + qht_debug_assert(prev); >> 'prev' can be NULL if this is the first iteration. > How can prev be NULL here and that not be a bug? NULL here would > mean there was a hole before orig[pos]. Or orig[pos] was > NULL, which is also a bug. Yeah, you're right. Kind regards, Sergey