From patchwork Wed Jan 16 09:43:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 155704 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp443580jaa; Wed, 16 Jan 2019 01:43:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN5wl4JZcT+L7vRNxNdLB8kasufiCCasQymff4KOYF9Qgrb26SZ1LbrmTbRzPQlD2c/zSrlx X-Received: by 2002:a17:902:96a:: with SMTP id 97mr8677839plm.45.1547631811138; Wed, 16 Jan 2019 01:43:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547631811; cv=none; d=google.com; s=arc-20160816; b=PWkIzADBqlhkGEP8ACj8iy/Cyg1KjWg7FgnkoVpzoAnI/ilZGVOMCcvmYXLFVIyRJu d7qiAs5SFmuIniqdFxMi3DC2fPXYInhCGMsRQn9O+ZWJBD0jDSdWWK+GYStTKuD26ev9 6nADdXCEXvP4VyJNPCcA5yluE4CZG5zKNZFuSDsMKC5Oh/kQr2yorzjhq4XQxtLIf5AH UKdULSSqmS6Fap10cOCBFDrZAMUml7YE8lSIeartJvMFkT3Vr+94XakWECvhATW8ZMJB jgOebhlKy02NYD5///oxGBziAn4YlhrS+ZKhZekKVQr1lGXWNkyBdQLe59OWm+fwQotA NRUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=IF8O5IB660i5uISr2+XWnKBaqatYQfBFmBwhpEAXDiM=; b=szLrE6XEdBPtHXzSi20kKnbDWml2wVEv+ECpewtwUpDaJUwO6Flw/psUWiNvgWjF1M GM9lU9fQr2yQBi3ZG3KmS9+IlJFmH/h6OvKTex3hs/WodyrsVfNmup/5SpyjhCUA/DL2 yGMZ1kGJdRVirp6mU83CvOxVdkZAqHUTmK7TFbt6YP5vmzTfY4jP5XGpyRbLcQ9QZ7kJ 2mnQTmRlTwqjYQZuKFnRjbD0NO3IDYLM/p6NKJPZYW8iu0kui2+9iB2o//jyDzIA/b0i oX9B5Isq8AIHG0HoFl/b3vIwQ0kqrWsbbBar7X+NsoktqXmijsHjxTo15nCt7DEz6GNl pIRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B+w4gOfS; 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 c64si5640523pfg.239.2019.01.16.01.43.30; Wed, 16 Jan 2019 01:43:31 -0800 (PST) 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=B+w4gOfS; 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 S2391795AbfAPJna (ORCPT + 30 others); Wed, 16 Jan 2019 04:43:30 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:38741 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391777AbfAPJn2 (ORCPT ); Wed, 16 Jan 2019 04:43:28 -0500 Received: by mail-wm1-f67.google.com with SMTP id m22so1251731wml.3 for ; Wed, 16 Jan 2019 01:43:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IF8O5IB660i5uISr2+XWnKBaqatYQfBFmBwhpEAXDiM=; b=B+w4gOfSUmQtZBFsM9IOmNkQO7DxVOMJyoV+4sBrlbm9rsCUJNAEzXtwr+Xu7H306r aGJOXOcC3i5MTCSupFRmglXycFAP41w2nHWTU2VlnyA9vEBWY3Aq6DlULyszojdEO3ex xSc2wnF7RHLAjAsSM7qUDBwIivPfvQ6ymnFvk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IF8O5IB660i5uISr2+XWnKBaqatYQfBFmBwhpEAXDiM=; b=QjSmQCFfp2OVKfnlEkZJNTilQYwHmGLYYPQlolYi3jeTGoreALotbs3Cx3bdNB/bI4 pXMPHA3b4zsHxMvSkCzIQw757CUOSJUyFm3PIKxzrp/OcRbNr4FzgWhQjyZGQxPDCQLK bGiuEHiX/nq1KJg7GDpPJqsXFOF4Gj3JxF83yI4PNjxqjN12yaoZjV5mPb3D+XhLnaIu Yu3j5NbN+JJsdlKKJpfexeJ800NnX0rXwhVNZBveAsGsWGAb08fKnWe0NNCs9jCAKrIV JFx1WafNBW78n3KXcF8OE1h2N+JyEY02QNQzQoCcOecPbiQWfCBhOAQnMTrA6K/mThDG hwrw== X-Gm-Message-State: AJcUukd6HC5mC0ZQSzpFqWKPl6Ou+31rsEjxM9hGhRaeQ21PIyT8cdB/ ItV4uj47QUiNYDb/YG9LfDt9484XC1lStg== X-Received: by 2002:a1c:9d57:: with SMTP id g84mr6899437wme.16.1547631805375; Wed, 16 Jan 2019 01:43:25 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:596d:a8c4:e914:fdde]) by smtp.gmail.com with ESMTPSA id k19sm115996304wre.5.2019.01.16.01.43.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Jan 2019 01:43:24 -0800 (PST) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, dietmar.eggemann@arm.com, Morten.Rasmussen@arm.com, patrick.bellasi@arm.com, pjt@google.com, bsegall@google.com, thara.gopinath@linaro.org, pkondeti@codeaurora.org, quentin.perret@arm.com, srinivas.pandruvada@linux.intel.com, Vincent Guittot Subject: [PATCH v8 3/3] sched/pelt: skip updating util_est when utilization is higher than cpu's capacity Date: Wed, 16 Jan 2019 10:43:11 +0100 Message-Id: <1547631791-16018-4-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547631791-16018-1-git-send-email-vincent.guittot@linaro.org> References: <1547631791-16018-1-git-send-email-vincent.guittot@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org util_est is mainly meant to be a lower-bound for tasks utilization. That's why task_util_est() returns the actual util_avg when it's higher than the estimated utilization. With new invaraince signal and without any special check on samples collection, if a task is limited because of thermal capping for example, we could end up overestimating its utilization and thus perhaps generating an unwanted frequency spike when the capping is relaxed... and (even worst) it will take some more activations for the estimated utilization to converge back to the actual utilization. Since we cannot easily know if there is idle time in a CPU when a task completes an activation with a utilization higher then the CPU capacity, we skip the sampling when utilization is higher than cpu's capacity. Suggested-by: Patrick Bellasi Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 14 +++++++++----- kernel/sched/sched.h | 7 +++++++ 2 files changed, 16 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 9332863..2262c8a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3639,6 +3639,7 @@ util_est_dequeue(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep) { long last_ewma_diff; struct util_est ue; + int cpu; if (!sched_feat(UTIL_EST)) return; @@ -3673,6 +3674,14 @@ util_est_dequeue(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep) return; /* + * To avoid overestimation of actual task utilization, skip updates if + * we cannot grant there is idle time in this CPU. + */ + cpu = cpu_of(rq_of(cfs_rq)); + if (task_util(p) > capacity_orig_of(cpu)) + return; + + /* * Update Task's estimated utilization * * When *p completes an activation we can consolidate another sample @@ -5541,11 +5550,6 @@ static unsigned long capacity_of(int cpu) return cpu_rq(cpu)->cpu_capacity; } -static unsigned long capacity_orig_of(int cpu) -{ - return cpu_rq(cpu)->cpu_capacity_orig; -} - static unsigned long cpu_avg_load_per_task(int cpu) { struct rq *rq = cpu_rq(cpu); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 4c506ea..455745e 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2230,6 +2230,13 @@ static inline void cpufreq_update_util(struct rq *rq, unsigned int flags) {} # define arch_scale_freq_invariant() false #endif +#ifdef CONFIG_SMP +static inline unsigned long capacity_orig_of(int cpu) +{ + return cpu_rq(cpu)->cpu_capacity_orig; +} +#endif + #ifdef CONFIG_CPU_FREQ_GOV_SCHEDUTIL /** * enum schedutil_type - CPU utilization type