Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2045410yba; Fri, 10 May 2019 05:32:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLxiOo931GL8uG4q4ujKtO6rG/KYhqEaUE67ZL2oNruunh7K4+9bLk2BXE942CLo0OXjYE X-Received: by 2002:a62:d244:: with SMTP id c65mr13472062pfg.173.1557491542885; Fri, 10 May 2019 05:32:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557491542; cv=none; d=google.com; s=arc-20160816; b=csOK1NXV2o0anGE4mN18GZ4cwHeEWYMMcv37lS06yooZARznQbqAj3jxTwKRxTIQ16 Nyz6ES8YOVHbf/8k8nnc0m8HBFGuqt8deLNbk3Gul7/2pfqLFVeMXuRDeXz23voCFiHc 83gL6dSFVNT0NqoMN9C8h+3LZOMof6UN+JDkD8YXul2gcBo3IjNgAXOvg8HYN081U6K4 1QE/c+LFsuoJibFKaJFrXbg2FeAx+b2oHDL2lnYl57NeZNIqg5jBbt9hWXYNm5lVXBwa jvV2JLpykY6beDYSMBCsEuFVLj6uCSwPixZSWEU8Ti9QeBsywNDYydLqkXO83CvmZb56 e5DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=eOLJW9/rZojjpBgthZDgv9XT0Wqubt+l+UgduLBDd9c=; b=Ez/mwfZ0jxi/Ey+5PwF2ZJx0G2hSAh7wQz28uxuH5a7zcpdMLT+JUt5sn2sixlbU3X IzXaxCY9sB1Kq04hiEyex64li/mhxK1PlsyL3zECvhfI79NfqBxdgzdGp5zie/FRUcvo dY+hJ2j6TaaYcZKncP4+swX2+CkgjAPnR5YYdFUuT/gD+N0ane8IUf9pm8863HGrGcCS 7x1KLZxc8i9VmuCeFGITpRzNKE4S4ZjtRDQLUcqKhUemrmuBR/B1YahoGWL+YPc36XAR 6jEBEF7klu7heeZyRB2wdNfBlpB62+HNX+4KFokd+7wqrDWNNidMarxAJSrwZ4ysIwzW KuWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AJOwqWfn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x143si7503258pgx.504.2019.05.10.05.32.05; Fri, 10 May 2019 05:32:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AJOwqWfn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727323AbfEJM3v (ORCPT + 99 others); Fri, 10 May 2019 08:29:51 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:40151 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727071AbfEJM3v (ORCPT ); Fri, 10 May 2019 08:29:51 -0400 Received: by mail-lj1-f194.google.com with SMTP id d15so4937460ljc.7 for ; Fri, 10 May 2019 05:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eOLJW9/rZojjpBgthZDgv9XT0Wqubt+l+UgduLBDd9c=; b=AJOwqWfnkRuAcTK2NNILnCY9nulpYpiG4KYbi2iRLLW+E+uVovUBH/qVdS1D/PWmKf Vk5LWm50Hb07SytgYij0y3u3Xlasuj8/zM8hJsyyf6zhWDFYwop+4GAmLIiQxs2rh4M5 GqYrcWVI18eSKMTUS2XuFqzEjFW4ilXaelHvVZyPpgx1vLlvXTw9ZAz8RpUm8c0ltEGM 6gGMt5mo2zJpVXEASZb6pOFKMsjnCH8LWqYYwQaxTRZzdZsi0JxfonV30+mgaIbwTNUf DXQd6sikdzQUu6r2LH7GI/xKhX0OGbBH6BvxVJSBEp1vdCLbZ2KKFMk4pf6UcTiYZH5Z g0vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eOLJW9/rZojjpBgthZDgv9XT0Wqubt+l+UgduLBDd9c=; b=tu2qUMNUGdnCTDclxwcUt+nLKXfBas1B4UrfaItezZjEL3iANWzIcaV9b5YSgLKjqi JmbCnBDcs1uC8jBoJ3gwI6Wr6ZOVHbG7fe6ZUX4TEldyi7tWMXkc73PEPF4+yjUwHGBS ym2hY1R3CatwCrAuJ2d7D9M3ltaooA2TlaBxRFu+5SPYVCh6n1IVsVX/hNPxaLTyPHwc KPz78cA3GjOfirdgaCve5B9RCNfB5XKGHS3ZbTGo0a4afn7KGuF2PW6SspBs0k+0yDwx 3wX+duLRvOxcLMO3DS9WreeIIp53q3nM/I1ZpXgX5iottR5G0kNG6j8g08NoRBiM9h8z TQUA== X-Gm-Message-State: APjAAAWvDA7vsllOXcUuDjmbj8wv0NOpeOCe/qyiIwuCVCsOEKo8ojBF VdJMFpruGX4oUqxwAPdxJbU3/p8o4gbw9hD74g10qQ== X-Received: by 2002:a2e:730c:: with SMTP id o12mr1580530ljc.61.1557491388364; Fri, 10 May 2019 05:29:48 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Vincent Guittot Date: Fri, 10 May 2019 14:29:37 +0200 Message-ID: Subject: Re: [RFC V2 0/2] sched/fair: Fallback to sched-idle CPU for better performance To: Song Liu Cc: Viresh Kumar , Ingo Molnar , Peter Zijlstra , Todd Kjos , Daniel Lezcano , Quentin Perret , Chris Redpath , Dietmar Eggemann , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Song, On Thu, 9 May 2019 at 23:54, Song Liu wrote: > > On Thu, Apr 25, 2019 at 5:38 AM Viresh Kumar wrote: > > > > Hi, > > > > Here is another attempt to get some benefit out of the sched-idle > > policy. The previous version [1] focused on getting better power numbers > > and this version tries to get better performance or lower response time > > for the tasks. > > > > The first patch is unchanged from v1 and accumulates > > information about sched-idle tasks per CPU. > > > > The second patch changes the way the target CPU is selected in the fast > > path. Currently, we target for an idle CPU in select_idle_sibling() to > > run the next task, but in case we don't find idle CPUs it is better to > > pick a CPU which will run the task the soonest, for performance reason. > > A CPU which isn't idle but has only SCHED_IDLE activity queued on it > > should be a good target based on this criteria as any normal fair task > > will most likely preempt the currently running SCHED_IDLE task > > immediately. In fact, choosing a SCHED_IDLE CPU shall give better > > results as it should be able to run the task sooner than an idle CPU > > (which requires to be woken up from an idle state). > > > > Basic testing is done with the help of rt-app currently to make sure the > > task is getting placed correctly. > > I run some test with this set on our (Facebook's) web service (main job) > and ffmpeg (side job). The result looks promising. > > For all the tests below, I run the web service with same load level; and > the side job with SCHED_IDLE. I presented schedule latency distribution > of the main job. The latency distribution is measured with the runqlat tool: > https://github.com/iovisor/bpftrace/blob/master/tools/runqlat.bt > > I modified the tool to only track wake up latency of the main job. > > 4 cases are compared here: > > 1. w/o this set, w/o side job; > 2. w/ this set, w/o side job; > 3. w/o this set, w/ side job; > 4. w/ this set, w/ side job; > > > Case #1. w/o this set, w/o side job > @usecs: > [1] 1705 | | > [2, 4) 1102086 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| > [4, 8) 329160 |@@@@@@@@@@@@@@@ | > [8, 16) 34135 |@ | > [16, 32) 37466 |@ | > [32, 64) 15700 | | > [64, 128) 8759 | | > [128, 256) 5714 | | > [256, 512) 3718 | | > [512, 1K) 2152 | | > [1K, 2K) 882 | | > [2K, 4K) 256 | | > [4K, 8K) 48 | | > [8K, 16K) 2 | | > > Case #2. w/ this set, w/o side job; > @usecs: > [1] 2121 | | > [2, 4) 1251877 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| > [4, 8) 401517 |@@@@@@@@@@@@@@@@ | > [8, 16) 64325 |@@ | > [16, 32) 74352 |@@@ | > [32, 64) 40583 |@ | > [64, 128) 26129 |@ | > [128, 256) 18612 | | > [256, 512) 12863 | | > [512, 1K) 8304 | | > [1K, 2K) 4072 | | > [2K, 4K) 1569 | | > [4K, 8K) 411 | | > [8K, 16K) 70 | | > [16K, 32K) 1 | | > > From #1 and #2, we see this set probably adds a little overhead to > scheduling when there is no side job. But the overhead is clearly very > small. > > > Case #3. w/o this set, w/ side job; > @usecs: > [1] 1282 | | > [2, 4) 260977 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | > [4, 8) 446120 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| > [8, 16) 136927 |@@@@@@@@@@@@@@@ | > [16, 32) 148758 |@@@@@@@@@@@@@@@@@ | > [32, 64) 160291 |@@@@@@@@@@@@@@@@@@ | > [64, 128) 177292 |@@@@@@@@@@@@@@@@@@@@ | > [128, 256) 184573 |@@@@@@@@@@@@@@@@@@@@@ | > [256, 512) 173405 |@@@@@@@@@@@@@@@@@@@@ | > [512, 1K) 149662 |@@@@@@@@@@@@@@@@@ | > [1K, 2K) 120217 |@@@@@@@@@@@@@@ | > [2K, 4K) 80275 |@@@@@@@@@ | > [4K, 8K) 36108 |@@@@ | > [8K, 16K) 11121 |@ | > [16K, 32K) 736 | | > [32K, 64K) 19 | | > > Case #4. w/ this set, w/ side job; > @usecs: > [1] 407 | | > [2, 4) 535378 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | > [4, 8) 795526 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| > [8, 16) 93032 |@@@@@@ | > [16, 32) 89890 |@@@@@ | > [32, 64) 82775 |@@@@@ | > [64, 128) 84413 |@@@@@ | > [128, 256) 84413 |@@@@@ | > [256, 512) 77202 |@@@@@ | > [512, 1K) 66043 |@@@@ | > [1K, 2K) 49276 |@@@ | > [2K, 4K) 30114 |@ | > [4K, 8K) 11145 | | > [8K, 16K) 2328 | | > [16K, 32K) 88 | | > > #3 and #4 clearly showed the benefit of this set. With this set, we see > significantly fewer latency values in the 8usecs+ ranges. > Thanks for running tests with this patchset, your results looks goods with a significant decrease of long wakeup latency. Vincent > Thanks, > Song > > > > > -- > > viresh > > > > Viresh Kumar (2): > > sched: Start tracking SCHED_IDLE tasks count in cfs_rq > > sched/fair: Fallback to sched-idle CPU if idle CPU isn't found > > > > kernel/sched/fair.c | 42 +++++++++++++++++++++++++++++++++--------- > > kernel/sched/sched.h | 2 ++ > > 2 files changed, 35 insertions(+), 9 deletions(-) > > > > -- > > 2.21.0.rc0.269.g1a574e7a288b > > > > [1] https://lore.kernel.org/lkml/cover.1543229820.git.viresh.kumar@linaro.org/