From patchwork Tue Nov 10 05:59:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 11893307 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A673E138B for ; Tue, 10 Nov 2020 06:00:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 70C4F20795 for ; Tue, 10 Nov 2020 06:00:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70C4F20795 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4071A6B005C; Tue, 10 Nov 2020 01:00:46 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3DE716B005D; Tue, 10 Nov 2020 01:00:46 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A9136B006C; Tue, 10 Nov 2020 01:00:46 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id F08BC6B005C for ; Tue, 10 Nov 2020 01:00:45 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8ECD7181AEF0B for ; Tue, 10 Nov 2020 06:00:45 +0000 (UTC) X-FDA: 77467459650.18.deer99_52107c1272f2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 6F83C100ED3B2 for ; Tue, 10 Nov 2020 06:00:45 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,ying.huang@intel.com,,RULES_HIT:30051:30054:30064,0,RBL:192.55.52.136:@intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95;04y8qr3xa7e3smrz3cyww54mpg4m5oc691n4x4itwnwkt3x5ajj7x3wtex4zzaa.eidoj31rqppku7ug4khtsqrunfcpqh9tw4jiajmxjwwif4jjfk4ftgu8kb7hqcp.h-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:69,LUA_SUMMARY:none X-HE-Tag: deer99_52107c1272f2 X-Filterd-Recvd-Size: 5419 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Nov 2020 06:00:44 +0000 (UTC) IronPort-SDR: pdKpZ6gAqB1YifWW/no/BWf1p3lsGl/NxFPD/L9xeqVyRpno+ZS9eEi530xebn5O7l7q8AX0Bj iRMoj76QW7dQ== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="149201893" X-IronPort-AV: E=Sophos;i="5.77,465,1596524400"; d="scan'208";a="149201893" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 22:00:43 -0800 IronPort-SDR: 2LYPzJLb+/AXPFNaNTGObsHzQ5gbjla3dXal+FXRuy7clHIYuIdENVqb0JUYDqgpCkbPsSqspR xRV/9OppJPcw== X-IronPort-AV: E=Sophos;i="5.77,465,1596524400"; d="scan'208";a="473300189" Received: from yhuang-mobile.sh.intel.com ([10.238.5.184]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 22:00:39 -0800 From: Huang Ying To: Peter Zijlstra Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , "Matthew Wilcox (Oracle)" , Rafael Aquini , Andrew Morton , Ingo Molnar , Mel Gorman , Rik van Riel , Johannes Weiner , Dave Hansen , Andi Kleen , Michal Hocko , David Rientjes Subject: [PATCH -V3 1/2] mempolicy: Rename MPOL_F_MORON to MPOL_F_MOPRON Date: Tue, 10 Nov 2020 13:59:50 +0800 Message-Id: <20201110055951.85085-2-ying.huang@intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201110055951.85085-1-ying.huang@intel.com> References: <20201110055951.85085-1-ying.huang@intel.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: To follow code-of-conduct better. Although the patch changes a user visible flag definition in uapi, the flag isn't used by the user space at all. The flag is only used internally by kernel in struct mempolicy flags field. It is defined in uapi just to avoid to conflict with MPOL_MODE_FLAGS. The flag is upper case with prefix, so it looks generally OK by itself. But in the following patch, we will introduce a label named after the flag, which is lower case and without prefix, so it's better to rename it. Signed-off-by: "Huang, Ying" Suggested-by: "Matthew Wilcox (Oracle)" Acked-by: Rafael Aquini Cc: Andrew Morton Cc: Ingo Molnar Cc: Mel Gorman Cc: Rik van Riel Cc: Johannes Weiner Cc: Dave Hansen Cc: Andi Kleen Cc: Michal Hocko Cc: David Rientjes --- include/uapi/linux/mempolicy.h | 2 +- kernel/sched/debug.c | 2 +- mm/mempolicy.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/mempolicy.h b/include/uapi/linux/mempolicy.h index 3354774af61e..3c3666d017e6 100644 --- a/include/uapi/linux/mempolicy.h +++ b/include/uapi/linux/mempolicy.h @@ -60,7 +60,7 @@ enum { #define MPOL_F_SHARED (1 << 0) /* identify shared policies */ #define MPOL_F_LOCAL (1 << 1) /* preferred local allocation */ #define MPOL_F_MOF (1 << 3) /* this policy wants migrate on fault */ -#define MPOL_F_MORON (1 << 4) /* Migrate On protnone Reference On Node */ +#define MPOL_F_MOPRON (1 << 4) /* Migrate On Protnone Reference On Node */ #endif /* _UAPI_LINUX_MEMPOLICY_H */ diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 0655524700d2..8bfb6adb3f31 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -898,7 +898,7 @@ static void sched_show_numa(struct task_struct *p, struct seq_file *m) task_lock(p); pol = p->mempolicy; - if (pol && !(pol->flags & MPOL_F_MORON)) + if (pol && !(pol->flags & MPOL_F_MOPRON)) pol = NULL; mpol_get(pol); task_unlock(p); diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 3ca4898f3f24..63d91fbd3ce6 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2511,7 +2511,7 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long } /* Migrate the page towards the node whose CPU is referencing it */ - if (pol->flags & MPOL_F_MORON) { + if (pol->flags & MPOL_F_MOPRON) { polnid = thisnid; if (!should_numa_migrate_memory(current, page, curnid, thiscpu)) @@ -2802,7 +2802,7 @@ void __init numa_policy_init(void) preferred_node_policy[nid] = (struct mempolicy) { .refcnt = ATOMIC_INIT(1), .mode = MPOL_PREFERRED, - .flags = MPOL_F_MOF | MPOL_F_MORON, + .flags = MPOL_F_MOF | MPOL_F_MOPRON, .v = { .preferred_node = nid, }, }; } @@ -3010,7 +3010,7 @@ void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol) unsigned short mode = MPOL_DEFAULT; unsigned short flags = 0; - if (pol && pol != &default_policy && !(pol->flags & MPOL_F_MORON)) { + if (pol && pol != &default_policy && !(pol->flags & MPOL_F_MOPRON)) { mode = pol->mode; flags = pol->flags; } From patchwork Tue Nov 10 05:59:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 11893309 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4318C921 for ; Tue, 10 Nov 2020 06:00:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0F13A206A1 for ; Tue, 10 Nov 2020 06:00:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F13A206A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DF75E6B005D; Tue, 10 Nov 2020 01:00:50 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D9FDC6B006C; Tue, 10 Nov 2020 01:00:50 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB5286B006E; Tue, 10 Nov 2020 01:00:50 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0087.hostedemail.com [216.40.44.87]) by kanga.kvack.org (Postfix) with ESMTP id 9E3996B005D for ; Tue, 10 Nov 2020 01:00:50 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 4AC093623 for ; Tue, 10 Nov 2020 06:00:50 +0000 (UTC) X-FDA: 77467459860.15.stem34_5f05922272f2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 2556C1814B0C7 for ; Tue, 10 Nov 2020 06:00:50 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,ying.huang@intel.com,,RULES_HIT:30054:30064,0,RBL:192.55.52.136:@intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95;04yrq87bhgyq6rncusi4jsyn9t34wop43qgo61bkuamhi9exccm1ayhwu4jhqyf.uiaaeqajjr4s7oh6ixqsfhkzto35kbiwywyxd5qdmat6ishbb58qqbdx7iahftc.w-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:68,LUA_SUMMARY:none X-HE-Tag: stem34_5f05922272f2 X-Filterd-Recvd-Size: 4856 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Nov 2020 06:00:49 +0000 (UTC) IronPort-SDR: gqzAe8XKlIENV8HMUpXy+9XTBl7AnccFbJCEWxtI4Pl1zOEP9djFapbgRhtBDaWblNqzHGj02J gGTa+TCfW+Lw== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="149201902" X-IronPort-AV: E=Sophos;i="5.77,465,1596524400"; d="scan'208";a="149201902" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 22:00:47 -0800 IronPort-SDR: /SathYVwYsMAXVfDTBFf2Ua3xMNyHJ/3pBunkzJzZyRBqWpkoROn55Tb8mEZVimt3h+EBwyGLB aEb2MZCiB5QQ== X-IronPort-AV: E=Sophos;i="5.77,465,1596524400"; d="scan'208";a="473300211" Received: from yhuang-mobile.sh.intel.com ([10.238.5.184]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 22:00:44 -0800 From: Huang Ying To: Peter Zijlstra Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Mel Gorman , Andrew Morton , Ingo Molnar , Rik van Riel , Johannes Weiner , "Matthew Wilcox (Oracle)" , Dave Hansen , Andi Kleen , Michal Hocko , David Rientjes Subject: [PATCH -V3 2/2] autonuma: Migrate on fault among multiple bound nodes Date: Tue, 10 Nov 2020 13:59:51 +0800 Message-Id: <20201110055951.85085-3-ying.huang@intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201110055951.85085-1-ying.huang@intel.com> References: <20201110055951.85085-1-ying.huang@intel.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now, AutoNUMA can only optimize the page placement among the NUMA nodes if the default memory policy is used. Because the memory policy specified explicitly should take precedence. But this seems too strict in some situations. For example, on a system with 4 NUMA nodes, if the memory of an application is bound to the node 0 and 1, AutoNUMA can potentially migrate the pages between the node 0 and 1 to reduce cross-node accessing without breaking the explicit memory binding policy. So in this patch, if mbind(.mode=MPOL_BIND, .flags=MPOL_MF_LAZY) is used to bind the memory of the application to multiple nodes, and in the hint page fault handler both the faulting page node and the accessing node are in the policy nodemask, the page will be tried to be migrated to the accessing node to reduce the cross-node accessing. [Peter Zijlstra: provided the simplified implementation method.] Signed-off-by: "Huang, Ying" Acked-by: Mel Gorman Cc: Andrew Morton Cc: Ingo Molnar Cc: Rik van Riel Cc: Johannes Weiner Cc: "Matthew Wilcox (Oracle)" Cc: Dave Hansen Cc: Andi Kleen Cc: Michal Hocko Cc: David Rientjes --- mm/mempolicy.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 63d91fbd3ce6..40f2ff2607b3 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2490,15 +2490,19 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long break; case MPOL_BIND: - /* - * allows binding to multiple nodes. - * use current page if in policy nodemask, - * else select nearest allowed node, if any. - * If no allowed nodes, use current [!misplaced]. + * Allows binding to multiple nodes. If both current and + * accessing nodes are in policy nodemask, migrate to + * accessing node to optimize page placement. Otherwise, + * use current page if in policy nodemask, else select + * nearest allowed node, if any. If no allowed nodes, use + * current [!misplaced]. */ - if (node_isset(curnid, pol->v.nodes)) + if (node_isset(curnid, pol->v.nodes)) { + if (node_isset(thisnid, pol->v.nodes)) + goto mopron; goto out; + } z = first_zones_zonelist( node_zonelist(numa_node_id(), GFP_HIGHUSER), gfp_zone(GFP_HIGHUSER), @@ -2512,6 +2516,7 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long /* Migrate the page towards the node whose CPU is referencing it */ if (pol->flags & MPOL_F_MOPRON) { +mopron: polnid = thisnid; if (!should_numa_migrate_memory(current, page, curnid, thiscpu))