From patchwork Thu Apr 26 10:30:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 134465 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2075198lji; Thu, 26 Apr 2018 03:31:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx49xd4KOhLc+E1Z8cmUmXdP6/bxLY664NoxAqstpaMEej3zl5OdMhi6oBIeNePTk3uw2z5lt X-Received: by 2002:a17:902:aa0b:: with SMTP id be11-v6mr33799392plb.179.1524738678728; Thu, 26 Apr 2018 03:31:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524738678; cv=none; d=google.com; s=arc-20160816; b=u48HGQlxTf3lGZOBCRgTdqxjX6KCx15+yX6xtj1ZupeYDSuro+8Z/jF9nHVjA5PiWk Ky/Ep4qK0fLnRtrjerfKHuqJmS8AUGmyqM7A/Jyl3CvnV+6xeuQQ0Dz5PFpNmhdYTBmS XjTGvKwCZ3AmP5KnRRsa46VuUFABV3ApI9Qa53YjmY0lJeW1m6A2LbqboVhH/Zvr8xv/ WaKSnkfH6OqNuQIYqWD9OIBbrosAQ2EENM0zjFYg1rLhs1S1tExtnmbif0VZOrMSGw8v J0Y4KK39543a0dDjxIpI5ILd5JzasTvfRuZMQrWm66Bb9rfB4jptRQxA50C4H8a1jlP7 KZ/g== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=OPXnaez+tfu2j/wj+c0V3ZMn7fsthJNEBJ5Mde8rA20=; b=MD54RY51ALMYQGYoKBXyFdzFUsokBOf2o/p1ySKYmXXk6a13xYU0Q6N0FSNsDDuQz7 zIFSZnQ6eafPLnvWmnlgx8JilJBrQfZeJlf798hPiV2NbCruXDzejhC1n15PpcgjqLwe ufBC936hMR8xxSx10O85jQkWHU6vuUbzgM0ZCEcrJjLpt3rA/kqt9EAStXbfRSXHrQsM wCo0qvBPqMzshrC00sovqhNh9uTjPhQydMgkpuSOy03gRu5JG1VD+9pKWT7yPUs4QxmG j0TxSnQNY73mxTEFP2/s2/g/PpiQbU0E2/VVpv3l6hlzVQHl2tS+C8nIHXQqWdA1UP1F RDRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EUYptTe0; 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 k15si1643943pfi.54.2018.04.26.03.31.18; Thu, 26 Apr 2018 03:31:18 -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=EUYptTe0; 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 S1755433AbeDZKbP (ORCPT + 29 others); Thu, 26 Apr 2018 06:31:15 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:39691 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755158AbeDZKbH (ORCPT ); Thu, 26 Apr 2018 06:31:07 -0400 Received: by mail-pg0-f65.google.com with SMTP id b9so15597794pgf.6 for ; Thu, 26 Apr 2018 03:31:07 -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:in-reply-to:references :in-reply-to:references; bh=OPXnaez+tfu2j/wj+c0V3ZMn7fsthJNEBJ5Mde8rA20=; b=EUYptTe0mL65zvBJS5t2yvGwniUhML3JivAFo5pIALOTETbHoz7IsmSpxmRnv7uGlO X+QiJyWih3rDYYt4LkP1JBgtJI3Ph/swlVavzHkVgHyoV4ecVLqrdtvjjTNFj2gQjGxq NIKRaV8oi4GqMVzr/Qw/WOTWPdjE2Xp3Qf3lM= 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:in-reply-to:references; bh=OPXnaez+tfu2j/wj+c0V3ZMn7fsthJNEBJ5Mde8rA20=; b=aZTxXyfrlKfaLszjcZQlG67ASHwYAZw6PZBOIW6SUFJc57kBLUrzCxtrzOhOTff0Eb ny+XlmmfSYlF4nKqZcr30bySiL0A1z54aa6e71t47nMc6NzyD59dYdawU+W4EKLxOG0H YyjaBhFiZiUwS/mf3hsiyQ4I/1Dl/2fbLgCVw8lC2lD5TPYPdUMotAoY+rIA1jJMpZVE ofjt/p/Uq9D6oIANKyR3sqk3+H4x7SbyRfyL9EZv52cX9iWNLa+jl906tyPK2hnCd6WR xaxZAyNOxNotPrzZ0XNRYGPJirQd4wVtLofHWm8QAejeKP/t+K2seaJl5tcuc9mL8hLG zwoA== X-Gm-Message-State: ALQs6tD00h/bsaM42/PpQMz4sq8oV58DLxOtvsv/DQ6IFMPnltXDBK5i rMlu1cS3p6Rbx3do67rPYHl51A== X-Received: by 10.101.91.204 with SMTP id o12mr24565075pgr.81.1524738666897; Thu, 26 Apr 2018 03:31:06 -0700 (PDT) Received: from localhost ([122.172.61.40]) by smtp.gmail.com with ESMTPSA id p126sm8815570pga.28.2018.04.26.03.31.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Apr 2018 03:31:06 -0700 (PDT) From: Viresh Kumar To: Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] sched/fair: Avoid calling sync_entity_load_avg() unnecessarily Date: Thu, 26 Apr 2018 16:00:51 +0530 Message-Id: X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: <20831b8d237bf3a20e4e328286f678b425ff04c9.1524738578.git.viresh.kumar@linaro.org> References: <20831b8d237bf3a20e4e328286f678b425ff04c9.1524738578.git.viresh.kumar@linaro.org> In-Reply-To: <20831b8d237bf3a20e4e328286f678b425ff04c9.1524738578.git.viresh.kumar@linaro.org> References: <20831b8d237bf3a20e4e328286f678b425ff04c9.1524738578.git.viresh.kumar@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Call sync_entity_load_avg() directly from find_idlest_cpu() instead of select_task_rq_fair(), as that's where we need to use task's utilization value. And call sync_entity_load_avg() only after making sure sched domain spans over one of the allowed CPUs for the task. Signed-off-by: Viresh Kumar --- kernel/sched/fair.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) -- 2.15.0.194.g9af6a3dea062 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 84fc74ddbd4b..5b1b4f91f132 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6199,6 +6199,13 @@ static inline int find_idlest_cpu(struct sched_domain *sd, struct task_struct *p if (!cpumask_intersects(sched_domain_span(sd), &p->cpus_allowed)) return prev_cpu; + /* + * We need task's util for capacity_spare_wake, sync it up to prev_cpu's + * last_update_time. + */ + if (!(sd_flag & SD_BALANCE_FORK)) + sync_entity_load_avg(&p->se); + while (sd) { struct sched_group *group; struct sched_domain *tmp; @@ -6651,15 +6658,6 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f if (unlikely(sd)) { /* Slow path */ - - /* - * We're going to need the task's util for capacity_spare_wake - * in find_idlest_group. Sync it up to prev_cpu's - * last_update_time. - */ - if (!(sd_flag & SD_BALANCE_FORK)) - sync_entity_load_avg(&p->se); - new_cpu = find_idlest_cpu(sd, p, cpu, prev_cpu, sd_flag); } else if (sd_flag & SD_BALANCE_WAKE) { /* XXX always ? */ /* Fast path */