Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1333406yba; Thu, 9 May 2019 14:55:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvObd0nQ7rg0Z5GAYI7IQ7uW9+T8OmYkAIzxejMPS94GVKO2dKeWf4NRQyFQETPai+6CYK X-Received: by 2002:a63:e94e:: with SMTP id q14mr8746181pgj.110.1557438954647; Thu, 09 May 2019 14:55:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557438954; cv=none; d=google.com; s=arc-20160816; b=Rx1lNNFY1lxfIfzCEo4b3KgqFJQgAt4crxU3LxaiHAJTwlfcqIqHEUxBSuQm8WyM5m ThnpuC6YMjJILJDLd+PHQk0zhgG5qlYZi81usrGOf9gkXvCXTRc0BZGwP30vi/BSp31k Dg5i+/bI41kydvqAPF6E6KPVoljhbL00GIPfp2JHP2iFQbGZrNH98FOrKbGJhtA6GpV0 G4ZvRjBKtPhSu0I6PRK4zmfncwidlPo8o9ogD0zmd79h2dsol6OHKQWuZEuRHs0UidSx 8BBwhefdHFqOWcr/ZDDCDzCcQJR68HbAXqdWDJEAPHod3WsN+XtEDrPyCiAraByw2vMl 50NA== 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=H1Y5CP3udzISeDRQqWhtzmQN2i9kFihKEw0JXstWj9M=; b=jLns8WyjawsIvQC0psYK/PN6ukQQUri9uEkFIcO25Ti/41pbNDwSn8k9yzUvUUA3UD poZnXdLNWgy0ACvZrKa1XSNTdX0cNaGYgUQHGQKgw3KW35Ap1Etrcv39nwwHxCYWML8z 83E1UOqer88HIWdAB9hqmLaln5odQTNDCpibXJ55Wl4JWkfrRx0Nshx6u0myA12nYMuD dGgQC0EjMOsxM6HH7gy5DQkd6ik7BBIZfwHhkpjnKgmW1N8tzDl3rmspzphSsUhmmhS6 IYzUVwD4UFM7c+vVp2xh3bnc5P4ChwcRpaKzjL2j0hhQNDOOCRIu1wn5ezRFwAEFHyJ0 W/Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="pL/Me8kr"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h189si4606293pfc.283.2019.05.09.14.55.37; Thu, 09 May 2019 14:55:54 -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=@gmail.com header.s=20161025 header.b="pL/Me8kr"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726790AbfEIVys (ORCPT + 99 others); Thu, 9 May 2019 17:54:48 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:42933 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbfEIVys (ORCPT ); Thu, 9 May 2019 17:54:48 -0400 Received: by mail-qk1-f193.google.com with SMTP id d4so2459286qkc.9 for ; Thu, 09 May 2019 14:54:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=H1Y5CP3udzISeDRQqWhtzmQN2i9kFihKEw0JXstWj9M=; b=pL/Me8krcAphJ67aosTGp+j/4PRI9lioxkeisVWldcV/Dvs3IsrnsVX0HvwN/dxIAF b8DftkernysTHwUvRYe4WvTmlqDQRYhnFMu6GyXGv4Y5PDt9Q56I/xZTnGu9pc2m46py JNOa4j8GWjmwqBNKk3cnh7QkBKjTGSGnGK1dNOq+4CC0QgZduczxm1VVNf17nidKPCZX mT/ZNXMbB7zLfeRXep+mupiqQauOgpEGVIZjc9lRhhKPfvX0Ug2Q9FlcRBGNRA3kuJRX 9XsZJB5n1Bx5csGHKcj4BFefSBd8mLVVgRf5bLKhWK/TfPtaAt+ibXDoKsI4Nx/FBolt 8CFA== 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=H1Y5CP3udzISeDRQqWhtzmQN2i9kFihKEw0JXstWj9M=; b=k07rqsFyIad1DgKFjCzMR96F+psErLv8M3UOLnlHrz69DwlV58Yp0dpgA+QKO10Wo7 PjCP2gB6Jf6gvEKKXLBUN/50hOE1nEsihnvLfgSt/FX0D56d1n6hDvvS4qJTGBUoTQ9G R7NFcCnG9vfngBfGvX+giOrHKOtg4lt7F4WwX5MxwhlZhi1t9HdO65l6fVCOMvruZfuX /NEVRBkefPB1S1R0qLKVKpNScPbSe5KzVb3EK4gG1B4lVOsfBCQcJGydv91xrfJNd+rk w+QVGRBiTM1mbJCqG5rXSY0pCdJJZX1lZav4/Ezx51NyhavJy+/nHTz3RyFvEfEdbuIW QcTw== X-Gm-Message-State: APjAAAVfW8CJPasI0pJH2IxO9u2gjLqD2JbXaK30eLHlfJdn2Kd22xOV diTEWunRrtw416cI8v291fb5g1+hSv15HOBT62c= X-Received: by 2002:ae9:ea10:: with SMTP id f16mr5536712qkg.5.1557438886786; Thu, 09 May 2019 14:54:46 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Song Liu Date: Thu, 9 May 2019 17:54:35 -0400 Message-ID: Subject: Re: [RFC V2 0/2] sched/fair: Fallback to sched-idle CPU for better performance To: Viresh Kumar Cc: Ingo Molnar , Peter Zijlstra , Vincent Guittot , tkjos@google.com, Daniel Lezcano , quentin.perret@linaro.org, chris.redpath@arm.com, Dietmar.Eggemann@arm.com, 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 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, 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/