From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81B58C48BC4 for ; Tue, 20 Feb 2024 06:45:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B3DA6B009A; Tue, 20 Feb 2024 01:45:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 13E006B009B; Tue, 20 Feb 2024 01:45:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1EBB6B009C; Tue, 20 Feb 2024 01:45:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DE1A56B009A for ; Tue, 20 Feb 2024 01:45:00 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BCA0EA021E for ; Tue, 20 Feb 2024 06:45:00 +0000 (UTC) X-FDA: 81811244760.01.A509E09 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf14.hostedemail.com (Postfix) with ESMTP id 30D7B100004 for ; Tue, 20 Feb 2024 06:44:58 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BuDLj1A4; spf=pass (imf14.hostedemail.com: domain of aneesh.kumar@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=aneesh.kumar@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708411499; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hgxDY1iWFO+tx4w+rg7vTcrBXvpk7Z9oq1+ZsicFPEE=; b=5lLAqFmceiHKmvYZlubecCJURXEwYlfPqsSaZOmjKPRfxfI+7Xe+1TgPx0vG7CTThOsce/ UczuoDJ5ugS+9N/94o+C8qEHaWCPQKL+QdZjGjxqwhf+T+nSK5R1+ebXa5n7C9B+Bdy9Ia 01+SuiXK8KZWQRB4g6k+iIKQqe4xbQM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708411499; a=rsa-sha256; cv=none; b=lqW+V54Hu6Ki7c194+/WeAZHXle0723CjtfoPmi2ipHwnmroMGG9Xc0TPJ5P7dJv9dHa5Q cNWoZwoDlEBBXradlr53viiUNrVVGxmdQ17iIRkqbEEwi24HrhWUp28rUk34ZY1U+2nu7Z O+1+bbX11U6R+tgVhHN3z33q/HqQf24= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BuDLj1A4; spf=pass (imf14.hostedemail.com: domain of aneesh.kumar@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=aneesh.kumar@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E00216105A; Tue, 20 Feb 2024 06:44:57 +0000 (UTC) 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 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 X-Rspamd-Queue-Id: 30D7B100004 X-Rspam-User: X-Stat-Signature: bqzj9k7m7djuacpyrwaoij9r4mamixyh X-Rspamd-Server: rspam03 X-HE-Tag: 1708411498-611938 X-HE-Meta: U2FsdGVkX19M0XxCxLjzfQZW0pY689wU3Gt16RUahL4rKxOlgA3Fw/4cqrEod0vfW/2aXaZpZQbe6M9iS7G2ZGtNzoyYNoTgtNQP/1gMULvIVNCrgWTw+jj/WTd+NVh3FSuA2iE5cGWJFYA0uJ7e/F4itKN6r4iPpyyRJPYOhGWKdiBsk0HL5bi2GqSRrgt3y7SI7uVMpBE48GtDeilHNAZKBke4zuzJjGU2EzrAg2nOZW+buUtaolS9AlRbtcrzaCvHFIM1BXHMnIIIuTA4GX0txK1kI/9O4NdGhM6nycag8rstIU3oF7oUN0wHZXZ0vU5AuH4v1y3FQqL8uPu6zGZlh4Dd2Dp7yQJ7CwalTVjFh+njmBZue/0m7MTlKHmMe5Y+/e8EpHh7u8ZJ8BQNkSEUCkOfBieoS3SYzOPMAJRMYVZ4bypb0snM17S5ja6rFiE3u4QytzAhxgG90guuM0u/VCjs4dIzCp+pGAl/mNN4lqc8umEDOISpfzcYaye8Tbi95wxTZBlDyx5boO9wYNvIgp50QiGDiSSCEn1tEWDf36ZowanYDMc/3HuT2vJRRWd0Y4jKxIrYZ+vC3j9v7/mD0A7PRSgp9Y08kNeOEHoO5OspfhlcSaXViOCCr2DOxDQQokAQN/Hu3cCFCt3TZe/ZlG1BBNcg5FvRVOC/HPEc0JU6Y0bEt3FL84gQsnEj/eggKpjHkfa5R4cLmI+pae/kak6GSHzOSd2GZj9lyk34w2OiLjhMTUOg8+bC1V5ida3komYJ+x/XsvL23ySNiITuohGqUpwzsZprqFsLK7lHZ9OqNazKEg3rzmlyzK3BO+meo5JgexahIF4Kgr0y3R1pzSHFBL200BV0oWZNXo0wc2qXhK4mRN7rfJDzDswczdAQ/em4PoCcHL35FXlrmCIly3LkXM7ue4KH7vrmdbepkYos9cjxVUbO+aelJp0Uv5ydcX3oxQ0y806nwrF 9a/9+k0+ ttajD X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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