Re: [PATCH 4/8] rhashtable: fix race in nested_table_alloc()

2018-05-06 Thread NeilBrown
On Sun, May 06 2018, Herbert Xu wrote: > On Sun, May 06, 2018 at 07:48:20AM +1000, NeilBrown wrote: >> >> The spinlock protects 2 or more buckets. The nested table contains at >> least 512 buckets, maybe more. >> It is quite possible for two insertions into 2 different buckets to both >> get thei

Re: [PATCH 4/8] rhashtable: fix race in nested_table_alloc()

2018-05-05 Thread Herbert Xu
On Sun, May 06, 2018 at 07:48:20AM +1000, NeilBrown wrote: > > The spinlock protects 2 or more buckets. The nested table contains at > least 512 buckets, maybe more. > It is quite possible for two insertions into 2 different buckets to both > get their spinlock and both try to instantiate the same

Re: [PATCH 4/8] rhashtable: fix race in nested_table_alloc()

2018-05-05 Thread NeilBrown
On Sat, May 05 2018, Herbert Xu wrote: > On Fri, May 04, 2018 at 01:54:14PM +1000, NeilBrown wrote: >> If two threads run nested_table_alloc() at the same time >> they could both allocate a new table. >> Best case is that one of them will never be freed, leaking memory. >> Worst case is hat entry

Re: [PATCH 4/8] rhashtable: fix race in nested_table_alloc()

2018-05-05 Thread Herbert Xu
On Fri, May 04, 2018 at 01:54:14PM +1000, NeilBrown wrote: > If two threads run nested_table_alloc() at the same time > they could both allocate a new table. > Best case is that one of them will never be freed, leaking memory. > Worst case is hat entry get stored there before it leaks, > and the ar

[PATCH 4/8] rhashtable: fix race in nested_table_alloc()

2018-05-03 Thread NeilBrown
If two threads run nested_table_alloc() at the same time they could both allocate a new table. Best case is that one of them will never be freed, leaking memory. Worst case is hat entry get stored there before it leaks, and the are lost from the table. So use cmpxchg to detect the race and free th