Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3310259pxa; Tue, 18 Aug 2020 11:49:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRhbH4XRG9nt3tXLtxsYEjEJSol95UeCuvSCWKwnL1M5SeNZcRv48FyzAcopKApamHoRsB X-Received: by 2002:aa7:d516:: with SMTP id y22mr21054133edq.221.1597776566236; Tue, 18 Aug 2020 11:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597776566; cv=none; d=google.com; s=arc-20160816; b=NHG6cvvmAEyEo9X9l/+cizi7q9zoHJc1m+AeAdEcJMxMFbmNz98bu4FlC9Vk1Y79pk HJFGn01hmyF6mKvZiA/lTfNA5d3/sbZNx8R5HyLCeTEbzrzO7rjLHyJnxTyQ513OfyCu d/efbHHeApgdQMuTc1XzVAYyrkQssbVjKaCD/SZXlOlr4VKqI5i6drIikYRiCkz31ci+ Y1eblbEKBXa0/r/xbkzaRhhd7DzGRGTCV3P6Lp4ElcekSr0xyRGHk2FweF6tD86pKqXk TI1Yexi9tmmHXxHfnFC7JfSuzP2QgvJGNGIPHhjJoe786Ncxq8CQM/miBNxCxnrFoN8M LChQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to:references:date :from:cc:to:subject:ironport-sdr:ironport-sdr; bh=ji51dxRlx5NrEHlRM9+MHDw6gdgqGxzhHsEjz9eM5cI=; b=HJMn+5mlD4rVPIFqhJGFFPmR8v1meVIIs7MbkKN2X/mGoiDnW9Cq+5usSTrcNxEMMI GcYDXR8oneplKRFiJLBAWgsBWntlRld428To23DPGG+jW0OvvG88SWMOvq6lA0Kj7p+M 9xvenxTDsZAjf/OtTXFpJsZyyxLYxOwcMt84a7Bu7zoU9YbsrxH1inSn/FY6XO998yMu FKmKhg/o1ufsi9jJsud1CPojcx06JCsupU9i7qZm4KxfQQyuHVzuhy4gMgwALNGbU1GY A9/DpUuAFGTURw/cm2Cmn2vEp1tCWILyPizATtbrByo1boO6DB68obLFnAcLUVrfGwEr AKqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l14si14296338ejz.730.2020.08.18.11.49.02; Tue, 18 Aug 2020 11:49:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726766AbgHRSsG (ORCPT + 99 others); Tue, 18 Aug 2020 14:48:06 -0400 Received: from mga11.intel.com ([192.55.52.93]:55906 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbgHRSsE (ORCPT ); Tue, 18 Aug 2020 14:48:04 -0400 IronPort-SDR: bblNWjOQNmnN5QAdWgN6ywOuwII7fg1uDQ2cyxfWIxhMOXMonAxB+aTeSwnLsemy+eNkGyXsh9 xzwKFjlMq90Q== X-IronPort-AV: E=McAfee;i="6000,8403,9717"; a="152610600" X-IronPort-AV: E=Sophos;i="5.76,328,1592895600"; d="scan'208";a="152610600" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 11:48:03 -0700 IronPort-SDR: /pdwXXntItm9kxQ5j43iTpw+7WR+wKQ/J0WmAEJGua4yA4qY458tGlR0Q48yZa2fPoaHgqWZ0q 5jnzzLmQLMog== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,328,1592895600"; d="scan'208";a="279475927" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by fmsmga008.fm.intel.com with ESMTP; 18 Aug 2020 11:48:03 -0700 Subject: [RFC][PATCH 1/9] mm/numa: node demotion data structure and lookup To: linux-kernel@vger.kernel.org Cc: Dave Hansen , yang.shi@linux.alibaba.com, rientjes@google.com, ying.huang@intel.com, dan.j.williams@intel.com From: Dave Hansen Date: Tue, 18 Aug 2020 11:41:24 -0700 References: <20200818184122.29C415DF@viggo.jf.intel.com> In-Reply-To: <20200818184122.29C415DF@viggo.jf.intel.com> Message-Id: <20200818184124.0951CF98@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen Prepare for the kernel to auto-migrate pages to other memory nodes with a user defined node migration table. This allows creating single migration target for each NUMA node to enable the kernel to do NUMA page migrations instead of simply reclaiming colder pages. A node with no target is a "terminal node", so reclaim acts normally there. The migration target does not fundamentally _need_ to be a single node, but this implementation starts there to limit complexity. If you consider the migration path as a graph, cycles (loops) in the graph are disallowed. This avoids wasting resources by constantly migrating (A->B, B->A, A->B ...). The expectation is that cycles will never be allowed. Signed-off-by: Dave Hansen Cc: Yang Shi Cc: David Rientjes Cc: Huang Ying Cc: Dan Williams -- changes in July 2020: - Remove loop from next_demotion_node() and get_online_mems(). This means that the node returned by next_demotion_node() might now be offline, but the worst case is that the allocation fails. That's fine since it is transient. --- b/mm/migrate.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff -puN mm/migrate.c~0006-node-Define-and-export-memory-migration-path mm/migrate.c --- a/mm/migrate.c~0006-node-Define-and-export-memory-migration-path 2020-08-18 11:36:47.910583191 -0700 +++ b/mm/migrate.c 2020-08-18 11:36:47.914583191 -0700 @@ -1160,6 +1160,22 @@ out: return rc; } +static int node_demotion[MAX_NUMNODES] = {[0 ... MAX_NUMNODES - 1] = NUMA_NO_NODE}; + +/** + * next_demotion_node() - Get the next node in the demotion path + * @node: The starting node to lookup the next node + * + * @returns: node id for next memory node in the demotion path hierarchy + * from @node; NUMA_NO_NODE if @node is terminal. This does not keep + * @node online or guarantee that it *continues* to be the next demotion + * target. + */ +int next_demotion_node(int node) +{ + return node_demotion[node]; +} + /* * Obtain the lock on page, remove all ptes and migrate the page * to the newly allocated page in newpage. _