From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752793AbdJaItR (ORCPT ); Tue, 31 Oct 2017 04:49:17 -0400 Received: from mout.gmx.net ([212.227.17.21]:51711 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751366AbdJaItP (ORCPT ); Tue, 31 Oct 2017 04:49:15 -0400 Message-ID: <1509439705.14765.16.camel@gmx.de> Subject: Re: [PATCH RFC 1/2] sched: Minimize the idle cpu selection race window. From: Mike Galbraith To: Peter Zijlstra , Atish Patra Cc: linux-kernel@vger.kernel.org, joelaf@google.com, brendan.jackman@arm.com, jbacik@fb.com, mingo@redhat.com Date: Tue, 31 Oct 2017 09:48:25 +0100 In-Reply-To: <20171031082009.rxxa57goto6q5xld@hirez.programming.kicks-ass.net> References: <1509427662-25114-1-git-send-email-atish.patra@oracle.com> <1509427662-25114-2-git-send-email-atish.patra@oracle.com> <20171031082009.rxxa57goto6q5xld@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="ISO-8859-15" X-Mailer: Evolution 3.20.5 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:Tds7/aJtHt09MAjGxWTmXwgdt5OZkVx/8D0ZUI6sa6cz7M7puUF 0jYFi+fdAtJYWKvaLbnPsDNj9DM+A51u9b2DZS5gXpQnnRdc2p6k8uR03jN4iUZiIBPfr95 zdgX+4SGMfmY3dZh+RNdKRfsxDY6/iOl3vn5mGnWbBNWqys0hXf4VOZuVKu2HtBpaLA7z/+ 5XQgrK35K7aS1LiRnKp2A== X-UI-Out-Filterresults: notjunk:1;V01:K0:NazGtCPZm+Q=:nIwwtqy65mpEpo42xvtItT dcgPF+YQUBsF9X9ZSb0NEefvxro66jzctgIZT2HJMVIlkhN4YICvpGoNTrPwnRZUyZDFAKjsN zry6OqWefAj9EO+z1P5y1HKgw0CQaXyhNr2rt5lhaTRtF5RL36jZt7JKP70sj34Xi2g3akO9s PMQ+WyDryJZ8AS1vgbVPfaXusCoIC5khjOln/cshbl1QpBUm2nGRut1rgffixQZx0zUonta6E ta1AT6Q6yUlLXeZsIjLjMkcUZ+6YdbVzdICPhILaw6D6mQnDR/NHACqGCRTuXYC8P40NNcdPv IYkaz36Zh3UN3uIzoStUxd62eJEsDyKQdg2hXUsClrgU/AqBy7UYej9nWxpBHcjKTfNK+RqOq 0Wk4i4440KN4FfWy8edGBIxf8FlyaTOQJur7W0DgWE7/jIjLWicPugRgGdeS9wmJlB5+ep2ki YGN5krlAmI2xVICHtSQwOuEYIaa+w8UT2k4T5xyxY++LfgEPoWJ28wTZc5IWE4K2dhtrRVXml PU7m5y2XLt+lstOzIOqwpYfEu48Snx83dNxJDUw85aT+oo6u69zGz8J6unsLpq2R+F3lTq2F4 7omwUo2lL6vnIw79LymoAShkj0iCzmb2UQlLNHudOp1LMcBSDYZILA8jQLqhCssv8dexYdOXj SJ08K/J9gaGkmkOD5EUAx2EoxGIOOkfGPSBjX4ifdCSka2TvB7kdEDESadNOAtUI1E3ee6nRR odJzXkRZYxgDQieLNC6C23QON9xKnXPQv2A7nB/fxaqWF3cCmJ7abyQ1KQP9JX++uL2grftzr FpWkm044fKVVRM6aQJ8JzPyJz69Mp1FaRegrMtpH+CDhFXtASo= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2017-10-31 at 09:20 +0100, Peter Zijlstra wrote: > On Tue, Oct 31, 2017 at 12:27:41AM -0500, Atish Patra wrote: > > Currently, multiple tasks can wakeup on same cpu from > > select_idle_sibiling() path in case they wakeup simulatenously > > and last ran on the same llc. This happens because an idle cpu > > is not updated until idle task is scheduled out. Any task waking > > during that period may potentially select that cpu for a wakeup > > candidate. > > > > Introduce a per cpu variable that is set as soon as a cpu is > > selected for wakeup for any task. This prevents from other tasks > > to select the same cpu again. Note: This does not close the race > > window but minimizes it to accessing the per-cpu variable. If two > > wakee tasks access the per cpu variable at the same time, they may > > select the same cpu again. But it minimizes the race window > > considerably. > > The very most important question; does it actually help? What > benchmarks, give what numbers? I played with something ~similar (cmpxchg() idle cpu reservation) a while back in the context of schbench, and it did help that, but for generic fast mover benchmarks, the added overhead had the expected effect, it shaved throughput a wee bit (rob Peter, pay Paul, repeat). I still have the patch lying about in my rubbish heap, but didn't bother to save any of the test results. -Mike