Received: by 10.192.165.148 with SMTP id m20csp3269287imm; Mon, 23 Apr 2018 03:45:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx49GrPHe0brg12uO1LmUcH8SytNBWT1uu9SG2udWuiH1RQGy4SE7RrmmXX/g1OqrWPdxqOJV X-Received: by 2002:a17:902:b209:: with SMTP id t9-v6mr20414021plr.105.1524480348069; Mon, 23 Apr 2018 03:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524480348; cv=none; d=google.com; s=arc-20160816; b=sGMNleGrk2jJctLdoQAQS+pMzkHOR9E7BpxwxfJ4IEEJ32UJYTwFqHUlPZ7z10jNs3 eByLvPN/PD3u7eLZEmEFlj/RcX6VMx+ZiCAnI0Xu4js82kjDGCutCS3BDbIVYINwCKbO FVSTIWHwILUs5RezsljVkY4yFqgEUeKkrTat9yAUMnABIuAlPoBGqXOrwSd8o9k63xBK J7MwpRLFk+nTGmOLxsRWTwFtCJBG9OTSVxmraxfME8uQzAhjDrC49UQUG1i+qSJ4wudA 8L4zRCh+qsjZHxUrjMT0Has5LlO5Ybi3PkvKbnvcp9Vi8aOHjHOxKXTgtPwbcdgYJq+e fawA== 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=Zas8Z0mkGZq5gSVHdqXLSh0vM3XNzZ95VpVtHDIqi/I=; b=WLP5E2WqGqCX1Z/MFIXgfVSBKSDmGsxbeZXsTmQxob1bs0dcHdYgND9CRplpwAhuw+ SGcGMWLVcqZkjVz69tXYDP8GkK3kK71VDLKtfvZfhqJ8HX8aOEnrvcBJRU89EDtHH8f0 UomZ3EcS4s0Go5umYCnpmOr0UiD1wrZI61pqA2tmxlp8SolmKnk0f41Zk/7DBcn4+9yw kDBXV12txMD3yu4I4GKe0duWoZY9T43GuFHWccbLCZ6S9KYgf65DbZXXngGGGtjwVghZ 9cGiAzd/u2mbWt445YSJc332KYJBkkcfaqq2mTgj2CPFLi58f/yWI2dfhAHMmw83UCU2 M7gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IczUPO5R; 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 s22-v6si12248880plp.216.2018.04.23.03.45.04; Mon, 23 Apr 2018 03:45:48 -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=IczUPO5R; 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 S1754749AbeDWKmC (ORCPT + 99 others); Mon, 23 Apr 2018 06:42:02 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:42887 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754643AbeDWKmA (ORCPT ); Mon, 23 Apr 2018 06:42:00 -0400 Received: by mail-pf0-f194.google.com with SMTP id o16so8934064pfk.9 for ; Mon, 23 Apr 2018 03:42:00 -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=Zas8Z0mkGZq5gSVHdqXLSh0vM3XNzZ95VpVtHDIqi/I=; b=IczUPO5R53F7uGyuLGF3qwv/9XcN9+HygGoorXi2ILQosLNdtIXw/kGgxCAhQGeq72 OvUxmOoSJ8rUlMvv/Y5fnxtz69x7ppK80W4WZUAGOAZcO8r93ae844COLloVS+NJZ93k q1F/kasNNYj78ErzZkwiMB4ooneCBx8FEWswc= 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=Zas8Z0mkGZq5gSVHdqXLSh0vM3XNzZ95VpVtHDIqi/I=; b=CAK8QMIqK0xAvd8IXjH0tKJRLJzB5jF4D6s/NpAMxh6wUaImZ7sPnscmSuxTPbYXb9 Bcx3eAlXk/ByDvVCFGGxRsf3ntI8aW4VRkLqH9YXRCPjBcVo9BKG38FAaDOKTemDP+LO s4zQD5Ncu0ujs1RS7LimSPYp2++puyXdX/lh8TkjfussefKFG2QVfAtQdVhrFZEfk+4J VCkPa9N7efcniz7deYEp7LCK/OY6noDrsUDZ2+8NDrXJk5vRo6YIFwkzljykYtRNT/1m ps3PwiuDQEybCEAW0Af7C+3xZC836+cPoe+oVKN9pK4yrWBwE+4xBy4iXp0NTp2Ggwmz wjBA== X-Gm-Message-State: ALQs6tCAL2RmXDGHduS3/HzT5yXEr5xNuZbf6Lym0niD3x9o/YuyGirq /RZbF87c5dock0PANa6YsW8bGw== X-Received: by 2002:a17:902:69c5:: with SMTP id m5-v6mr20129926pln.358.1524480120413; Mon, 23 Apr 2018 03:42:00 -0700 (PDT) Received: from localhost ([122.172.61.40]) by smtp.gmail.com with ESMTPSA id 86sm28028919pfh.93.2018.04.23.03.41.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 03:41:59 -0700 (PDT) From: Viresh Kumar To: Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , Vincent Guittot , Daniel Lezcano , linux-kernel@vger.kernel.org Subject: [PATCH] sched/fair: Rearrange select_task_rq_fair() to optimize it Date: Mon, 23 Apr 2018 16:08:26 +0530 Message-Id: <8a34a16da90b9f83ffe60316a074a5e4d05b59b0.1524479666.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rearrange select_task_rq_fair() a bit to avoid executing some conditional statements in few specific code-paths. That gets rid of the goto as well. This shouldn't result in any functional changes. Signed-off-by: Viresh Kumar --- kernel/sched/fair.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 54dc31e7ab9b..cacee15076a4 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6636,6 +6636,7 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f */ if (want_affine && (tmp->flags & SD_WAKE_AFFINE) && cpumask_test_cpu(prev_cpu, sched_domain_span(tmp))) { + sd = NULL; /* Prefer wake_affine over balance flags */ affine_sd = tmp; break; } @@ -6646,33 +6647,26 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f break; } - if (affine_sd) { - sd = NULL; /* Prefer wake_affine over balance flags */ - if (cpu == prev_cpu) - goto pick_cpu; - - new_cpu = wake_affine(affine_sd, p, cpu, prev_cpu, sync); - } - - if (sd && !(sd_flag & SD_BALANCE_FORK)) { + if (sd) { /* * 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. */ - sync_entity_load_avg(&p->se); - } + 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 (affine_sd && cpu != prev_cpu) + new_cpu = wake_affine(affine_sd, p, cpu, prev_cpu, sync); - if (!sd) { -pick_cpu: if (sd_flag & SD_BALANCE_WAKE) { /* XXX always ? */ new_cpu = select_idle_sibling(p, prev_cpu, new_cpu); if (want_affine) current->recent_used_cpu = cpu; } - } else { - new_cpu = find_idlest_cpu(sd, p, cpu, prev_cpu, sd_flag); } rcu_read_unlock(); -- 2.15.0.194.g9af6a3dea062