Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2149747pxb; Mon, 8 Mar 2021 16:00:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlN/FcJrtys75Kb3Bc2uZx4BML6KG5/ySZ07IRJtfRPgRYZt/x7nCs1QU2Y+YqsYXVHHCb X-Received: by 2002:a17:906:fa04:: with SMTP id lo4mr17372937ejb.44.1615248046386; Mon, 08 Mar 2021 16:00:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615248046; cv=none; d=google.com; s=arc-20160816; b=crOzp666NQybR09h16rYb+q4Z10fFapBQAyPzbuGU/tWO5IP6wrd0j02tLIcZGigTJ KmBOkX0SWcZPBRkXaNGrCd4c1muyddTIklGYHbcXRAdavfPAKP9cGldTqL0k1IKavzuq 1x0vRNTf2659FxAkapNq8FkgFAqXZqk6vZT85ygPdkn6RvBRAAKuLk5+bw5ekT9kUnr4 fyEKypCB3YsTXfUz9skxqTtSMx8GJ37nOFZWyps6YSSAM/tThiUejqK/cRBaiN5mubCg BMazJoRcXHbZp6EwfTmsCRuVLy1RiKVUqB2+iGU5cWW+3fSah3vQqMn7Q+Da2cvpXl5B /Bfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=S0sgCVzuEWKtYhGm2lK4XelzYXOqzpILEQnckI9FXEY=; b=fhCHpboDCiB9TnGieeC0B2MoQTcxfPCMX5FyfqrkIp1NfFIbRffTjXEDI6lQr0T98m nr/u0b9bY0c39MVsEsh3UjJsEH5E6K0oZo8rADoMwFUktwAq0FtUBXLbWc3F7xgxSdCq fkKqFsRzeroD5NPg2Pe0+EQckKRp1WiLpubBON9pzF90ED8iE6v4RuKA5CiVu8rvxXIR KwsoEluOW+1tZfLKNTBirgRI8AZ4L36wHXUNQ0lCDovRRAqzK9lrVsiKqzdjnn5jLUeV XKzT5UuzTk2ssBih7RLjYgdh6bIL5uWcYcvTTN2lI7nwOBoumbtRwkw1Q8WPcXpQyJi7 BrcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Aseowwh2; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dx21si8055108ejb.567.2021.03.08.16.00.23; Mon, 08 Mar 2021 16:00:46 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Aseowwh2; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231406AbhCHX7Y (ORCPT + 99 others); Mon, 8 Mar 2021 18:59:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230444AbhCHX7J (ORCPT ); Mon, 8 Mar 2021 18:59:09 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 983BFC06174A for ; Mon, 8 Mar 2021 15:59:08 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id mj10so23923120ejb.5 for ; Mon, 08 Mar 2021 15:59:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=S0sgCVzuEWKtYhGm2lK4XelzYXOqzpILEQnckI9FXEY=; b=Aseowwh2JcLWPQNWZOAXoWU0QMjWmb0VwfNqQlqr4N5u/ycJsRUTo9Z+R6wO5mxUJZ 2e1mPPdqAYjy5Cva32D8Rj5TmRWFs2+wwSX6N4WgdWNfwc6yidbnzv9+QmfbYxvL3eXA Hwcl8U+So2nBtK0xaGmGDyPrGmpQeuuAw2+g3Q/UAkmtMokQqRGoVRmrbXM3k5vPV119 0lzcB66ObWAzp54b6K9dLJ5y6ERIy496/BfljJFFgdjZKCWCOkOdhW5Iqr8CeaL4iy7c W+mc77qnThxN0+usIEXrLVY4EMv0p/RjSs2YnEmGO53QBFCottWEGA1aQtNik84ABfWZ lohw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=S0sgCVzuEWKtYhGm2lK4XelzYXOqzpILEQnckI9FXEY=; b=G0AbDhW23/srs86rX3RXnkeUIzZcZuFwxfVv37q8EG+erQ5hUPJ20f9oNpv9KPdMow x+0JIUHyQo0uZzbL4qLmzY3DYBEfTgpPAnf71xhJrb0rmc3jvqlDBQUPiz2dffl825Xt sB9jNdjk7Y+RQ90Ovb0LluzaLc+BzmRDf9fXJ3IF12w7unSLfVaJ5HyPl1GmT/QzO+Wm 1FvmpDQ3w0BtVpEQj0bQYCfIQXClymnJQq6qrgLdSj1kWm4PMuysoSOQ9p58jCjcsvJe 5JFvQ9r5dmii3Az+2q4NFUi354gRepJXGWLcU/Uz1Qo7VfRGX/i9dO6LIuYI4wdvg/kl e0MA== X-Gm-Message-State: AOAM532HVrXAR/e3KMLj0kH8iiKRIqe9B/oNpqKaCKDD1OQedUgIwkpE J6u25ttkJ+hqqK57oXNlAh9bDiiTv+m8B5hW6U4= X-Received: by 2002:a17:906:a51:: with SMTP id x17mr17528122ejf.25.1615247947402; Mon, 08 Mar 2021 15:59:07 -0800 (PST) MIME-Version: 1.0 References: <20210304235949.7922C1C3@viggo.jf.intel.com> <20210304235951.271553C2@viggo.jf.intel.com> In-Reply-To: <20210304235951.271553C2@viggo.jf.intel.com> From: Yang Shi Date: Mon, 8 Mar 2021 15:58:56 -0800 Message-ID: Subject: Re: [PATCH 01/10] mm/numa: node demotion data structure and lookup To: Dave Hansen Cc: Linux Kernel Mailing List , Linux MM , Yang Shi , David Rientjes , Huang Ying , Dan Williams , David Hildenbrand , Oscar Salvador Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 4, 2021 at 4:00 PM Dave Hansen wrote: > > > 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. Reviewed-by: Yang Shi > > Signed-off-by: Dave Hansen > Cc: Yang Shi > Cc: David Rientjes > Cc: Huang Ying > Cc: Dan Williams > Cc: David Hildenbrand > Cc: osalvador > > -- > > changes since 20200122: > * Make node_demotion[] __read_mostly > > 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 | 17 +++++++++++++++++ > 1 file changed, 17 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 2021-03-04 15:35:51.353806441 -0800 > +++ b/mm/migrate.c 2021-03-04 15:35:51.359806441 -0800 > @@ -1157,6 +1157,23 @@ out: > return rc; > } > > +static int node_demotion[MAX_NUMNODES] __read_mostly = > + {[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. > _ >