Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-30 Thread Davidlohr Bueso
On Wed, 30 May 2018, Herbert Xu wrote: On Tue, May 29, 2018 at 10:59:27AM -0700, Davidlohr Bueso wrote: That's exactly what you need to explain in the patch or the commit message. In fact you still haven't explained it fully. Why do we need a second attempt without the GFP_NOFAIL? How does it

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-30 Thread Davidlohr Bueso
On Wed, 30 May 2018, Herbert Xu wrote: On Tue, May 29, 2018 at 10:59:27AM -0700, Davidlohr Bueso wrote: That's exactly what you need to explain in the patch or the commit message. In fact you still haven't explained it fully. Why do we need a second attempt without the GFP_NOFAIL? How does it

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Herbert Xu
On Tue, May 29, 2018 at 10:59:27AM -0700, Davidlohr Bueso wrote: > On Wed, 30 May 2018, Herbert Xu wrote: > > > It doesn't explain it at all. In fact I don't see why we neeed > > three attempts, just do the GFP_NOFAIL as the second and final step. > > Second attempt is reduced size only as we

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Herbert Xu
On Tue, May 29, 2018 at 10:59:27AM -0700, Davidlohr Bueso wrote: > On Wed, 30 May 2018, Herbert Xu wrote: > > > It doesn't explain it at all. In fact I don't see why we neeed > > three attempts, just do the GFP_NOFAIL as the second and final step. > > Second attempt is reduced size only as we

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Davidlohr Bueso
On Wed, 30 May 2018, Herbert Xu wrote: Well I think we should respect min_size. rhashtable users may fail at insertion time if the table is too small. I'm fine either way.

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Davidlohr Bueso
On Wed, 30 May 2018, Herbert Xu wrote: Well I think we should respect min_size. rhashtable users may fail at insertion time if the table is too small. I'm fine either way.

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Davidlohr Bueso
On Wed, 30 May 2018, Herbert Xu wrote: It doesn't explain it at all. In fact I don't see why we neeed three attempts, just do the GFP_NOFAIL as the second and final step. Second attempt is reduced size only as we don't want to GFP_NOFAIL if we can avoid it helping the allocator. We go from

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Davidlohr Bueso
On Wed, 30 May 2018, Herbert Xu wrote: It doesn't explain it at all. In fact I don't see why we neeed three attempts, just do the GFP_NOFAIL as the second and final step. Second attempt is reduced size only as we don't want to GFP_NOFAIL if we can avoid it helping the allocator. We go from

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Herbert Xu
On Tue, May 29, 2018 at 10:55:13AM -0700, Davidlohr Bueso wrote: > On Wed, 30 May 2018, Herbert Xu wrote: > > > On Tue, May 29, 2018 at 09:42:31AM -0700, Davidlohr Bueso wrote: > > > > > > For the sake of simplicity, Linus suggested directly using HASH_MIN_SIZE > > > such that we have a single

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Herbert Xu
On Tue, May 29, 2018 at 10:55:13AM -0700, Davidlohr Bueso wrote: > On Wed, 30 May 2018, Herbert Xu wrote: > > > On Tue, May 29, 2018 at 09:42:31AM -0700, Davidlohr Bueso wrote: > > > > > > For the sake of simplicity, Linus suggested directly using HASH_MIN_SIZE > > > such that we have a single

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Davidlohr Bueso
On Wed, 30 May 2018, Herbert Xu wrote: On Tue, May 29, 2018 at 09:42:31AM -0700, Davidlohr Bueso wrote: For the sake of simplicity, Linus suggested directly using HASH_MIN_SIZE such that we have a single fallback. Where did he suggest that? https://lkml.org/lkml/2018/5/24/1265

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Davidlohr Bueso
On Wed, 30 May 2018, Herbert Xu wrote: On Tue, May 29, 2018 at 09:42:31AM -0700, Davidlohr Bueso wrote: For the sake of simplicity, Linus suggested directly using HASH_MIN_SIZE such that we have a single fallback. Where did he suggest that? https://lkml.org/lkml/2018/5/24/1265

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Herbert Xu
On Tue, May 29, 2018 at 10:03:38AM -0700, Davidlohr Bueso wrote: > On Mon, 28 May 2018, Herbert Xu wrote: > > > + /* > > > + * This is api initialization and thus we need to guarantee the > > > + * initial rhashtable allocation. Upon failure, retry with a > > > + * smallest possible size,

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Herbert Xu
On Tue, May 29, 2018 at 10:03:38AM -0700, Davidlohr Bueso wrote: > On Mon, 28 May 2018, Herbert Xu wrote: > > > + /* > > > + * This is api initialization and thus we need to guarantee the > > > + * initial rhashtable allocation. Upon failure, retry with a > > > + * smallest possible size,

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Herbert Xu
On Tue, May 29, 2018 at 09:42:31AM -0700, Davidlohr Bueso wrote: > > For the sake of simplicity, Linus suggested directly using HASH_MIN_SIZE > such that we have a single fallback. Where did he suggest that? Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key:

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Herbert Xu
On Tue, May 29, 2018 at 09:42:31AM -0700, Davidlohr Bueso wrote: > > For the sake of simplicity, Linus suggested directly using HASH_MIN_SIZE > such that we have a single fallback. Where did he suggest that? Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key:

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Davidlohr Bueso
On Mon, 28 May 2018, Herbert Xu wrote: + /* +* This is api initialization and thus we need to guarantee the +* initial rhashtable allocation. Upon failure, retry with a +* smallest possible size, otherwise we exhaust our options with +* __GFP_NOFAIL. +

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Davidlohr Bueso
On Mon, 28 May 2018, Herbert Xu wrote: + /* +* This is api initialization and thus we need to guarantee the +* initial rhashtable allocation. Upon failure, retry with a +* smallest possible size, otherwise we exhaust our options with +* __GFP_NOFAIL. +

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Davidlohr Bueso
On Mon, 28 May 2018, Herbert Xu wrote: On Thu, May 24, 2018 at 02:11:31PM -0700, Davidlohr Bueso wrote: + /* +* This is api initialization and thus we need to guarantee the +* initial rhashtable allocation. Upon failure, retry with a +* smallest possible size,

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-29 Thread Davidlohr Bueso
On Mon, 28 May 2018, Herbert Xu wrote: On Thu, May 24, 2018 at 02:11:31PM -0700, Davidlohr Bueso wrote: + /* +* This is api initialization and thus we need to guarantee the +* initial rhashtable allocation. Upon failure, retry with a +* smallest possible size,

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-28 Thread Herbert Xu
On Thu, May 24, 2018 at 02:11:31PM -0700, Davidlohr Bueso wrote: > > + /* > + * This is api initialization and thus we need to guarantee the > + * initial rhashtable allocation. Upon failure, retry with a > + * smallest possible size, otherwise we exhaust our options with > +

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-28 Thread Herbert Xu
On Thu, May 24, 2018 at 02:11:31PM -0700, Davidlohr Bueso wrote: > > + /* > + * This is api initialization and thus we need to guarantee the > + * initial rhashtable allocation. Upon failure, retry with a > + * smallest possible size, otherwise we exhaust our options with > +

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-28 Thread Herbert Xu
On Thu, May 24, 2018 at 02:11:31PM -0700, Davidlohr Bueso wrote: > > -static struct bucket_table *bucket_table_alloc(struct rhashtable *ht, > -size_t nbuckets, > -gfp_t gfp) > +static struct bucket_table

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-28 Thread Herbert Xu
On Thu, May 24, 2018 at 02:11:31PM -0700, Davidlohr Bueso wrote: > > -static struct bucket_table *bucket_table_alloc(struct rhashtable *ht, > -size_t nbuckets, > -gfp_t gfp) > +static struct bucket_table

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-24 Thread Davidlohr Bueso
On Thu, 24 May 2018, Davidlohr Bueso wrote: size = sizeof(*tbl) + nbuckets * sizeof(tbl->buckets[0]); + if (retry) { + gfp |= __GFP_NOFAIL; + tbl = kzalloc(size, gfp); + } /* fall-through */ + if (gfp != GFP_KERNEL) tbl =

Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-24 Thread Davidlohr Bueso
On Thu, 24 May 2018, Davidlohr Bueso wrote: size = sizeof(*tbl) + nbuckets * sizeof(tbl->buckets[0]); + if (retry) { + gfp |= __GFP_NOFAIL; + tbl = kzalloc(size, gfp); + } /* fall-through */ + if (gfp != GFP_KERNEL) tbl =

[PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-24 Thread Davidlohr Bueso
rhashtable_init() may fail due to -ENOMEM, thus making the entire api unusable. This patch removes this scenario, however unlikely. In order to guarantee memory allocation, this patch refactors bucket_table_alloc() to add a 'retry' parameter which always ends up doing GFP_KERNEL|__GFP_NOFAIL for

[PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation

2018-05-24 Thread Davidlohr Bueso
rhashtable_init() may fail due to -ENOMEM, thus making the entire api unusable. This patch removes this scenario, however unlikely. In order to guarantee memory allocation, this patch refactors bucket_table_alloc() to add a 'retry' parameter which always ends up doing GFP_KERNEL|__GFP_NOFAIL for