Re: [PATCH 4/6] rhashtable: allow a walk of the hash table without missing objects.

2018-03-28 Thread NeilBrown
On Thu, Mar 29 2018, NeilBrown wrote: > > How about storing the hash chains in order by object address? > Then rhashtable_walk_start() can easily find it's place regardless of > whether the old object was still present or not, using <= on the > address. > "Insert" would need to record an insert lo

Re: [PATCH 4/6] rhashtable: allow a walk of the hash table without missing objects.

2018-03-28 Thread NeilBrown
On Wed, Mar 28 2018, Herbert Xu wrote: > On Wed, Mar 28, 2018 at 06:17:57PM +1100, NeilBrown wrote: >> >> Sounds like over-kill to me. >> It might be reasonable to have a CONFIG_DEBUG_RHASHTABLE which enables >> extra to code to catch misuse, but I don't see the justification for >> always perform

Re: [PATCH 4/6] rhashtable: allow a walk of the hash table without missing objects.

2018-03-28 Thread Herbert Xu
On Wed, Mar 28, 2018 at 06:17:57PM +1100, NeilBrown wrote: > > Sounds like over-kill to me. > It might be reasonable to have a CONFIG_DEBUG_RHASHTABLE which enables > extra to code to catch misuse, but I don't see the justification for > always performing these checks. > The DEBUG code could just s

Re: [PATCH 4/6] rhashtable: allow a walk of the hash table without missing objects.

2018-03-28 Thread NeilBrown
On Wed, Mar 28 2018, Herbert Xu wrote: > On Wed, Mar 28, 2018 at 08:54:41AM +1100, NeilBrown wrote: >> >> Possibly. >> I particularly want the interface to require that you pass the >> previously returned object to _continue. That makes it easy to see that >> the object is still being used. If so

Re: [PATCH 4/6] rhashtable: allow a walk of the hash table without missing objects.

2018-03-27 Thread Herbert Xu
On Wed, Mar 28, 2018 at 08:54:41AM +1100, NeilBrown wrote: > > Possibly. > I particularly want the interface to require that you pass the > previously returned object to _continue. That makes it easy to see that > the object is still being used. If someone changes to code to delete > the object be

Re: [PATCH 4/6] rhashtable: allow a walk of the hash table without missing objects.

2018-03-27 Thread NeilBrown
On Tue, Mar 27 2018, Herbert Xu wrote: > On Tue, Mar 27, 2018 at 10:33:04AM +1100, NeilBrown wrote: >> >> -int rhashtable_walk_start_check(struct rhashtable_iter *iter) >> +int rhashtable_walk_start_continue(struct rhashtable_iter *iter, struct >> rhash_head *obj) >> __acquires(RCU) >> { >>

Re: [PATCH 4/6] rhashtable: allow a walk of the hash table without missing objects.

2018-03-27 Thread NeilBrown
On Tue, Mar 27 2018, David Miller wrote: > From: NeilBrown > Date: Tue, 27 Mar 2018 10:33:04 +1100 > >> In many cases where the walker needs to drop out of RCU protection, >> it will take a reference to the object and this can prevent it from >> being removed from the hash table. In those cases,

Re: [PATCH 4/6] rhashtable: allow a walk of the hash table without missing objects.

2018-03-27 Thread Herbert Xu
On Tue, Mar 27, 2018 at 11:49:41AM -0400, David Miller wrote: > > Merely having an elevated reference count does not explicitly prevent > the object from being removed from the hash table. > > This invariant might hold for the particular user of the rhashtable > instance, but it is not always the

Re: [PATCH 4/6] rhashtable: allow a walk of the hash table without missing objects.

2018-03-27 Thread Herbert Xu
On Tue, Mar 27, 2018 at 10:33:04AM +1100, NeilBrown wrote: > > -int rhashtable_walk_start_check(struct rhashtable_iter *iter) > +int rhashtable_walk_start_continue(struct rhashtable_iter *iter, struct > rhash_head *obj) > __acquires(RCU) > { > struct rhashtable *ht = iter->ht; > >

Re: [PATCH 4/6] rhashtable: allow a walk of the hash table without missing objects.

2018-03-27 Thread David Miller
From: NeilBrown Date: Tue, 27 Mar 2018 10:33:04 +1100 > In many cases where the walker needs to drop out of RCU protection, > it will take a reference to the object and this can prevent it from > being removed from the hash table. In those cases, the last-returned > object can still be used as a

[PATCH 4/6] rhashtable: allow a walk of the hash table without missing objects.

2018-03-26 Thread NeilBrown
When a walk of the hashtable can be done entirely under RCU, no objects will be missed - though seeing duplicates is possible. This is because a cursor is kept in iter->p. Without the cursor we depend on the ->skip counter. If an object before the current location in hash chain is removed, the ->s