From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751778AbdI1WkT (ORCPT ); Thu, 28 Sep 2017 18:40:19 -0400 Received: from mout.gmx.net ([212.227.17.21]:52012 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750880AbdI1WkS (ORCPT ); Thu, 28 Sep 2017 18:40:18 -0400 Date: Fri, 29 Sep 2017 00:39:32 +0200 From: Gerd Gerats To: Peter Zijlstra 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: <20170928223932.GA874@pluto.fritz.box> References: <20170910213324.GA24252@pluto.fritz.box> <20170928105814.cfzsyi42asybctfo@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170928105814.cfzsyi42asybctfo@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.9.1 (2017-09-22) X-Provags-ID: V03:K0:ug7Hkgu2RuqCRvwflaqZxnhpN0Sc451VeuZob7tW5TMiYDIt3kX ol2I4cMNy7sKx7M0CILTp/MDve7d7fnVUvihcmCb9usndJSI4FWcnD9vJTtNqL0cKYuTATq 8nh1L23eVS7W04aMf46UY+EUMf8Nov9bSxbgXUXuudZaLsW6OvQAmN7du1M6xjdOJ2ygX8h wRzAyYx6agLgTtklcOcLg== X-UI-Out-Filterresults: notjunk:1;V01:K0:fuRpg7yK8qc=:V8I2XGMnNj4ZdfCtWh3u7R ILfLuzhCAxS3CvbxOCojv7H0u0i1qqtiiq4/W0T1AReW/AomA2nqX6NFAf+Jq0fQnSB57d9z5 k0I61DkIzvSZDyLDpK4iEv2g4HvAFEAFfrYzc1/+MlR52VnNPxOQGHIrJU5hqfXAc+R4fZ1bv ZF0oisDGYbgoYnosIbSKnmVtBmDsrS6xE8gN4wMRAXd4gtQ1pXa5e86nFC5fnMaY04DV4z/I3 FDvsBBLVYvnBnINFuIkbqwAWefrf02aB6MPvHr/kBvu4UzDCNES9Ro6XSohe267MMnaOeNfMV OkccqB4yJIsnVbNSc6doeJ1xve7pn6CNvD9n+BA4Ul2tsHIK7HyATK4xjHYc8W+qFgKjFSXL+ WWuRQOZsOOtNLo2MfWAIBX3jgg5hill86psY/dH0xBhhvWXWBbfMHRnX1wdRQP1cemv2eosg+ SMqj6teB+8DLfTBqhQRv1N292aT0kE9OVYV+4nphgX2wv8sVPe/di39IK6hw5Ad7P+HLVKBMX Js9vXkhCNpURer3Mu4WwN93S1FV2CQXk1wbcNgWbdg/xFjCjlJIDR69B2p3WdN2kCK/np7NkX mqBQB73anFCsO50O3iHXrJqW2UUCuwk0C+Fq774OxuWaf+J8PxyCoBlXoUu8p9zFKay90I53k jYU6zbdyrAz2tWfZ7HADczT9hR7NdX1lxrS/B/6oI5GfizVOOWuv/V8TUrgpCmH3NYVu3oGSM xdl9/EYZDZPhC3rrfb7e/Xgm+k1CDTVKhTsiYzF1ICpen6ykpCTrJv79YHN50kefqH4298PrN HAk8i1ZeMntryVwMzYnSF8hY+UwWeuWvAo9oQyuhCkiD2nyEZk= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 28, 2017 at 12:58:14PM +0200, Peter Zijlstra wrote: > 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 do not understand, plist is the original data structure. I assume, it works together with SCHED_DEADLINE. Or is there something on the way not pressent in 4.13. pring replaces this data structure, retaining prio sorting rules, by a head-less ring. This ring contains all waiter for one futex_key, ordered the same way as by plist. Thanx, Gerd