Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2251134rdb; Wed, 21 Feb 2024 01:33:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXnHOR3KwZSqZxtUuIXNT+Zb4dXNZV/qNo1o6gYUD3w7uQLwsi/E6MO9KMDKA4hLwHUamsELNLNgcol0ZvuMFR2Oq0F34J1tsDP1A8QMQ== X-Google-Smtp-Source: AGHT+IGZ5IYf36N/yCqHMNhMVLOVj8l+aRkDs2+0mqU2W2hKftg2ACzgh88+pLrxU8WaJ2LvsdCE X-Received: by 2002:a17:90a:ca84:b0:299:3f27:d08c with SMTP id y4-20020a17090aca8400b002993f27d08cmr11641838pjt.38.1708508027778; Wed, 21 Feb 2024 01:33:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708508027; cv=pass; d=google.com; s=arc-20160816; b=k4L527qA1/UFzmXs2G8o0xvc3dcdsso2Pb0NJnqrySRN3+vBIITCTvnNj6Qld4dpBp JsO0fEsLyAbwgUFEwAt7up8Z9neGT2a8N9OAykBPYD6NCRSkfb5LS4SeKKifettnev9y veoZE9VeJCts2XOPipgwlCFb5h7CcHoXGap19r0fer5oEDhavndSdejWWPclad/wHmkn TeLY4uCgTjEbDt3K9MqCiRGL9OGyJwb2QdKCpz4OnU+0qI3v6b9yz2IScVFANnM12Y0c ByxtewKdJtwb4LbzTjIL+0Nwr2JXR2lfNLUfupg0T0Pz7cLDCcr2XIqIgKj+xABLu3Hh 3nYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dbpOfTRpA7RL14rl+8ySQliZQuoH0mAg7qi1p2q34yY=; fh=Eg1bbkMBB2FpJxkcjuowRNwwz/msSkRTpuEVSvFESpg=; b=A2123umJHcDfPLfbcj35uyOXpMvRju2ycZZAMm7xdPdX0cGAkRneLKAph89QEDIrLv CXMDF5QF7PAJQJIwZ1aLWVikBgk4DhXE/eL/FHAl/4b0P7bHuQQEZ+wUoDBzUu5LSBx7 WMOmZpvDkbj1lz/O4ljtIrvXVFjg5xmlLd5WKNAFymHsIXGn18AwEUaZU2A7vAQ3TKtB T5IgCMnuWqONObt+BfTqqnOtDBsNRAeVYbB57Z8vrHPEzc6YC7NTqRZ2VMvz9JMVd1uD gvlb4BAhU+anpY+JgMoPE10ViltQr891/k4bmc+HB2Ix+lplSeN/rW0lNDIxYtLyfuls lNEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=h1985OuN; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-74403-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74403-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id y15-20020a17090aa40f00b0029934828c79si1153148pjp.128.2024.02.21.01.33.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 01:33:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74403-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=h1985OuN; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-74403-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74403-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 1915AB22DF0 for ; Wed, 21 Feb 2024 09:29:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7917B3F8D3; Wed, 21 Feb 2024 09:28:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="h1985OuN" Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) (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 2E87E3DB89 for ; Wed, 21 Feb 2024 09:28:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.99 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708507695; cv=none; b=eWwNFPPWijaZ/GG8XZsw/FRJ34UGS7cAvIljB4XP6ZOUwI0wBRJyJSm84rLpPVsPnGgqWbNFDujtkdgkZB841vqTIhLOm++qAJ7JQiaiPGHdNnd2pnLT0o4DytrrueuVc7n36sukmzgRbfqWQ+LReFcPS3PE1jd9gsnNaO+NLW4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708507695; c=relaxed/simple; bh=3uKwHohhB3aic92O+ME8L8BAtG4fdHDuAqPlhAFi+CU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l+1tuzxVCWjOavqWkRmibeOzd2ubAMGn1Ot68mU7ACvbgLY2gqGXt9H9V6F3GVY/dAmg70VGcW/gGn8Qa+PGnoUFdkcNyQAEqLd5kYHN4eT5ksJhIZx0GMfsdvs+7OrXwHVnPfVgXtm9PDEd0AsnY5XY5vbM0G+9CeTTzwvJoUk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=h1985OuN; arc=none smtp.client-ip=115.124.30.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1708507685; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=dbpOfTRpA7RL14rl+8ySQliZQuoH0mAg7qi1p2q34yY=; b=h1985OuNmMzPVT2MEjzNvkwjO8iGeZGj5HIyJ840Ku6pHvlVK89oIPp2MBbUJXnbvOiXozhRYD2uEk1PeZ4lZzagswPlsD8T4V9zS2yTS+RtyoBZ8ijq+C46pbk4hgD3IFkj6GkA3qU91OTwHXh8s1tqSVQWZyPOVbwvIWk/Zb0= 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: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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)) -- 2.39.3