Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1557967rdb; Mon, 19 Feb 2024 22:46:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUBnHqjYBXMYWO1DaS/B1+vz9p76u2FE1EDpUr4ysgAS2f6S0PbDA1+5VeXskoHb0bU0/8tzkBK9qbJj6hgA4UFyrK77M9w2OzCq9Mkxw== X-Google-Smtp-Source: AGHT+IGzGsDv2/hV3TmCJ4HGqN3PUd/dWfwcLAtMqZ2MALZfTeRn/7S5FgzH8trLoEKkzVdowhkE X-Received: by 2002:ac8:5bc7:0:b0:42e:21ed:43ec with SMTP id b7-20020ac85bc7000000b0042e21ed43ecmr2661975qtb.23.1708411588105; Mon, 19 Feb 2024 22:46:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708411588; cv=pass; d=google.com; s=arc-20160816; b=Yy3VxAjWc6JwQ8yTzcV3kGhf/iHc1iRI9DfJBBfKGmMFPFpO+JeMsJXv8nQkJn6ZXY lgnH4b2Oc9zxvCw5DM55GJaFh1YyrYMN8icUBUfiQOJrIfhADPWbdcRh38c2KkHohKUq 21u/9+KV5fSjrs/VcWj+qAUt0IEVPqRWcHlkHZgVGON9PvDoAunmZZ9LrP7O7wfYf63z sIvEfh5mjHHb74zi188HRbieREYXxMx+kZxq7KHZ5ZvGAuek/hA2FokM0jl4P+XC04zs UcwWbFwJm27Nc1KfQgkGgEiL1CiI1MuL2n7rDZpp3DCZEoJMXCKgnUwFY8oviX5S2Upf U+7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=hgxDY1iWFO+tx4w+rg7vTcrBXvpk7Z9oq1+ZsicFPEE=; fh=A00Pmh86EVZI+EqxjfE7wvk4l74zjClFE/7Kw2qwn88=; b=1BXwhx22BOiAA+qfUQn2hA6owqMNm46qldoNYM1ltLsQNRNR2T4hmxvtmwQA4vgE6H QZLcuPJWusfmO4W1U5gwd4jxPxsTiUuBlRuQi5h0j+mn8SMmVwlV/8j/JeHo9TBd3Xip MVGNzax1Y6yPmJZZ15f1SoAlGzbxiWRqGVNOkcaEOesyJiNxejOHSPF0Ytzfm4hHtqmn YhL39QOxlNLndkGDj+rBSqjGTo1HPQQ3BSklLlC25NK9c6BwDLWV8q2fEon+T/wWRR6Y Bwk06gNy7kC2t0zadkZYzzLQyDDM3WV6PPy4AbGlTMTGtzK4phw47JFZ8wXWjZvYOm3m 0HVg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BuDLj1A4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-72427-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72427-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g10-20020ac85d4a000000b0042df0409734si8113151qtx.787.2024.02.19.22.46.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 22:46:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72427-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BuDLj1A4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-72427-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72427-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 73D631C21374 for ; Tue, 20 Feb 2024 06:46:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 361D55B5AD; Tue, 20 Feb 2024 06:44:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BuDLj1A4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 348845B213 for ; Tue, 20 Feb 2024 06:44:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708411498; cv=none; b=gtmFXSRMADGM93gx/g5+883vgaq/fQ+J22Mjk1IK+2yX5Z5i4ANJEBpuXRVgUjrlnSAzLCRZOvnuZsm0ma7PlgcqPZL6ZGLRubuhczsTFOk7dGodDl8tDvcnwERpc+3ZPOM9XvNYexltxlKNG8bW68o1CanONP3Hz8XXSl7bhyI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708411498; c=relaxed/simple; bh=HZHt+3VTF3kLSve2B2NZhic8Pv8cjrm5oG+CZTHgH54=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Z9dT7wX85H3MYOjh+JaAk55+Sr5T9Zx6Ag6ipNxZ7zNs7x3HColAuIGUBLERi8Jpdfx9IsWCMnqylP3m4ajpgn5b9ylPI5ZBMD1ZNNDLmfh79wCyop6L+s9TI8UMoK896d3ksYTRuFnRbWccJaMpnTsaCWlZMhyBLjLCR/9BX+c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BuDLj1A4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECD22C43399; Tue, 20 Feb 2024 06:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708411497; bh=HZHt+3VTF3kLSve2B2NZhic8Pv8cjrm5oG+CZTHgH54=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=BuDLj1A4KudlWPsKqYiWUUm1WA9DRy3e1SYdQF7mnJxP5bDR2NtmBcHltxmE5pg4l 1UMBhG0HZT4o+pXZDz9tCkYHlMJfzkmL9/BvI16O6qM2wmzDGRDucYuSKsDbD2ZLON YH0mU5FFevRjJvK7So0KVq5qquwH1P/YBZc3ZIfWsmG3wzdmu5kWq7aIBUC5rVO5gO aWFtfqg6mXGgd/a9aNKabacqKOUJDSDbc+67DFMVeEpmQ8qOhOMruWg5p7srqhA231 KnAFWXbMZKOs+Kkwlsr6tUmlWuyXFCnM9wWbcOXdvjq3hkszbzajkRv//Sd6VGIOgc 4oKSMnM+J+vWg== Message-ID: Date: Tue, 20 Feb 2024 12:14:48 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/3] mm/numa_balancing:Allow migrate on protnone reference with MPOL_PREFERRED_MANY policy Content-Language: en-US To: "Huang, Ying" , Donet Tom Cc: Michal Hocko , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dave Hansen , Mel Gorman , Ben Widawsky , Feng Tang , Andrea Arcangeli , Peter Zijlstra , Ingo Molnar , Rik van Riel , Johannes Weiner , Matthew Wilcox , Mike Kravetz , Vlastimil Babka , Dan Williams , Hugh Dickins , Kefeng Wang , Suren Baghdasaryan References: <9c3f7b743477560d1c5b12b8c111a584a2cc92ee.1708097962.git.donettom@linux.ibm.com> <8d7737208bd24e754dc7a538a3f7f02de84f1f72.1708097962.git.donettom@linux.ibm.com> <87bk8bprpr.fsf@yhuang6-desk2.ccr.corp.intel.com> From: "Aneesh Kumar K.V" In-Reply-To: <87bk8bprpr.fsf@yhuang6-desk2.ccr.corp.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 2/20/24 12:06 PM, Huang, Ying wrote: > Donet Tom writes: > >> On 2/19/24 17:37, Michal Hocko wrote: >>> On Sat 17-02-24 01:31:35, Donet Tom wrote: >>>> commit bda420b98505 ("numa balancing: migrate on fault among multiple bound >>>> nodes") added support for migrate on protnone reference with MPOL_BIND >>>> memory policy. This allowed numa fault migration when the executing node >>>> is part of the policy mask for MPOL_BIND. This patch extends migration >>>> support to MPOL_PREFERRED_MANY policy. >>>> >>>> Currently, we cannot specify MPOL_PREFERRED_MANY with the mempolicy flag >>>> MPOL_F_NUMA_BALANCING. This causes issues when we want to use >>>> NUMA_BALANCING_MEMORY_TIERING. To effectively use the slow memory tier, >>>> the kernel should not allocate pages from the slower memory tier via >>>> allocation control zonelist fallback. Instead, we should move cold pages >>>> from the faster memory node via memory demotion. For a page allocation, >>>> kswapd is only woken up after we try to allocate pages from all nodes in >>>> the allocation zone list. This implies that, without using memory >>>> policies, we will end up allocating hot pages in the slower memory tier. >>>> >>>> MPOL_PREFERRED_MANY was added by commit b27abaccf8e8 ("mm/mempolicy: add >>>> MPOL_PREFERRED_MANY for multiple preferred nodes") to allow better >>>> allocation control when we have memory tiers in the system. With >>>> MPOL_PREFERRED_MANY, the user can use a policy node mask consisting only >>>> of faster memory nodes. When we fail to allocate pages from the faster >>>> memory node, kswapd would be woken up, allowing demotion of cold pages >>>> to slower memory nodes. >>>> >>>> With the current kernel, such usage of memory policies implies we can't >>>> do page promotion from a slower memory tier to a faster memory tier >>>> using numa fault. This patch fixes this issue. >>>> >>>> For MPOL_PREFERRED_MANY, if the executing node is in the policy node >>>> mask, we allow numa migration to the executing nodes. If the executing >>>> node is not in the policy node mask but the folio is already allocated >>>> based on policy preference (the folio node is in the policy node mask), >>>> we don't allow numa migration. If both the executing node and folio node >>>> are outside the policy node mask, we allow numa migration to the >>>> executing nodes. >>> The feature makes sense to me. How has this been tested? Do you have any >>> numbers to present? >> >> Hi Michal >> >> I have a test program which allocate memory on a specified node and >> trigger the promotion or migration (Keep accessing the pages). >> >> Without this patch if we set MPOL_PREFERRED_MANY promotion or migration was not happening >> with this patch I could see pages are getting migrated or promoted. >> >> My system has 2 CPU+DRAM node (Tier 1) and 1 PMEM node(Tier 2). Below >> are my test results. >> >> In below table N0 and N1 are Tier1 Nodes. N6 is the Tier2 Node. >> Exec_Node is the execution node, Policy is the nodes in nodemask and >> "Curr Location Pages" is the node where pages present before migration >> or promotion start. >> >> Tests Results >> ------------------ >> Scenario 1:  if the executing node is in the policy node mask >> ================================================================================ >> Exec_Node    Policy           Curr Location Pages Observations >> ================================================================================ >> N0           N0 N1 N6             N1 Pages Migrated from N1 to N0 >> N0           N0 N1 N6             N6 Pages Promoted from N6 to N0 >> N0           N0 N1               N1             Pages Migrated from N1 to N0 >> N0           N0 N1                N6     Pages Promoted from N6 to N0 >> >> Scenario 2: If the folio node is in policy node mask and Exec node not in policy  node mask >> ================================================================================ >> Exec_Node    Policy       Curr Location Pages      Observations >> ================================================================================ >> N0          N1 N6             N1 Pages are not Migrating to N0 >> N0           N1 N6             N6 Pages are not migration to N0 >> N0           N1                N1     Pages are not Migrating to N0 >> >> Scenario 3: both the folio node and executing node are outside the policy nodemask >> ============================================================================== >> Exec_Node    Policy         Curr Location Pages       Observations >> ============================================================================== >> N0            N1                     N6          Pages Promoted from N6 to N0 >> N0            N6 N1          Pages Migrated from N1 to N0 >> > > Please use some benchmarks (e.g., redis + memtier) and show the > proc-vmstat stats and benchamrk score. Without this change numa fault migration is not supported with MPOL_PREFERRED_MANY policy. So there is no performance comparison with and without patch. W.r.t effectiveness of numa fault migration, that is a different topic from this patch -aneesh