Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp539756pxu; Wed, 7 Oct 2020 09:24:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpi8PUaKeNjCwjGaCDC6p3ngdzdUYU0b/+hpvLR9DmbHisrgkdrWqhfXWu3dFvPskc862A X-Received: by 2002:a17:906:a101:: with SMTP id t1mr4037132ejy.203.1602087850208; Wed, 07 Oct 2020 09:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602087850; cv=none; d=google.com; s=arc-20160816; b=aJZkl6BkcBLL9VlLF97M8JfG4cYrpwmSn2oqI7Gt44PfVfcnYtyb/J5F5QsfAJdo1S KHNLz/yDufptvkPkmqhkH6JicD2BUlLgUHZV0yRCKD2UKIbylHll5fY5Pv8jOnrtD0rv m7MLXexy1zteEQcT7zU+4oopgIP4zB5rB8qMc5PoZWU8oQ4T2DJZzY8zY3qqb2Xh4pOn lFUAifyQleCDEc4gzlVO0e/LrsntKw9YaphEe03aQ3M42FDwvPntjV5+KFJBB3Iq+U6J 48dvlQhTmMPEFpM0zyV0gp/slzHiQIpK1BjNVJLos94ksAI0FahC8LOXfBzHNiML+ajH IODQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:in-reply-to:references:date:from:cc :to:subject:ironport-sdr:ironport-sdr; bh=NslhFW4NZtdKVnW8gGlN2e9WAfE7zXCN6DBhpQ9SRPU=; b=NTX+2QEn6GuRMC5KsZeNKcf/z9sXSwPZ9xGL9yRgHxW5MDBupw6o7HE0/8jV/vYIN1 HD5Qtv3R1KsL0B00lGLfzd+B/Oy+V941wpHFcOcS2H3Bky56C8+0RX+W0SZ29P9FuKts 58DQ7cQgSc2l3VgvanfssQKuakFelM1N9zYvNNyCHas2QfUDSXpCyihtmFHf+FNvz2Pe FrvDkRJ8HBO/s1rCcl//OtPxtukBmzfACvv/KH9riKDC6NR5uov52AjtYqpe2SIcr5is HISU1pQCicDhMbTswHUeClOoKVWBpNWrNNs/lDj7YBiRGEyHLWTv+zNtsbhhdgpWBcYy Zxhw== 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 g24si1672347edq.128.2020.10.07.09.23.46; Wed, 07 Oct 2020 09:24:10 -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 S1729157AbgJGQRs (ORCPT + 99 others); Wed, 7 Oct 2020 12:17:48 -0400 Received: from mga11.intel.com ([192.55.52.93]:6868 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726348AbgJGQRq (ORCPT ); Wed, 7 Oct 2020 12:17:46 -0400 IronPort-SDR: AWM4l0mC2toXIt2I/usWpRRz59iLQ3t0tMXpluxzjkclXBuJ7uZURUoIFgPn5DxSl2qiN7lGbX iFNIF03QZyMQ== X-IronPort-AV: E=McAfee;i="6000,8403,9767"; a="161609580" X-IronPort-AV: E=Sophos;i="5.77,347,1596524400"; d="scan'208";a="161609580" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2020 09:17:45 -0700 IronPort-SDR: WH1ZsKs1hkQPXa4ELitlC1Jl6CZikFwpbHUpmO3Mj3N3wEGEh6HquTZ3M7F7N6RGYfwKhqHOsc 9Sj2qp+hZTdw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,347,1596524400"; d="scan'208";a="418753250" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by fmsmga001.fm.intel.com with ESMTP; 07 Oct 2020 09:17:45 -0700 Subject: [RFC][PATCH 1/9] mm/numa: node demotion data structure and lookup To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Dave Hansen , yang.shi@linux.alibaba.com, rientjes@google.com, ying.huang@intel.com, dan.j.williams@intel.com, david@redhat.com From: Dave Hansen Date: Wed, 07 Oct 2020 09:17:38 -0700 References: <20201007161736.ACC6E387@viggo.jf.intel.com> In-Reply-To: <20201007161736.ACC6E387@viggo.jf.intel.com> Message-Id: <20201007161738.403BFCD7@viggo.jf.intel.com> 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 Cc: David Hildenbrand -- 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-10-07 09:15:25.978642454 -0700 +++ b/mm/migrate.c 2020-10-07 09:15:25.989642454 -0700 @@ -1161,6 +1161,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. _