From patchwork Mon Oct 21 05:11:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hua Su X-Patchwork-Id: 13843558 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 DC86ED3C93D for ; Mon, 21 Oct 2024 05:12:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61F5C6B0083; Mon, 21 Oct 2024 01:12:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CFBE6B0088; Mon, 21 Oct 2024 01:12:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 497006B0089; Mon, 21 Oct 2024 01:12:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 27A606B0083 for ; Mon, 21 Oct 2024 01:12:29 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B10B6815F8 for ; Mon, 21 Oct 2024 05:12:15 +0000 (UTC) X-FDA: 82696438650.29.7D2FFF4 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf27.hostedemail.com (Postfix) with ESMTP id 580A64000B for ; Mon, 21 Oct 2024 05:12:12 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mGSpMABC; spf=pass (imf27.hostedemail.com: domain of suhua.tanke@gmail.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=suhua.tanke@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729487348; 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: references:dkim-signature; bh=IsHb9+hp0hI9PDOsgwvZsutcEgaMa7sk2a/4tz58Qi0=; b=oaahTZM+EdfB1fW7J5U2ZkopSiwfbvJFYo9vYH19MHH3lRzgkNybgea4ZkxnzxIxLGCfQk i+/URdEdVd8VqOPrhT2PzcSaBVDEEPZ0LitReLSMgoR/chMw9UVJzy1CIanaikW6vJeQM7 xP8qhuCiBcPUgyY+W1Iljc67VMPxYvE= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mGSpMABC; spf=pass (imf27.hostedemail.com: domain of suhua.tanke@gmail.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=suhua.tanke@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729487348; a=rsa-sha256; cv=none; b=pzn253SWcC1DORSOFIZhoulkYyjOmAYPbb7r4mS401I3X2WpWY3utho4Z+yxbxQfW7mtJ4 uZGRHPmiHg+QvUmIs/a/trcxZtoU9gqWIE8Md+7sd2vcUPTq04AXxuP+IH938wL75e4zGx 7v7N9BCvZcUeXViIp7qPOHQCr02gIBk= Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-20cdb889222so38976195ad.3 for ; Sun, 20 Oct 2024 22:12:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729487545; x=1730092345; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=IsHb9+hp0hI9PDOsgwvZsutcEgaMa7sk2a/4tz58Qi0=; b=mGSpMABCvQ07NPZvDiS8fh12RN7xgMz3agjuehqob2BTLEJTwDms+dd+m7nYduiIO5 HRVv41JaTuJFnyLhQ07pLzClWWtsJq2SFcG7EL7w6XpKKdhvf/qZWMtCNTku9eKRL1OK B1YA3krvTz/bIEG4/7TCoCdOOIH1S6+S/AqZRxclCT61cjGokTJypPO1LO/WX6512Y7x uggKEYJnj2kBoi2mk2Q5h6Y4yTKCHASzzdBmi/jmkY4ZobStJ74HTZj5ZZcfySLNtF6C rktitWkINapzo5Qt1wHWzR9NBhCvpC+uulbsVEwZfdOAhX+ZpQFJelIRfixbc5L7iCOs TxVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729487545; x=1730092345; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IsHb9+hp0hI9PDOsgwvZsutcEgaMa7sk2a/4tz58Qi0=; b=ZVoDG4L0psXpgdbwrwARWKb9Kbe0pE0zDNdyoSSreYhM4ASQGkSuFyTTBZmpJKBl+D ztaSCxv4bjIp7nm2cb+r9296njYhUB2Gv7867VQNp5vNpDRI2q/CjrINY0tg3wBi6BEF I69bRwfNfjOPzVbgFDbcJ/J2g8KWxiY/rcr9ygS9rZSXhyEMql22HKXZDLDUPO3P8yd+ QE6JK7cojfjCsNq7u51SXJ7we64UpKbZ+5qb498EyWUaZPtx6PXLfO7/nW6xIBPm+DEt QblIHzXbO8vORacQ0emgBpbR3xGbyH0DLLtwAyhiPivLhrfUa5a21JxV/Ib4GQi1YE+g w33Q== X-Gm-Message-State: AOJu0YxE/eIgccwMKgUWZV8uZVZgawlpKgpZcpqyA3XS2KWTlTST7aiT Q7+xfFyzMVip59AndYd/Ar6La7J0LImyy51ufjNZ73JxwgJO/Cfg X-Google-Smtp-Source: AGHT+IEEd6fksooFUBRMO+r7hmkAlcF9h4gJUG3DYHqoX0nkc7D5yPu+3IJVk2ia2lpsxmM+TxSuGQ== X-Received: by 2002:a17:902:d484:b0:20c:98f8:e0f5 with SMTP id d9443c01a7336-20e5a8f3e6emr137246325ad.43.1729487545209; Sun, 20 Oct 2024 22:12:25 -0700 (PDT) Received: from suhua-virtual-machine.localdomain ([183.197.220.47]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20e7f0de39fsm17607485ad.206.2024.10.20.22.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 22:12:24 -0700 (PDT) From: Hua Su To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hua Su Subject: [PATCH] memblock: uniformly initialize all reserved pages to MIGRATE_MOVABLE Date: Mon, 21 Oct 2024 13:11:51 +0800 Message-Id: <20241021051151.4664-1-suhua.tanke@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 580A64000B X-Stat-Signature: 8f1t3qtnz91b3k1xf6phojbn1k8y6mo3 X-Rspam-User: X-HE-Tag: 1729487532-743471 X-HE-Meta: U2FsdGVkX18JbnMk5JXoE8S06Dxf+fhJosbFLoKGdcZQslsMx7BsZ3rPR+Cu7MXoSEjOElXMXN8X2TJ9/+52SOW8x0Y8wY/jNjJEXvjR3Z155P8GgZYVtJLzaQXtAPOrjWbOSrJzKH591S9nXRWngZaufjjNqBZyk86Q75eqNfZiMi+exYmiomkAZOAH1BsVdn/1C5Bkq9on/vkyLuRH35Um8CkhPjW0L/uVn1M/wwo/oeixZiufrjM9sYXL+On/BYSa08qmdjQoPtw8/E+cGz9EosgU4ocoKm/WWWR8tDYcAE6a25nQZom/eHhwjsnvdQd2dHt0j/hth3i7xJBuf8O6MyzNmpGiieVj+pxD+MQwDVmaMv9rGcl32WIp8gpGBwIalqx1RM5cgZbLsQ4nyz67ULAPtSC+QljXEJt949V6B8+w45Mlsvf2q/4kjXkRI4ZoV97XGtNK77tervaN2XZNhHN+z3BXDnk2lvDYQwI3ZicfthyVhrPaVZrqOArsS4BJKvm4eyK4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sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Currently when CONFIG_DEFERRED_STRUCT_PAGE_INIT is not set, the reserved pages are initialized to MIGRATE_MOVABLE by default in memmap_init. Reserved memory mainly store the metadata of struct page. When HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON=Y and hugepages are allocated, the HVO will remap the vmemmap virtual address range to the page which vmemmap_reuse is mapped to. The pages previously mapping the range will be freed to the buddy system. Before this patch: when CONFIG_DEFERRED_STRUCT_PAGE_INIT is not set, the freed memory was placed on the Movable list; When CONFIG_DEFERRED_STRUCT_PAGE_INIT=Y, the freed memory was placed on the Unmovable list. After this patch, the freed memory is placed on the Movable list regardless of whether CONFIG_DEFERRED_STRUCT_PAGE_INIT is set. Eg: Tested on a virtual machine(1000GB): Intel(R) Xeon(R) Platinum 8358P CPU After vm start: echo 500000 > /proc/sys/vm/nr_hugepages cat /proc/meminfo | grep -i huge HugePages_Total: 500000 HugePages_Free: 500000 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB Hugetlb: 1024000000 kB cat /proc/pagetypeinfo before: Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10 … Node 0, zone Normal, type Unmovable 51 2 1 28 53 35 35 43 40 69 3852 Node 0, zone Normal, type Movable 6485 4610 666 202 200 185 208 87 54 2 240 Node 0, zone Normal, type Reclaimable 2 2 1 23 13 1 2 1 0 1 0 Node 0, zone Normal, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Isolate 0 0 0 0 0 0 0 0 0 0 0 Unmovable ≈ 15GB after: Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10 … Node 0, zone Normal, type Unmovable 0 1 1 0 0 0 0 1 1 1 0 Node 0, zone Normal, type Movable 1563 4107 1119 189 256 368 286 132 109 4 3841 Node 0, zone Normal, type Reclaimable 2 2 1 23 13 1 2 1 0 1 0 Node 0, zone Normal, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Isolate 0 0 0 0 0 0 0 0 0 0 0 Signed-off-by: Hua Su --- mm/mm_init.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/mm_init.c b/mm/mm_init.c index 4ba5607aaf19..6dbf2df23eee 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -722,6 +722,10 @@ static void __meminit init_reserved_page(unsigned long pfn, int nid) if (zone_spans_pfn(zone, pfn)) break; } + + if (pageblock_aligned(pfn)) + set_pageblock_migratetype(pfn_to_page(pfn), MIGRATE_MOVABLE); + __init_single_page(pfn_to_page(pfn), pfn, zid, nid); } #else