From patchwork Thu Jun 14 10:33:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 138537 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1931018lji; Thu, 14 Jun 2018 03:33:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIFtZBcViqZI1GeurHJ6HrFyxJEchnfRpeXSjjOHD8vL8/53Oqclf99QECu5UYR72OxgElY X-Received: by 2002:a65:4146:: with SMTP id x6-v6mr1807922pgp.221.1528972397488; Thu, 14 Jun 2018 03:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528972397; cv=none; d=google.com; s=arc-20160816; b=ifUC+CRSG4GW0r6shwInLnV6lvy1wZqN+7g2uWD7J28x9EAHhzq/I2l9rIqwFheF1y rj2zyD3mY50uVwxyaft56yBhpywNM7zFVKNOlnQlnhrdv6rxeI9TcPKpDO2tg6kzCzbf rRCP6UHzhdm8mVSVq+mz7VHQPr5XQ7zhImgV/geZZeWNgfXF1WDjyt5Lx5JR9YydxwsT PfH0Va4EUXPNS1otvmFfeu99tsSvWbDQOi+GVuNMAtnWaPw/imZK9+dQwXy1midX49gH uGBMEVvMIzPF5bQx9UOkkZba3Cd09dRf5MFGd637GC2mDtjIUR7XvRUmUEoBMEvbegIZ JQNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=BNV/ih/tOFiOY23P07soJ7dY8Nrc7hPd77TJUNr/gkY=; b=Y0GqxNORkRAoNRb+RlHoJU99a49sp671Ltf8IZYXu2khvfEiUd5Xkmui1uTgbguKPH dO2tCPyG4EvqnW3udAk90TGEsvqYdRwIV2Y4yICeBYsypTVkh1oMuTXaxTZjsRrrS6e2 sBEYuJstQi0ZB8FCaT3YDcfswoyxcvXYZD5vF5NFwVaGpQuG7whg5xCpvfv9pjejcm+C Q4bssuiW7HAhIehn7XhryC6YB2TbWvbaxcBMzFFR6tzOSUjrCIaoDOrA/iMMSFCxEa8P tIxuOSCAiM2vEMrPX+chO69WfsahjhmnUYb15uewejjSR6aX5bKrtxZ9k9ERT98XqMQR kF6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U4eXILZb; 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 f13-v6si3965693pgv.374.2018.06.14.03.33.17; Thu, 14 Jun 2018 03:33:17 -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=U4eXILZb; 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 S1754886AbeFNKdO (ORCPT + 30 others); Thu, 14 Jun 2018 06:33:14 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:51609 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754724AbeFNKdN (ORCPT ); Thu, 14 Jun 2018 06:33:13 -0400 Received: by mail-wm0-f65.google.com with SMTP id r15-v6so9680320wmc.1 for ; Thu, 14 Jun 2018 03:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=BNV/ih/tOFiOY23P07soJ7dY8Nrc7hPd77TJUNr/gkY=; b=U4eXILZbNhk9GM6A74uUo5UEIyDvqx90Cns4uKdgJVk4KkO5cKSCSqrRGh3BNa5Wp8 DQYYqQ4jWpfuOxRCIVME/FYXpqeUrEKzqyq8Vz7A+XTzgwg4XqwdAtq1CL5vIAV/NjcG o9uh4VKG6r6hkFmqCAzVQWZ7ck2uP7h30n2rc= 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; bh=BNV/ih/tOFiOY23P07soJ7dY8Nrc7hPd77TJUNr/gkY=; b=Pgr8J13lihZfdc2Un9VpVkdQgoKBPmtRRtGWqPCjP2FwNkGLDeR6E4ONvHkGFQCuVL ZiUOmhcfy/6PlVzF0lyck9+UsdfNEvVJ30UYCToIf25tqt640alGqrHpydi/jWERPcSO mHQg323uQL7HVEnlgiMXKjbs8V/KlhTb6XgjlS3B8aLrE+IO4z2nJVH7lHqdSJoPlXy3 Klgy3VPs4q0gl6T9b0+lZmdkul0lzHbH3/fZw9ZOFZ/hz1X8NpTiSEz+/S6ncffAO9pB vekKstYoezf8GJHA4o1R4h5v8tJLlN3/YFBrR8TAowFj12iuD0ekSwxmFLEcTzm88ys5 sCVw== X-Gm-Message-State: APt69E0CV0tNdHTvUp5u+GOQhKdHiPIiYZdXJ1n8knJaW+COW4dzoUpM QgunbkTGTPysqjohgd1SN/yG0A== X-Received: by 2002:a1c:f308:: with SMTP id q8-v6mr1353901wmq.6.1528972392110; Thu, 14 Jun 2018 03:33:12 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:f:6020:c494:f0e:88b7:c1b]) by smtp.gmail.com with ESMTPSA id u15-v6sm7389975wma.37.2018.06.14.03.33.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Jun 2018 03:33:11 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, patrick.bellasi@arm.com Cc: Vincent Guittot Subject: [PATCH] sched/util_est: fix util_est_dequeue() for throttled cfs rq Date: Thu, 14 Jun 2018 12:33:00 +0200 Message-Id: <1528972380-16268-1-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a cfs_rq is throttled, parent cfs_rq->nr_running is decreased and everything happens at cfs_rq level. Currently util_est stays unchanged in such case and it keeps accounting the utilization of throttled tasks. This can somewhat make sense as we don't dequeue tasks but only throttled cfs_rq. If a task of another group is enqueued/dequeued and root cfs_rq becomes idle during the dequeue, util_est will be cleared whereas it was accounting util_est of throttled tasks before. So the behavior of util_est is not always the same regarding throttled tasks and depends of side activity. Furthermore, util_est will not be updated when the cfs_rq is unthrottled as everything happens at cfs rq level. Main results is that util_est will stay null whereas we now have running tasks. We have to wait for the next dequeue/enqueue of the previously throttled tasks to get an up to date util_est. Remove the assumption that cfs_rq's estimated utilization of a CPU is 0 if there is no running task so the util_est of a task remains until the latter is dequeued even if its cfs_rq has been throttled. Fixes: 7f65ea42eb00 ("sched/fair: Add util_est on top of PELT") Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) -- 2.7.4 Reviewed-by: Patrick Bellasi diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e497c05..d3121fc 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3982,18 +3982,10 @@ util_est_dequeue(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep) if (!sched_feat(UTIL_EST)) return; - /* - * Update root cfs_rq's estimated utilization - * - * If *p is the last task then the root cfs_rq's estimated utilization - * of a CPU is 0 by definition. - */ - ue.enqueued = 0; - if (cfs_rq->nr_running) { - ue.enqueued = cfs_rq->avg.util_est.enqueued; - ue.enqueued -= min_t(unsigned int, ue.enqueued, - (_task_util_est(p) | UTIL_AVG_UNCHANGED)); - } + /* Update root cfs_rq's estimated utilization */ + ue.enqueued = cfs_rq->avg.util_est.enqueued; + ue.enqueued -= min_t(unsigned int, ue.enqueued, + (_task_util_est(p) | UTIL_AVG_UNCHANGED)); WRITE_ONCE(cfs_rq->avg.util_est.enqueued, ue.enqueued); /*