[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 04/11] libports: lock-less reference counting for port_info o
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 04/11] libports: lock-less reference counting for port_info objects |
Date: |
Tue, 13 May 2014 00:28:38 +0200 |
User-agent: |
Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) |
Justus Winter, le Mon 12 May 2014 12:05:42 +0200, a écrit :
> - pthread_mutex_lock (&_ports_lock);
> pthread_mutex_lock (&_ports_htable_lock);
>
> if (_ports_htable.nr_items == 0)
> @@ -60,13 +59,12 @@ _ports_bucket_class_iterate (struct port_bucket *bucket,
> if ((bucket == NULL || pi->bucket == bucket)
> && (class == NULL || pi->class == class))
> {
> - pi->refcnt++;
> + refcounts_ref (&pi->refcounts, NULL);
> p[n] = pi;
> n++;
> }
> }
> pthread_mutex_unlock (&_ports_htable_lock);
> - pthread_mutex_unlock (&_ports_lock);
Mmm, just to warn (I'm not sure I'll get the time soon to review these
changes), this kind of change needs a lot of making sure we see the
whole picture: quite often taking the mutex is not only to protect
the reference counting, but also to make that coherent with other
reads/writes, and thus only an atomic operation is not enough. As an
example, here we would want to make sure other threads see that we have
acquired a reference, before recording the pointer and doing something
else. Keeping the mutex is more than we need, but we need to make sure
we still synchronize enough with the rest of the code.
Samuel
- Re: [PATCH 03/11] include: add lock-less reference counting primitives, (continued)
[PATCH 06/11] libtrivfs: lock-less reference counting for trivfs_peropen objects, Justus Winter, 2014/05/12
[PATCH 02/11] libports: use a single hash table, Justus Winter, 2014/05/12
[PATCH 04/11] libports: lock-less reference counting for port_info objects, Justus Winter, 2014/05/12
- Re: [PATCH 04/11] libports: lock-less reference counting for port_info objects,
Samuel Thibault <=
[PATCH 08/11] libihash: reduce the default maximum load factor to 75%, Justus Winter, 2014/05/12
[PATCH 11/11] fatfs: improve {enable,disable}_caching, Justus Winter, 2014/05/12
[PATCH 10/11] ext2fs: improve {enable,disable}_caching, Justus Winter, 2014/05/12