Re: [PATCH 5/7] include: add lock-less reference counting primitives

2014-05-13 Thread Samuel Thibault
Justus Winter, le Tue 13 May 2014 21:02:54 +0200, a écrit : > * include/refcount.h: New file. Ack. > --- > include/refcount.h | 193 > + > 1 file changed, 193 insertions(+) > create mode 100644 include/refcount.h > > diff --git a/include/ref

Re: [PATCH 4/7] libihash: use fast binary scaling to determine the load

2014-05-13 Thread Samuel Thibault
Justus Winter, le Tue 13 May 2014 21:02:53 +0200, a écrit : > Expressing the maximum load in binary percent (where 128b% corresponds > to 100%) allows us to use fast binary scaling to determine if the > maximum load has been reached without losing precision. > > Furthermore, the previously used ex

Re: [PATCH 3/7] libihash: use linear probing and fast modulo operation

2014-05-13 Thread Samuel Thibault
Justus Winter, le Tue 13 May 2014 21:02:52 +0200, a écrit : > libihash uses open addressing. Previously, quadratic probing in both > directions was used to resolve collisions. Quadratic probing might > result in a less efficient use of caches. > > Also, prime numbers of the form 4 * i + 3 were u

Re: [PATCH 2/7] libihash: use an integer hash function on the keys

2014-05-13 Thread Samuel Thibault
Justus Winter, le Tue 13 May 2014 21:02:51 +0200, a écrit : > Use an integer hash function to derive the index from the key. This > should reduce the number of collisions. Ack. > * libihash/ihash.c (hash_int32): New function. > (find_index): Use hash_int32 on the key to derive the index. > (add_

Re: [PATCH 1/7] libihash: fix type of max_load

2014-05-13 Thread Samuel Thibault
Justus Winter, le Tue 13 May 2014 21:02:50 +0200, a écrit : > Previously, int was used for the field max_load of struct hurd_ihash. > There is no reason for this as far as I can tell. Furthermore, > hurd_ihash_set_max_load takes an unsigned int max_load. Ack. > * libihash/ihash.h (struct hurd_ih

[PATCH 5/7] include: add lock-less reference counting primitives

2014-05-13 Thread Justus Winter
* include/refcount.h: New file. --- include/refcount.h | 193 + 1 file changed, 193 insertions(+) create mode 100644 include/refcount.h diff --git a/include/refcount.h b/include/refcount.h new file mode 100644 index 000..0816220 --- /dev/nu

[PATCH 4/7] libihash: use fast binary scaling to determine the load

2014-05-13 Thread Justus Winter
Expressing the maximum load in binary percent (where 128b% corresponds to 100%) allows us to use fast binary scaling to determine if the maximum load has been reached without losing precision. Furthermore, the previously used expression 'ht->nr_items * 100' overflows int at 2^25 (unsigned int at 2

[PATCH 6/7] libdiskfs: lock-less reference counting for peropen objects

2014-05-13 Thread Justus Winter
* libdiskfs/diskfs.h (struct peropen): Use refcount_t for field refcnt. * libdiskfs/peropen-make.c (diskfs_make_peropen): Initialize refcnt. * libdiskfs/peropen-rele.c (diskfs_release_peropen): Adjust accordingly. * libdiskfs/protid-make.c (diskfs_start_protid): Likewise. Also, the node must no lo

[PATCH 7/7] libtrivfs: lock-less reference counting for trivfs_peropen objects

2014-05-13 Thread Justus Winter
* libtrivfs/trivfs.h (struct trivfs_peropen): Use refcount_t for field refcnt. (struct trivfs_control): Remove unused field lock. * libtrivfs/cntl-create.c (trivfs_create_control): Drop the mutex initialization. * libtrivfs/io-reauthenticate.c (trivfs_S_io_reauthenticate): Adjust accordingly. * lib

[PATCH 1/7] libihash: fix type of max_load

2014-05-13 Thread Justus Winter
Previously, int was used for the field max_load of struct hurd_ihash. There is no reason for this as far as I can tell. Furthermore, hurd_ihash_set_max_load takes an unsigned int max_load. * libihash/ihash.h (struct hurd_ihash): Use unsigned int for field max_load. --- libihash/ihash.h | 2 +- 1

[PATCH 2/7] libihash: use an integer hash function on the keys

2014-05-13 Thread Justus Winter
Use an integer hash function to derive the index from the key. This should reduce the number of collisions. * libihash/ihash.c (hash_int32): New function. (find_index): Use hash_int32 on the key to derive the index. (add_one): Likewise. --- libihash/ihash.c | 17 +++-- 1 file changed

[PATCH 3/7] libihash: use linear probing and fast modulo operation

2014-05-13 Thread Justus Winter
libihash uses open addressing. Previously, quadratic probing in both directions was used to resolve collisions. Quadratic probing might result in a less efficient use of caches. Also, prime numbers of the form 4 * i + 3 were used as array sizes. This was used in combination with the integer modu

Re: [PATCH 03/11] include: add lock-less reference counting primitives

2014-05-13 Thread Justus Winter
Quoting Samuel Thibault (2014-05-13 12:55:29) > Justus Winter, le Tue 13 May 2014 12:52:03 +0200, a écrit : > > Quoting Neal H. Walfield (2014-05-13 09:44:21) > > > At Mon, 12 May 2014 12:05:41 +0200, > > > Justus Winter wrote: > > > > +/* Decrement REF. Return the result of the operation. This f

Re: [PATCH 03/11] include: add lock-less reference counting primitives

2014-05-13 Thread Samuel Thibault
Richard Braun, le Tue 13 May 2014 14:01:59 +0200, a écrit : > On Tue, May 13, 2014 at 12:56:03PM +0200, Samuel Thibault wrote: > > > > AIUI this cast is a case of type-puning. Why not making refcounts_t the > > > > union itself? That way would be clearly safe with gcc's extension. > > > > > > As

Re: [PATCH 03/11] include: add lock-less reference counting primitives

2014-05-13 Thread Richard Braun
On Tue, May 13, 2014 at 12:56:03PM +0200, Samuel Thibault wrote: > > > AIUI this cast is a case of type-puning. Why not making refcounts_t the > > > union itself? That way would be clearly safe with gcc's extension. > > > > As stated in the comment for refcounts_t, I like the idea of using the >

Re: [PATCH 03/11] include: add lock-less reference counting primitives

2014-05-13 Thread Neal H. Walfield
At Tue, 13 May 2014 13:47:51 +0200, Samuel Thibault wrote: > > Neal H. Walfield, le Tue 13 May 2014 13:44:37 +0200, a écrit : > > At Tue, 13 May 2014 12:52:03 +0200, > > Justus Winter wrote: > > > Quoting Neal H. Walfield (2014-05-13 09:44:21) > > > > At Mon, 12 May 2014 12:05:41 +0200, > > > > Ju

Re: [PATCH 03/11] include: add lock-less reference counting primitives

2014-05-13 Thread Samuel Thibault
Neal H. Walfield, le Tue 13 May 2014 13:44:37 +0200, a écrit : > At Tue, 13 May 2014 12:52:03 +0200, > Justus Winter wrote: > > Quoting Neal H. Walfield (2014-05-13 09:44:21) > > > At Mon, 12 May 2014 12:05:41 +0200, > > > Justus Winter wrote: > > > > +/* Decrement REF. Return the result of the op

Re: [PATCH 03/11] include: add lock-less reference counting primitives

2014-05-13 Thread Neal H. Walfield
At Tue, 13 May 2014 12:52:03 +0200, Justus Winter wrote: > > Quoting Neal H. Walfield (2014-05-13 09:44:21) > > At Mon, 12 May 2014 12:05:41 +0200, > > Justus Winter wrote: > > > +/* Decrement REF. Return the result of the operation. This function > > > + uses atomic operations. It is not req

Re: [PATCH 04/11] libports: lock-less reference counting for port_info objects

2014-05-13 Thread Samuel Thibault
Justus Winter, le Tue 13 May 2014 12:54:33 +0200, a écrit : > I'm aware of that. Note that _ports_complete_deallocate aquires the > _ports_htable_lock and checks if someone reacquired a reference > through the hash table. It should be explained how the whole figure works as a comment somewhere in

Re: [PATCH 03/11] include: add lock-less reference counting primitives

2014-05-13 Thread Samuel Thibault
Justus Winter, le Tue 13 May 2014 12:50:54 +0200, a écrit : > Quoting Samuel Thibault (2014-05-13 01:04:13) > > Justus Winter, le Mon 12 May 2014 12:05:41 +0200, a écrit : > > > +/* An opaque type. You must not access these values directly. */ > > > +typedef uint64_t refcounts_t; > > > + > > > +/

Re: [PATCH 03/11] include: add lock-less reference counting primitives

2014-05-13 Thread Samuel Thibault
Justus Winter, le Tue 13 May 2014 12:52:03 +0200, a écrit : > Quoting Neal H. Walfield (2014-05-13 09:44:21) > > At Mon, 12 May 2014 12:05:41 +0200, > > Justus Winter wrote: > > > +/* Decrement REF. Return the result of the operation. This function > > > + uses atomic operations. It is not req

Re: [PATCH 04/11] libports: lock-less reference counting for port_info objects

2014-05-13 Thread Justus Winter
Quoting Samuel Thibault (2014-05-13 00:28:38) > 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 (s

Re: [PATCH 02/11] libports: use a single hash table

2014-05-13 Thread Samuel Thibault
Justus Winter, le Tue 13 May 2014 12:48:46 +0200, a écrit : > Quoting Samuel Thibault (2014-05-13 01:00:30) > > Justus Winter, le Mon 12 May 2014 12:05:40 +0200, a écrit : > > > Previously, libports used a hash table per port bucket. This makes > > > looking up a port difficult if one does not kno

Re: [PATCH 03/11] include: add lock-less reference counting primitives

2014-05-13 Thread Justus Winter
Quoting Neal H. Walfield (2014-05-13 09:44:21) > At Mon, 12 May 2014 12:05:41 +0200, > Justus Winter wrote: > > +/* Decrement REF. Return the result of the operation. This function > > + uses atomic operations. It is not required to serialize calls to > > + this function. */ > > +static inl

Re: [PATCH 03/11] include: add lock-less reference counting primitives

2014-05-13 Thread Justus Winter
Quoting Samuel Thibault (2014-05-13 01:04:13) > Justus Winter, le Mon 12 May 2014 12:05:41 +0200, a écrit : > > +/* An opaque type. You must not access these values directly. */ > > +typedef uint64_t refcounts_t; > > + > > +/* Instead, the functions manipulating refcounts_t values write the > > +

Re: [PATCH 02/11] libports: use a single hash table

2014-05-13 Thread Justus Winter
Quoting Samuel Thibault (2014-05-13 01:00:30) > Justus Winter, le Mon 12 May 2014 12:05:40 +0200, a écrit : > > Previously, libports used a hash table per port bucket. This makes > > looking up a port difficult if one does not know the port bucket, as > > one has to iterate over all buckets and do

Re: [PATCH 07/11] libihash: use an integer hash function on the keys

2014-05-13 Thread Richard Braun
On Tue, May 13, 2014 at 09:47:31AM +0200, Neal H. Walfield wrote: > This URL is not valid ("ttwang.cnc.net Not Available. The domain > ttwang.cnc.net which you are trying to access is currently > unavailable..."). Do you have a more stable URL? At least mention > the name of the paper. It disapp

Re: [PATCH 07/11] libihash: use an integer hash function on the keys

2014-05-13 Thread Neal H. Walfield
At Mon, 12 May 2014 12:05:45 +0200, Justus Winter wrote: > > Use an integer hash function to derive the index from the key. This > should reduce the number of collisions. > > * libihash/ihash.c (hash_int32): New function. > (find_index): Use hash_int32 on the key to derive the index. > (add_one)

Re: [PATCH 03/11] include: add lock-less reference counting primitives

2014-05-13 Thread Neal H. Walfield
At Mon, 12 May 2014 12:05:41 +0200, Justus Winter wrote: > +/* Decrement REF. Return the result of the operation. This function > + uses atomic operations. It is not required to serialize calls to > + this function. */ > +static inline unsigned int > +refcount_deref (refcount_t *ref) > +{ >