[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 13/18] qht: support parallel writes
From: |
Sergey Fedorov |
Subject: |
Re: [Qemu-devel] [PATCH v5 13/18] qht: support parallel writes |
Date: |
Wed, 25 May 2016 01:17:21 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 |
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
- Re: [Qemu-devel] [PATCH v5 04/18] include/processor.h: define cpu_relax(), (continued)
[Qemu-devel] [PATCH v5 06/18] atomics: add atomic_read_acquire and atomic_set_release, Emilio G. Cota, 2016/05/13
[Qemu-devel] [PATCH v5 13/18] qht: support parallel writes, Emilio G. Cota, 2016/05/13
[Qemu-devel] [PATCH v5 10/18] qdist: add module to represent frequency distributions of data, Emilio G. Cota, 2016/05/13
[Qemu-devel] [PATCH v5 08/18] exec: add tb_hash_func5, derived from xxhash, Emilio G. Cota, 2016/05/13
[Qemu-devel] [PATCH v5 16/18] qht: add test-qht-par to invoke qht-bench from 'check' target, Emilio G. Cota, 2016/05/13
[Qemu-devel] [PATCH v5 17/18] tb hash: track translated blocks with qht, Emilio G. Cota, 2016/05/13
[Qemu-devel] [PATCH v5 15/18] qht: add qht-bench, a performance benchmark, Emilio G. Cota, 2016/05/13
[Qemu-devel] [PATCH v5 14/18] qht: add test program, Emilio G. Cota, 2016/05/13
[Qemu-devel] [PATCH v5 09/18] tb hash: hash phys_pc, pc, and flags with xxhash, Emilio G. Cota, 2016/05/13