Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2556489ybv; Mon, 24 Feb 2020 07:21:46 -0800 (PST) X-Google-Smtp-Source: APXvYqx4j/GoGtXpo/ItgjRwjfOU37uKjzSQUgJhqmVG3/ICAsOwfc8tqkHF5VIcXV/r71xlWqgC X-Received: by 2002:a9d:7498:: with SMTP id t24mr41552988otk.290.1582557706068; Mon, 24 Feb 2020 07:21:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582557706; cv=none; d=google.com; s=arc-20160816; b=Ovm/63lVos3GQmo09SwivxnkTmY/OxhSkLdNrDHubmJWvv47x17uVCCChNV0CiRrGH DPy8JnRUOqJji0FdPeLHF9SSSZp7IzCPnXhej50CoHohvpdNmxxK6BK3QunPbhLCcM01 pSljTjDXY0OHaU5YLNe+eddlfyup3sGYkyyyzkXzfh2nIxGrKhJzy8KdCBzjj8ip72Je jS9w3EyjVBFElWQpITPH+mMOUuFwcYhha0psZpWo8KJ7JlsKEiI9QbqJRnzA1H/a3G9n d7DyM66mwGT2FfJR008gB74IlWAB2+aMlKWH5yCPttoe0o4gF0ZBdlEA+glgCmqQpu8F hCzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=X8JymfmZCMIMnayiNwLaGoeoaCt3JhTAIgoaWull6qg=; b=X854QGHo8I/rw7ze5r9hUOHOqlG4MQs5pgRG65uY1Ydp46HUtWtvRB4oq6Sh6v6FIr +kvtni1gyHGPxChhEX+/GYBkDXMP6BNFWb9WqXzc9Nl4xOdQDPH5RHzgsfhAaKRkDmu7 P9GURY5cpX44NX3Xd9wVXGNatZgQ+hERplD+5ucXwrjo+3kULy9Wcjxi/+ypX9oUPfB4 R19iuXlBtCz1fugsbCB7/53qjnC023n4hmpaTkwYkFb7RqWob1nba0/l8ANK2pNxnNry bv8rYrgRouX5tn/bWGcLliwSvWHYAjfYXXkkfOtVK9/paBbDfols6MkQZxx7zX49MuAk 9OQw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5si6330073otk.244.2020.02.24.07.21.34; Mon, 24 Feb 2020 07:21:46 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728169AbgBXPVJ (ORCPT + 99 others); Mon, 24 Feb 2020 10:21:09 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:50376 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728150AbgBXPVH (ORCPT ); Mon, 24 Feb 2020 10:21:07 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1j6FX4-0005pz-S8; Mon, 24 Feb 2020 16:20:31 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 6AF691C213D; Mon, 24 Feb 2020 16:20:30 +0100 (CET) Date: Mon, 24 Feb 2020 15:20:30 -0000 From: "tip-bot2 for Mel Gorman" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/numa: Bias swapping tasks based on their preferred node Cc: Mel Gorman , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Valentin Schneider , Phil Auld , Hillf Danton , x86 , LKML In-Reply-To: <20200224095223.13361-13-mgorman@techsingularity.net> References: <20200224095223.13361-13-mgorman@techsingularity.net> MIME-Version: 1.0 Message-ID: <158255763019.28353.11731318686961855268.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: 88cca72c9673e631b63eca7a1dba4a9722a3f414 Gitweb: https://git.kernel.org/tip/88cca72c9673e631b63eca7a1dba4a9722a3f414 Author: Mel Gorman AuthorDate: Mon, 24 Feb 2020 09:52:22 Committer: Ingo Molnar CommitterDate: Mon, 24 Feb 2020 11:36:39 +01:00 sched/numa: Bias swapping tasks based on their preferred node When swapping tasks for NUMA balancing, it is preferred that tasks move to or remain on their preferred node. When considering an imbalance, encourage tasks to move to their preferred node and discourage tasks from moving away from their preferred node. Signed-off-by: Mel Gorman Signed-off-by: Ingo Molnar Acked-by: Peter Zijlstra Cc: Vincent Guittot Cc: Juri Lelli Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Valentin Schneider Cc: Phil Auld Cc: Hillf Danton Link: https://lore.kernel.org/r/20200224095223.13361-13-mgorman@techsingularity.net --- kernel/sched/fair.c | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 050c1b1..8c1ac01 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1741,18 +1741,27 @@ static void task_numa_compare(struct task_numa_env *env, goto unlock; } + /* Skip this swap candidate if cannot move to the source cpu. */ + if (!cpumask_test_cpu(env->src_cpu, cur->cpus_ptr)) + goto unlock; + + /* + * Skip this swap candidate if it is not moving to its preferred + * node and the best task is. + */ + if (env->best_task && + env->best_task->numa_preferred_nid == env->src_nid && + cur->numa_preferred_nid != env->src_nid) { + goto unlock; + } + /* * "imp" is the fault differential for the source task between the * source and destination node. Calculate the total differential for * the source task and potential destination task. The more negative * the value is, the more remote accesses that would be expected to * be incurred if the tasks were swapped. - */ - /* Skip this swap candidate if cannot move to the source cpu */ - if (!cpumask_test_cpu(env->src_cpu, cur->cpus_ptr)) - goto unlock; - - /* + * * If dst and source tasks are in the same NUMA group, or not * in any group then look only at task weights. */ @@ -1779,6 +1788,19 @@ static void task_numa_compare(struct task_numa_env *env, task_weight(cur, env->dst_nid, dist); } + /* Discourage picking a task already on its preferred node */ + if (cur->numa_preferred_nid == env->dst_nid) + imp -= imp / 16; + + /* + * Encourage picking a task that moves to its preferred node. + * This potentially makes imp larger than it's maximum of + * 1998 (see SMALLIMP and task_weight for why) but in this + * case, it does not matter. + */ + if (cur->numa_preferred_nid == env->src_nid) + imp += imp / 8; + if (maymove && moveimp > imp && moveimp > env->best_imp) { imp = moveimp; cur = NULL; @@ -1786,6 +1808,15 @@ static void task_numa_compare(struct task_numa_env *env, } /* + * Prefer swapping with a task moving to its preferred node over a + * task that is not. + */ + if (env->best_task && cur->numa_preferred_nid == env->src_nid && + env->best_task->numa_preferred_nid != env->src_nid) { + goto assign; + } + + /* * If the NUMA importance is less than SMALLIMP, * task migration might only result in ping pong * of tasks and also hurt performance due to cache