From patchwork Wed Feb 21 09:27:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13565162 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 3F9F4C5478A for ; Wed, 21 Feb 2024 09:28:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 78BE36B0083; Wed, 21 Feb 2024 04:28:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 73B066B0085; Wed, 21 Feb 2024 04:28:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 575206B0087; Wed, 21 Feb 2024 04:28:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 305BA6B0083 for ; Wed, 21 Feb 2024 04:28:13 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F11E7A09BA for ; Wed, 21 Feb 2024 09:28:12 +0000 (UTC) X-FDA: 81815284824.14.53E4816 Received: from out30-112.freemail.mail.aliyun.com (out30-112.freemail.mail.aliyun.com [115.124.30.112]) by imf12.hostedemail.com (Postfix) with ESMTP id 5118A40009 for ; Wed, 21 Feb 2024 09:28:09 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b="GzC/uFhW"; spf=pass (imf12.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.112 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708507691; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dbpOfTRpA7RL14rl+8ySQliZQuoH0mAg7qi1p2q34yY=; b=FA8JlP6rVpDVOWnUu5EZBMH5GTJmjqUDGI/HZG2hG6/u5FNwzd/0CxTciLa8xQn69P1fIJ sE8sxXifThL897om2D11020FO0oMn9GAVJnCKlfnS46lMfnl1kYuHNBR9Q7Koy5t0JmGnw u2qrFD+Ipjt6jzrLHPSDEVcaqpKBFIU= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b="GzC/uFhW"; spf=pass (imf12.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.112 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708507691; a=rsa-sha256; cv=none; b=IvNHVuzeaXhO6lzMxDZCh2EDj1oryV3fQFxZF38SECASEgJEeckY5LvCLxErxLspxm9kkT RH7AArMrnQvfdsLhB7R2YEYmzRhwi2UQQZvMX68jahzwgcgjyN31JeE+lvYErgeSfuNsR/ rGPB2gNuFapYHWee4R/vSBScNc0npws= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1708507686; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=dbpOfTRpA7RL14rl+8ySQliZQuoH0mAg7qi1p2q34yY=; b=GzC/uFhWuHPux7CSgieh03iLZjVxDikAteV0gYO/Rh+zx5BfE+eHK2REncMgwJaj/VfV40BR41mp+/PeSIBmAiHnvSePs1Z2EXxz94fqP9p7nOZaG7xOXFnPgdCkUR4EZSao8G80EzWq5I04ialtbMWBwjxBIBGEacA7n9sL0gc= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0W0zPloF_1708507683; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W0zPloF_1708507683) by smtp.aliyun-inc.com; Wed, 21 Feb 2024 17:28:04 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: muchun.song@linux.dev, osalvador@suse.de, david@redhat.com, linmiaohe@huawei.com, naoya.horiguchi@nec.com, mhocko@kernel.org, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/3] mm: record the migration reason for struct migration_target_control Date: Wed, 21 Feb 2024 17:27:53 +0800 Message-Id: <04e445d16ab9f8d5a4cd4082c0c9b5f5e0bbf54c.1708507022.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 5118A40009 X-Rspam-User: X-Stat-Signature: 9d9346zzyorjjkwdh5ge3tetk8ypy4ag X-Rspamd-Server: rspam01 X-HE-Tag: 1708507689-853838 X-HE-Meta: U2FsdGVkX1+agZ+Q7SgQpG/p8BwoeWS7r694mPwLiyJBveeHBk8Uvablc0Faw0goaM3JYai4Oz6G3sYiir06jnaK5db17UauJShZYrLq4zQ5/6oYRaxPcCCpI4NKXmSaL2iEPK+gmPqjWbxQUxhAfU2xeTXZT+xD3hRJcvq6X1cbiR4JMwLJv2uFNuGkaVbaewvhxZcM4rbGcEEz0MBCl+pqDVg05T5dpJfyeaMSVx72Dq1qwKysOJxpNuI2T1goIM3GQU0CH2pdrvE0buiLE1fHkwyScxJb9G1tjjidDz7zwgZHj+lDAhd9DVx+lLx/mJNcRhojxgzgLrqjGJL73GzLi8F4Fp4Q2MzPEww8uLC24r4nM2azBcXsEa23hO6kIXWTedSwgoduUlWQ8zt8rr7qCDd3VQSRy8H3w2Ibo0pOVUQi7hJL2sepWrFNfCEiWw+a6g3/x83L/NF4eLtScqL0osliePYzo07B4T5sc44ALLqffULoCZO8T8QOV4EiUT/u4+IA7GPLWc/KGrK8etdxkTWZW098zn2kZ7rnPJHdB0F5Yx7WmmEWfsVnfBZEafHabUXKiKtENJbesGUzUjQHHYTk5GCg8qhXo3fJQhqxLpbGr7t0+6N54DTwvW0ZSYd0IfagsAeI+nI3UMEhBKZGNVvvAiwJpLIIqXAv7Ge3U4sCGrRl9146xb7of2YDBfYPIbOhyYDqkOPo8u8fPHvc8qKNSLHoz9XJ8nTG9OlRZ/lMQ5M9m0R+KI9zVmgKnsQmcjLLVXZZ7gbOMVOk/F47146JSfqXHKrr0n2UupKNLjZeoYO12xKJhuCVEE678yenZfeme6ZJ38izzEtzjtdpQ5VxeoI6IM8S1pSxzQDI2TeieYgWgv44b0C0IbcvCBNlCK1Rw8A0zDOXoT2rOPjWMuFCMeBNXq7iLOEgqYuhCyUv1qZgmPgIqC16UWAzdNLd2rojXieaGrHNJlf 55m6axKZ nSZp4bMECLy2Hvi3vcOKv3Mo0bW5Vlc8fTA6EUvX+P4SF1eBuQnAKNwYKc8IOvMdblo8KnIAc0LAqi0/WLhoniY8jA/489hN/1naeOHrqWaxdbWQWkZPCdV0ec1d9/8Yc71f7DF8qsJ+E9D2wKBsLVw4i6tbE8I5/vWfst0MsDFjrzV+oZha97mJSSFwcp51KpfvABLO4wx0xtJtH3yOTy09xiuWyzK09JiF2SnmixSSltZVYiMqdwbxJsdnUKJTRN/U4e2lrWyDg4o8= 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: To support different hugetlb allocation strategies during hugetlb migration based on various migration reasons, recording the migration reason for the migration_target_control structure as a preparation. Signed-off-by: Baolin Wang --- mm/gup.c | 1 + mm/internal.h | 1 + mm/memory-failure.c | 1 + mm/memory_hotplug.c | 1 + mm/mempolicy.c | 1 + mm/migrate.c | 1 + mm/page_alloc.c | 1 + mm/vmscan.c | 3 ++- 8 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mm/gup.c b/mm/gup.c index df83182ec72d..959a1a05b059 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2132,6 +2132,7 @@ static int migrate_longterm_unpinnable_pages( struct migration_target_control mtc = { .nid = NUMA_NO_NODE, .gfp_mask = GFP_USER | __GFP_NOWARN, + .reason = MR_LONGTERM_PIN, }; if (migrate_pages(movable_page_list, alloc_migration_target, diff --git a/mm/internal.h b/mm/internal.h index 93e229112045..7677ee4d8e12 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -958,6 +958,7 @@ struct migration_target_control { int nid; /* preferred node id */ nodemask_t *nmask; gfp_t gfp_mask; + enum migrate_reason reason; }; /* diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 9349948f1abf..780bb2aee0af 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2666,6 +2666,7 @@ static int soft_offline_in_use_page(struct page *page) struct migration_target_control mtc = { .nid = NUMA_NO_NODE, .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, + .reason = MR_MEMORY_FAILURE, }; if (!huge && folio_test_large(folio)) { diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index a444e2d7dd2b..b79ba36e09e0 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1841,6 +1841,7 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) struct migration_target_control mtc = { .nmask = &nmask, .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, + .reason = MR_MEMORY_HOTPLUG, }; int ret; diff --git a/mm/mempolicy.c b/mm/mempolicy.c index f60b4c99f130..98ceb12e0e17 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1070,6 +1070,7 @@ static long migrate_to_node(struct mm_struct *mm, int source, int dest, struct migration_target_control mtc = { .nid = dest, .gfp_mask = GFP_HIGHUSER_MOVABLE | __GFP_THISNODE, + .reason = MR_SYSCALL, }; nodes_clear(nmask); diff --git a/mm/migrate.c b/mm/migrate.c index 73a052a382f1..bde63010a3cf 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2060,6 +2060,7 @@ static int do_move_pages_to_node(struct list_head *pagelist, int node) struct migration_target_control mtc = { .nid = node, .gfp_mask = GFP_HIGHUSER_MOVABLE | __GFP_THISNODE, + .reason = MR_SYSCALL, }; err = migrate_pages(pagelist, alloc_migration_target, NULL, diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b0b92ce997dc..81ba73d77921 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6264,6 +6264,7 @@ int __alloc_contig_migrate_range(struct compact_control *cc, struct migration_target_control mtc = { .nid = zone_to_nid(cc->zone), .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, + .reason = MR_CONTIG_RANGE, }; lru_cache_disable(); diff --git a/mm/vmscan.c b/mm/vmscan.c index 87df3a48bdd7..d111c8e3b40e 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -978,7 +978,8 @@ static unsigned int demote_folio_list(struct list_head *demote_folios, .gfp_mask = (GFP_HIGHUSER_MOVABLE & ~__GFP_RECLAIM) | __GFP_NOWARN | __GFP_NOMEMALLOC | GFP_NOWAIT, .nid = target_nid, - .nmask = &allowed_mask + .nmask = &allowed_mask, + .reason = MR_DEMOTION, }; if (list_empty(demote_folios))