From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753172AbdI1K6X (ORCPT ); Thu, 28 Sep 2017 06:58:23 -0400 Received: from merlin.infradead.org ([205.233.59.134]:52788 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753073AbdI1K6V (ORCPT ); Thu, 28 Sep 2017 06:58:21 -0400 Date: Thu, 28 Sep 2017 12:58:14 +0200 From: Peter Zijlstra To: Gerd Gerats Cc: tglx@linutronix.de, mingo@redhat.com, dvhart@infradead.org, LKML Subject: Re: [RFC] futex: hashbucket as list of futex instead of waiters Message-ID: <20170928105814.cfzsyi42asybctfo@hirez.programming.kicks-ass.net> References: <20170910213324.GA24252@pluto.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170910213324.GA24252@pluto.fritz.box> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 10, 2017 at 11:41:58PM +0200, Gerd Gerats wrote: > When using futex as a condition variable, for example: to manage a > threadpool, there may be a lot of threads inside the futex_wait to sleep on > this futex. The futex_hash_bucket consists therefore of many struct futex_q > for the same futex. > > On bad luck another futex, used as mutex, hashed into the same bucket. > Every futex_wake on this mutex, has to scan the whole chain of above waiter > to find the struct futex_q for this mutex. For non-unusual threadpool sizes > of more than 20, this should be a considerable effort. > > I therefore suggest to include in the hash-bucketchain only one struct > futex_q per futex and to queue additional waiter in an extrachain at the > 'top' futex_q entry. Thus different futex are isolated from each other, the > cost of a hash collision is reduced. So I don't dislike that idea.. however > To show the idea, I added a sample patch. Here, the plist is exchanged for > a futex-specific implementation. kernel/pring.h is certainly not not the > right place. So I suppose the purpose of that plist in futex is to enable waking up the highest prio waiter, but with the advent of SCHED_DEADLINE that no longer works. I think Thomas resisted going the RB-tree route earlier..