From patchwork Fri Jun 19 16:23:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 11614635 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 65F4E90 for ; Fri, 19 Jun 2020 16:25:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3BC49217A0 for ; Fri, 19 Jun 2020 16:25:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3BC49217A0 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 DFA128D00E4; Fri, 19 Jun 2020 12:24:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DAA008D00E1; Fri, 19 Jun 2020 12:24:45 -0400 (EDT) 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 C4F668D00E4; Fri, 19 Jun 2020 12:24:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A36698D00E1 for ; Fri, 19 Jun 2020 12:24:45 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 6BC4F8248068 for ; Fri, 19 Jun 2020 16:24:45 +0000 (UTC) X-FDA: 76946484930.07.pan95_2908f6d26e1a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 312551803FD61 for ; Fri, 19 Jun 2020 16:24:45 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,ben.widawsky@intel.com,,RULES_HIT:30041:30045:30054:30064:30080,0,RBL:192.55.52.120:@intel.com:.lbl8.mailshell.net-64.95.201.95 62.50.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: pan95_2908f6d26e1a X-Filterd-Recvd-Size: 3951 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Fri, 19 Jun 2020 16:24:44 +0000 (UTC) IronPort-SDR: JXzgnIbhdwO1wTwv3PyXtOrTmWE/0W7ggVG/qrERli7uiIVzvAnNhk5rOJOXy+z5msyn/mMlYm 4K97y4nqASvw== X-IronPort-AV: E=McAfee;i="6000,8403,9657"; a="140535476" X-IronPort-AV: E=Sophos;i="5.75,256,1589266800"; d="scan'208";a="140535476" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:24:16 -0700 IronPort-SDR: ICEE3bk73kweJ0z09790ZeGo0+KMGbQ0BQDdkaBJ5owNTAraYgnHTCb/SaQuf0WiegR6JDQAha tBLk+dvrEvvA== X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="264366239" Received: from sjiang-mobl2.ccr.corp.intel.com (HELO bwidawsk-mobl5.local) ([10.252.131.131]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:24:15 -0700 From: Ben Widawsky To: linux-mm Subject: [PATCH 02/18] mm/mempolicy: Use node_mem_id() instead of node_id() Date: Fri, 19 Jun 2020 09:23:58 -0700 Message-Id: <20200619162414.1052234-3-ben.widawsky@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619162414.1052234-1-ben.widawsky@intel.com> References: <20200619162414.1052234-1-ben.widawsky@intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 312551803FD61 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: Calling out some distinctions first as I understand it, and the reasoning of the patch: numa_node_id() - The node id for the currently running CPU. numa_mem_id() - The node id for the closest memory node. The case where they are not the same is CONFIG_HAVE_MEMORYLESS_NODES. Only ia64 and powerpc support this option, so it is perhaps not a very interesting situation to most. The question is, when you do want which? numa_node_id() is definitely what's desired if MPOL_PREFERRED, or MPOL_LOCAL were used, since the ABI states "This mode specifies "local allocation"; the memory is allocated on the node of the CPU that triggered the allocation (the "local node")." It would be weird, though not impossible to set this policy on a CPU that has memoryless nodes. A more likely way to hit this is with interleaving. The current interfaces will return some equally weird thing, but at least it's symmetric. Therefore, in cases where the node is being queried for the currently running process, it probably makes sense to use numa_node_id(). For other cases however, when CPU is trying to obtain the "local" memory, numa_mem_id() already contains this and should be used instead. This really should only effect configurations where CONFIG_HAVE_MEMORYLESS_NODES=y, and even on those machines it's quite possible the ultimate behavior would be identical. Cc: Andrew Morton Cc: Lee Schermerhorn Signed-off-by: Ben Widawsky --- mm/mempolicy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 36ee3267c25f..99e0f3f9c4a6 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1991,7 +1991,7 @@ static unsigned offset_il_node(struct mempolicy *pol, unsigned long n) int nid; if (!nnodes) - return numa_node_id(); + return numa_mem_id(); target = (unsigned int)n % nnodes; nid = first_node(pol->v.nodes); for (i = 0; i < target; i++) @@ -2049,7 +2049,7 @@ int huge_node(struct vm_area_struct *vma, unsigned long addr, gfp_t gfp_flags, nid = interleave_nid(*mpol, vma, addr, huge_page_shift(hstate_vma(vma))); } else { - nid = policy_node(gfp_flags, *mpol, numa_node_id()); + nid = policy_node(gfp_flags, *mpol, numa_mem_id()); if ((*mpol)->mode == MPOL_BIND) *nodemask = &(*mpol)->v.nodes; }