From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752885AbcDBSDK (ORCPT ); Sat, 2 Apr 2016 14:03:10 -0400 Received: from www.linutronix.de ([62.245.132.108]:57714 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752488AbcDBSDJ (ORCPT ); Sat, 2 Apr 2016 14:03:09 -0400 Date: Sat, 2 Apr 2016 20:01:29 +0200 (CEST) From: Thomas Gleixner To: Peter Zijlstra cc: LKML , Sebastian Andrzej Siewior , Darren Hart , Ingo Molnar , Michael Kerrisk , Davidlohr Bueso , Chris Mason , "Carlos O'Donell" , Torvald Riegel , Eric Dumazet Subject: Re: [RFC patch 4/7] futex: Add support for attached futexes In-Reply-To: <20160402162632.GQ3448@twins.programming.kicks-ass.net> Message-ID: References: <20160402095108.894519835@linutronix.de> <20160402110035.753145539@linutronix.de> <20160402162632.GQ3448@twins.programming.kicks-ass.net> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2 Apr 2016, Peter Zijlstra wrote: > On Sat, Apr 02, 2016 at 11:09:18AM -0000, Thomas Gleixner wrote: > > +/** > > + * hash_local_futex - Return the hash bucket in the task local cache > > + * @uaddr: The user space address of the futex > > + * @prime: The prime number for the modulo operation > > + * > > + * That's a primitive hash function, but it turned out to be the most > > + * efficient one for the task local cache as we don't have anything to > > + * mix in like we have for the global hash. > > + */ > > +static inline unsigned int > > +hash_local_futex(void __user *uaddr, unsigned int prime) > > +{ > > + return ((unsigned long) uaddr) % prime; > > +} > > > +static unsigned int hash_prime(unsigned int size) > > +{ > > + switch(size) { > > + case 16: > > + default: return 13; > > + case 32: return 31; > > + case 64: return 61; > > + case 128: return 127; > > + case 256: return 251; > > + case 512: return 509; > > + case 1024: return 1021; > > + case 2048: return 2039; > > + case 4096: return 4093; > > + } > > +} > > One wonders what's wrong with include/linux/hash.h ? It appears to me > hash_ptr() is pretty much what you want, no? Nothing is wrong with that. Just my futex fried brain not being able to see the obvious:) Thanks, tglx