Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp647803pxu; Tue, 6 Oct 2020 15:47:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTY6Q3wMFs9Lm46ZnM/Wvf8F2Ixg9ZD+5m8Fo8z07Z0OfGQhetMX5xnxMk2F28swwFU2Uc X-Received: by 2002:aa7:c7cd:: with SMTP id o13mr432204eds.114.1602024471719; Tue, 06 Oct 2020 15:47:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602024471; cv=none; d=google.com; s=arc-20160816; b=OMkjnTkvB9ZCPACIQVsFPrZNxMWrFVwuxfTvUa1ppRvO4srzQ0nJlnBYlA4yaHMF+x Sgr690AqV9zL/S7ANTnd5tKjDYO2ncwsMQE2j4YLNy05CQV2vKiLMlY8Z7Wx+Mk4r2di 7LxO5ptH9gLzsV6OMVyrR8RudEflstH7Ds71+cfYlwqsOnsfbkhz5mRTrPFQF5hxMJNb ZsTaGDMxSxyFdIbjQSUVBTPMi+WVTklQP7/BzNiEQc1aTPAz2AsEAXwdhSBwCMKOi/Px kTF4SKbh05mNmGHtly8/n0sI7lup/HTnqnH4cy8qcY1a7w5LsfcFo3ii3npLhIWkFmyd RFEA== 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=qxygc1B/3OUOzbAFSJmEXrNmuJ7p/aw6iZtN4hO17Bs=; b=0tDe3ZVCA7w0neOQ6WMOKoo+/DLquyEGqVwSX52sGgjX1WP58o3CMN4492l0jN4n6H oo118ijMGpIsezpdMlg/X+NQ3kDjRT1YlBO04wKvn7xvkW9iPRWaUbPApt5yBTL15iJC G+m+nt4PT1eLYB4ypeRcROkeCWuKV0Y5eAxOWCEezN/lrd1Rzz+R2j1qU3HR/CQGaX4P 9y2gveJdGzr0SppP7b6XhTctm/HROKLijvaXxNkaQdbEbnRiWOPd5/blUEVI0ot5cBzC WOHTBdDbR/LULuETmlIMOC/AxsIuYW295vkrQW40JK08e/2znAuxlqCUu0O/RBJQuUvV 00tg== 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 rk14si121510ejb.56.2020.10.06.15.47.28; Tue, 06 Oct 2020 15:47:51 -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 S1727372AbgJFUvT (ORCPT + 99 others); Tue, 6 Oct 2020 16:51:19 -0400 Received: from mga04.intel.com ([192.55.52.120]:39985 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727362AbgJFUvR (ORCPT ); Tue, 6 Oct 2020 16:51:17 -0400 IronPort-SDR: zFnAvBvifId9QKe8Rg54860NRdJuS55OHHEn9fV7GebE+ur97y8U+P4MzbiLBjZIy1M2u/BSPO V2Z/+3hD1uTg== X-IronPort-AV: E=McAfee;i="6000,8403,9766"; a="162068099" X-IronPort-AV: E=Sophos;i="5.77,343,1596524400"; d="scan'208";a="162068099" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2020 13:51:17 -0700 IronPort-SDR: I49RqxfMzOJoODnFIBUrs4eT46wDJN5SOedRimiPla74wkb0FZnZ1hb1w2PUh22LiL6PXfn3Cs k1oNJ4w0zg9w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,343,1596524400"; d="scan'208";a="315846926" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by orsmga006.jf.intel.com with ESMTP; 06 Oct 2020 13:51:16 -0700 Subject: [RFC][PATCH 04/12] 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, 06 Oct 2020 13:51:12 -0700 References: <20201006205103.268F74A9@viggo.jf.intel.com> In-Reply-To: <20201006205103.268F74A9@viggo.jf.intel.com> Message-Id: <20201006205112.5746B090@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 -- 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-06 13:39:24.067818434 -0700 +++ b/mm/migrate.c 2020-10-06 13:39:24.071818434 -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. _