Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4158383yba; Wed, 17 Apr 2019 05:57:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTIU6h+XUgxsY3BdtXwN2slRddFFGN4sOkcd1mGi8GcCOKRDCZJFUPawszbHKDrVZegrbQ X-Received: by 2002:a65:6091:: with SMTP id t17mr46012363pgu.328.1555505876368; Wed, 17 Apr 2019 05:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555505876; cv=none; d=google.com; s=arc-20160816; b=V6p5gI1NWwHFnTvmSTiejxLkzchmHhMM3vDbLTKO7drWKdnJ8HCAKPCub8x4rJ853U 8/TrRJcMN0qch52OxV+fiXzIYxqL2mER8N+OatxI+el8bl+mYWLgOAXVdZiCjfjo1OmB yGiBRT9DHwoHU1fAnKL1P9059pPJHhBxpoYiJG9HakX4dttGeG2UbSR+Yle/FWb046Uj GnoZj5K1bel0LBEcGc0K5T3Zg54F7lO0pOajuDT7DIq7vr04ZJTqwIWZIa2fpwWbXtjT UGFBgddLqunm+l3Blenapi9RRdLvOaZxAWfKzLt0Uv/lxmE0EL14Fg88EmGmLYE2fufN pbcQ== 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=12mqcnOOt0vufAP9KYkBeANamYksA51AvFl5IrppBvM=; b=fEaX4JQtMb9oSYbU1R/GeCQPgHJZjqopRWggHSrNhyWyvaJMFxsqnP2nzeUWM9JBmf R1Ns2BnbfVg3Ri3xcuqD2NMijnv9icKQPV7+SmvHCiIQkjdq+NxWbg+nRWHse7H77ZJC CfEup41i4+SSDeYnYEynFkxkb/kuEOKrn/9kd7zCvBrki+f3tNOkxtj9JWWoYvF7pxMj rbFzVYPUZhu8YbEYjU6/gqWC8vnt9+7UTfT2ISiJyLqpgJ5cDDDwbifYo/B06FYPdNe8 2Eavtn2V9jBSMkOadaY1VtY9bnvJSPFL/4ZkdxjoKR8oJLcegE3NdwEWp1aBpovoAuJ5 ZzwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pfe/NuSF"; 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 u2si28003805pgc.250.2019.04.17.05.57.40; Wed, 17 Apr 2019 05:57:56 -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="pfe/NuSF"; 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 S1731743AbfDQM4n (ORCPT + 99 others); Wed, 17 Apr 2019 08:56:43 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:38201 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729356AbfDQM4n (ORCPT ); Wed, 17 Apr 2019 08:56:43 -0400 Received: by mail-lf1-f66.google.com with SMTP id v1so9488262lfg.5 for ; Wed, 17 Apr 2019 05:56:42 -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=12mqcnOOt0vufAP9KYkBeANamYksA51AvFl5IrppBvM=; b=pfe/NuSFFYnWmFIRCbwz4QpMLdrJfNI0taBbC3izuZfSInrQ4v1yP9XL29Eihd5UvT JsdCq+sHbR6vXcdUULWvUIoiDbpnNewscpug90mCJERb9SpdPG1B7ca7QAq3ry0e+up8 urgLrbPMgbNUIVBB8FsW+1X0GoAsvFZaevqYxkNzI/1wooLzpHPQQD202eQ/wHdihbyX W373q8NWTR3qNPzZECNdhdAokM3IK7RyEwA6+WIO4NfyXVNYUzc3AtDRzzQNo0b6jNAA 2eSkf585DR5oIim3ACRcvlTQ7BuQ3RYTHcbxOYza9ycMJlQSyciLgqgLom1CflxcySBE daLA== 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=12mqcnOOt0vufAP9KYkBeANamYksA51AvFl5IrppBvM=; b=D8oTZ9qWAouTZ7+ZQYAFQkyLVjwFAmBTt8A3aSH4vMKWVhodilWlljkmP0vjC71740 s9VNR3lptAEQm3lhYgnsZxznjmPnKOiSYdb+QSUFjHrTtAf4qVxghGu47IYxdHx8qubK /Om7epNZ9rpSp3waZAq7m551jv20rFeMDbe/+xLoieGVUyna48VbgP8yh79koeCUJ23a Hk3gqX0DcngA62atSQDlNIiHyjw2rI/e8z7s0+EC6iYbvuMOezM6mCwWmJaSHH/3Q7h5 VAkARHOIjofbxMYmWZ9pQynoCfaCktzWuesSPrqBsS6YeBvZmUdgJAQAKO9llbQVAzL3 unSQ== X-Gm-Message-State: APjAAAUdXB56YBqiSj26ungEMteaxxVwckasC5cFMlFs373ycVR7Sgqg /8FQKZ+czHWN5ChUHTqEWbdQwFKJ5PRoFVhcz2dRiQ== X-Received: by 2002:ac2:41cc:: with SMTP id d12mr40079726lfi.73.1555505801140; Wed, 17 Apr 2019 05:56:41 -0700 (PDT) MIME-Version: 1.0 References: <20190408214539.2705660-1-songliubraving@fb.com> <20190410115907.GE19434@e105550-lin.cambridge.arm.com> In-Reply-To: From: Vincent Guittot Date: Wed, 17 Apr 2019 14:56:29 +0200 Message-ID: Subject: Re: [PATCH 0/7] introduce cpu.headroom knob to cpu controller To: Song Liu Cc: Morten Rasmussen , linux-kernel , "cgroups@vger.kernel.org" , "mingo@redhat.com" , "peterz@infradead.org" , "tglx@linutronix.de" , Kernel Team 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 Wed, 10 Apr 2019 at 21:43, Song Liu wrote: > > Hi Morten, > > > On Apr 10, 2019, at 4:59 AM, Morten Rasmussen wrote: > > > > > > The bit that isn't clear to me, is _why_ adding idle cycles helps your > > workload. I'm not convinced that adding headroom gives any latency > > improvements beyond watering down the impact of your side jobs. AFAIK, > > We think the latency improvements actually come from watering down the > impact of side jobs. It is not just statistically improving average > latency numbers, but also reduces resource contention caused by the side > workload. I don't know whether it is from reducing contention of ALUs, > memory bandwidth, CPU caches, or something else, but we saw reduced > latencies when headroom is used. > > > the throttling mechanism effectively removes the throttled tasks from > > the schedule according to a specific duty cycle. When the side job is > > not throttled the main workload is experiencing the same latency issues > > as before, but by dynamically tuning the side job throttling you can > > achieve a better average latency. Am I missing something? > > > > Have you looked at your distribution of main job latency and tried to > > compare with when throttling is active/not active? > > cfs_bandwidth adjusts allowed runtime for each task_group each period > (configurable, 100ms by default). cpu.headroom logic applies gentle > throttling, so that the side workload gets some runtime in every period. > Therefore, if we look at time window equal to or bigger than 100ms, we > don't really see "throttling active time" vs. "throttling inactive time". > > > > > I'm wondering if the headroom solution is really the right solution for > > your use-case or if what you are really after is something which is > > lower priority than just setting the weight to 1. Something that > > The experiments show that, cpu.weight does proper work for priority: the > main workload gets priority to use the CPU; while the side workload only > fill the idle CPU. However, this is not sufficient, as the side workload > creates big enough contention to impact the main workload. > > > (nearly) always gets pre-empted by your main job (SCHED_BATCH and > > SCHED_IDLE might not be enough). If your main job consist > > of lots of relatively short wake-ups things like the min_granularity > > could have significant latency impact. > > cpu.headroom gives benefits in addition to optimizations in pre-empt > side. By maintaining some idle time, fewer pre-empt actions are > necessary, thus the main workload will get better latency. I agree with Morten's proposal, SCHED_IDLE should help your latency problem because side job will be directly preempted unlike normal cfs task even lowest priority. In addition to min_granularity, sched_period also has an impact on the time that a task has to wait before preempting the running task. Also, some sched_feature like GENTLE_FAIR_SLEEPERS can also impact the latency of a task. It would be nice to know if the latency problem comes from contention on cache resources or if it's mainly because you main load waits before running on a CPU Regards, Vincent > > Thanks, > Song > > > > > Morten >