From patchwork Fri Aug 31 13:58:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 145646 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp815056ljw; Fri, 31 Aug 2018 06:58:41 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZdYrOPRd1doDMLcEwYQs0IAVf/HGJ4Owm0kBZTdtmy/16Hf49eaoD3lMP7j4D6DqhqPnef X-Received: by 2002:a62:a6cc:: with SMTP id r73-v6mr15979907pfl.60.1535723921280; Fri, 31 Aug 2018 06:58:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535723921; cv=none; d=google.com; s=arc-20160816; b=aLKQNQEuMJzRy1ydumAap673N+RsfXUQEg71UgNal/FVDH76yuNMqywjCu31ooXPFa xEyonZydyOA87ZVHO1tFWGelzkUScfyh6pnQlZlAAMW6XiybyDSV9E+MFfG+UnJHialY sW2c3urj8DtKBFV4HxyPFKv1WBKFry1uq/sgjrHd5TpBYY7XHK0zn71xtKWfO1MLsInF XYakMW+CD/wNCUOTzZpvLVp0LjN3gzNjxWkrvYM1JZ3j1FJw71BzecROikknLRobh+tG QEXQmasItVn87lZz0nmYSsdfmMOtEUwyablGrUgWPYnqykjy1+SYoc9/OCK17vRRScan XrVw== 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=P/2PE9fwa3N0IyuSfjUhgXsWHAdCpdTQgP8rRp1wPbo=; b=f6H1xdFDPW9mDbwgi7eqDBEF12JFcd6mwKREwKOWSKrN48vAMevK1FrTtdxkHf3T/L JpuQaTaizacF5QeJqClvwqvp6Y9gC8ZjHoelHqNzuCfXqIshpNsOjvTqKA9v4JPGre06 I3n5qDA+HDlyMzF9uYr5uVVKwi1furqFnYq2PzD3CWvS+G4CCw9XpvJDi4g/okM2Fcw1 qwQkQdBAhb+Vb2/owh6pVvvcMJPH8SEvc/QzaLIOO5sdjfTNWRykMBgVqfcS+D8yEMiH TvfE5SbYVDcptYHSyhXUEQcyZyVNM0mp3X9tnN7MnPkV6BbR6i+m0WlSu88dGx6rbYTY dG/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PLdm1o3Y; 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 q2-v6si6860136pgs.108.2018.08.31.06.58.41; Fri, 31 Aug 2018 06:58:41 -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=PLdm1o3Y; 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 S1728606AbeHaSGP (ORCPT + 32 others); Fri, 31 Aug 2018 14:06:15 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39508 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727432AbeHaSGP (ORCPT ); Fri, 31 Aug 2018 14:06:15 -0400 Received: by mail-wr1-f68.google.com with SMTP id o37-v6so11315188wrf.6 for ; Fri, 31 Aug 2018 06:58:38 -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=P/2PE9fwa3N0IyuSfjUhgXsWHAdCpdTQgP8rRp1wPbo=; b=PLdm1o3YV6tpIAB273/DtHdIpZoARxib7r+5+fw4WbAflOkQi5tqxq2AOwTNPtxF4h ALTxTnoo3OhsShjFWeVmpinZf+eBG4kuhG0etUQP9hx3uN0CWwOXMxJ/38XqfTXE6oP7 RK2QIURdxUD0xBjqOF9JeSp/SHr/5DR6csL5w= 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=P/2PE9fwa3N0IyuSfjUhgXsWHAdCpdTQgP8rRp1wPbo=; b=R+jKlAMiWp/z8lz9eyXRBjeV9KnJF99bIFgS4nnlA3y+qCf0bPRZCeEW0imWjdKKYQ VrvtDjRjAK6L6iPAtM7Dc+FaJBNjTObQNGOtX1si8teKU0xyvBIsrWr8UapvJwd9JSmh fQv3QdHM8yxJJBJiVW+JaFyMumzELz9/SOcFaLnwfytq7hG9ss8wdfVQUtRYI6kQjENi TNW6XXKlTqeeIqDe9Q8T0Yk5Ykl0gaF0V4QAtk1kHNmHud72h853Xg2R3TptwXzej8qC KgKhPsy0z3ZGDa7OJDoMuyN+Th9+DL9kGlTxpTFY2xRSLEEm47KhdiLRZ9AZejPfkj6X ekvQ== X-Gm-Message-State: APzg51CdHtyM3khkdl0+oC5cqmVDQZywb47W8Htpsv7drJ40IBZsyhWN CPPpC5+gJBBF2c5wYqNGcjLVhw== X-Received: by 2002:adf:fd90:: with SMTP id d16-v6mr11341233wrr.276.1535723917260; Fri, 31 Aug 2018 06:58:37 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:f:6020:840f:e0ae:74c6:97dd]) by smtp.gmail.com with ESMTPSA id q21-v6sm5090217wmq.3.2018.08.31.06.58.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Aug 2018 06:58:36 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: Vincent Guittot Subject: [PATCH] sched/pelt: fix update_blocked_averages() for dl and rt Date: Fri, 31 Aug 2018 15:58:28 +0200 Message-Id: <1535723908-10779-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 update_blocked_averages() is called to periodiccally decay the stalled load of idle CPUs and to sync all loads before running load balance. When cfs rq is idle, it trigs a load balance during pick_next_task_fair() in order to potentially pull tasks and to use this newly idle CPU. This load balance happens whereas prev task from another class has not been put and its utilization updated yet. This may lead to wrongly account running time as idle time for rt or dl classes. Test that no rt or dl task is running when updating their utilization in update_blocked_averages(). We still update rt and dl utilization instead of simply skipping them to make sure that all metrics are synced when used during load balance. Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 309c93f..a1babaf 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7262,6 +7262,7 @@ static void update_blocked_averages(int cpu) { struct rq *rq = cpu_rq(cpu); struct cfs_rq *cfs_rq, *pos; + const struct sched_class *curr_class = rq->curr->sched_class; struct rq_flags rf; bool done = true; @@ -7298,8 +7299,8 @@ static void update_blocked_averages(int cpu) if (cfs_rq_has_blocked(cfs_rq)) done = false; } - update_rt_rq_load_avg(rq_clock_task(rq), rq, 0); - update_dl_rq_load_avg(rq_clock_task(rq), rq, 0); + update_rt_rq_load_avg(rq_clock_task(rq), rq, curr_class == &rt_sched_class); + update_dl_rq_load_avg(rq_clock_task(rq), rq, curr_class == &dl_sched_class); update_irq_load_avg(rq, 0); /* Don't need periodic decay once load/util_avg are null */ if (others_have_blocked(rq))