Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1403711 > unrolled thread

Re: [patch V2 3/7] futex: Add op for hash preallocation

Started byPeter Zijlstra <peterz@infradead.org>
First post2016-05-19 14:30 +0200
Last post2016-05-30 11:00 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [patch V2 3/7] futex: Add op for hash preallocation Peter Zijlstra <peterz@infradead.org> - 2016-05-19 14:30 +0200
    Re: [patch V2 3/7] futex: Add op for hash preallocation Sebastian Andrzej Siewior <sebastian@breakpoint.cc> - 2016-05-27 19:30 +0200
      Re: [patch V2 3/7] futex: Add op for hash preallocation Peter Zijlstra <peterz@infradead.org> - 2016-05-30 11:00 +0200

#1403711 — Re: [patch V2 3/7] futex: Add op for hash preallocation

FromPeter Zijlstra <peterz@infradead.org>
Date2016-05-19 14:30 +0200
SubjectRe: [patch V2 3/7] futex: Add op for hash preallocation
Message-ID<rAvfs-8bz-37@gated-at.bofh.it>
On Thu, May 05, 2016 at 08:44:05PM -0000, Thomas Gleixner wrote:
> +static int futex_preallocate_hash(unsigned int slots)
> +{
> +#ifdef CONFIG_FUTEX_PRIVATE_HASH
> +	struct mm_struct *mm = current->mm;
> +	struct futex_hash_bucket *hb;
> +	unsigned int bits;
> +
> +	/* Try to allocate the requested nr of slots */
> +	bits = order_base_2(slots);
> +
> +	if (bits < FUTEX_MIN_HASH_BITS)
> +		bits = FUTEX_MIN_HASH_BITS;
> +
> +	if (bits > futex_max_hash_bits)
> +		bits = futex_max_hash_bits;
> +
> +	futex_populate_hash(bits);

Should we not simply fail if the provided number of slots is not a power
of 2 ?

[toc] | [next] | [standalone]


#1408205

FromSebastian Andrzej Siewior <sebastian@breakpoint.cc>
Date2016-05-27 19:30 +0200
Message-ID<rDtKa-6ka-37@gated-at.bofh.it>
In reply to#1403711
On 2016-05-19 14:25:58 [+0200], Peter Zijlstra wrote:
> On Thu, May 05, 2016 at 08:44:05PM -0000, Thomas Gleixner wrote:
> > +static int futex_preallocate_hash(unsigned int slots)
> > +{
> > +#ifdef CONFIG_FUTEX_PRIVATE_HASH
> > +	struct mm_struct *mm = current->mm;
> > +	struct futex_hash_bucket *hb;
> > +	unsigned int bits;
> > +
> > +	/* Try to allocate the requested nr of slots */
> > +	bits = order_base_2(slots);
> > +
> > +	if (bits < FUTEX_MIN_HASH_BITS)
> > +		bits = FUTEX_MIN_HASH_BITS;
> > +
> > +	if (bits > futex_max_hash_bits)
> > +		bits = futex_max_hash_bits;
> > +
> > +	futex_populate_hash(bits);
> 
> Should we not simply fail if the provided number of slots is not a power
> of 2 ?

We could if it is worth doing so. The procfs interface which limits the
upper / lower limit is bits based. This is slot based which then gets
converted to the number if bits.
If we align this interface with proc's limits then we would expect the
number of bits instead slots - now check for power of two anymore.
Anyone?

Sebastian

[toc] | [prev] | [next] | [standalone]


#1408889

FromPeter Zijlstra <peterz@infradead.org>
Date2016-05-30 11:00 +0200
Message-ID<rErdg-1TA-49@gated-at.bofh.it>
In reply to#1408205
On Fri, May 27, 2016 at 07:27:57PM +0200, Sebastian Andrzej Siewior wrote:
> On 2016-05-19 14:25:58 [+0200], Peter Zijlstra wrote:
> > On Thu, May 05, 2016 at 08:44:05PM -0000, Thomas Gleixner wrote:
> > > +static int futex_preallocate_hash(unsigned int slots)
> > > +{
> > > +#ifdef CONFIG_FUTEX_PRIVATE_HASH
> > > +	struct mm_struct *mm = current->mm;
> > > +	struct futex_hash_bucket *hb;
> > > +	unsigned int bits;
> > > +
> > > +	/* Try to allocate the requested nr of slots */
> > > +	bits = order_base_2(slots);
> > > +
> > > +	if (bits < FUTEX_MIN_HASH_BITS)
> > > +		bits = FUTEX_MIN_HASH_BITS;
> > > +
> > > +	if (bits > futex_max_hash_bits)
> > > +		bits = futex_max_hash_bits;
> > > +
> > > +	futex_populate_hash(bits);
> > 
> > Should we not simply fail if the provided number of slots is not a power
> > of 2 ?
> 
> We could if it is worth doing so. The procfs interface which limits the
> upper / lower limit is bits based. This is slot based which then gets
> converted to the number if bits.
> If we align this interface with proc's limits then we would expect the
> number of bits instead slots - now check for power of two anymore.
> Anyone?

I'm all for consistent and strict when it comes to things like this.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web