From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754431AbcE3I7Z (ORCPT ); Mon, 30 May 2016 04:59:25 -0400 Received: from merlin.infradead.org ([205.233.59.134]:46984 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754363AbcE3I7U (ORCPT ); Mon, 30 May 2016 04:59:20 -0400 Date: Mon, 30 May 2016 10:59:05 +0200 From: Peter Zijlstra To: Sebastian Andrzej Siewior Cc: Thomas Gleixner , LKML , Sebastian Andrzej Siewior , Linus Torvalds , Darren Hart , Ingo Molnar , Michael Kerrisk , Davidlohr Bueso , Chris Mason , "Carlos O'Donell" , Torvald Riegel , Eric Dumazet Subject: Re: [patch V2 3/7] futex: Add op for hash preallocation Message-ID: <20160530085905.GO3192@twins.programming.kicks-ass.net> References: <20160505204230.932454245@linutronix.de> <20160505204354.051976225@linutronix.de> <20160519122558.GC3192@twins.programming.kicks-ass.net> <20160527172756.GD28561@breakpoint.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160527172756.GD28561@breakpoint.cc> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.