[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 10/15] qht: QEMU's fast, resizable and scalab
From: |
Sergey Fedorov |
Subject: |
Re: [Qemu-devel] [PATCH v6 10/15] qht: QEMU's fast, resizable and scalable Hash Table |
Date: |
Fri, 3 Jun 2016 18:34:34 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 |
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