From patchwork Thu Oct 17 06:44:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hua Su X-Patchwork-Id: 13839497 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 B7C1BD2F7F2 for ; Thu, 17 Oct 2024 06:45:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0AD606B007B; Thu, 17 Oct 2024 02:45:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 05E036B0082; Thu, 17 Oct 2024 02:45:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E672F6B0083; Thu, 17 Oct 2024 02:45:19 -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 C6BDF6B007B for ; Thu, 17 Oct 2024 02:45:19 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 89A71160A05 for ; Thu, 17 Oct 2024 06:45:07 +0000 (UTC) X-FDA: 82682157474.28.C44946F Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) by imf13.hostedemail.com (Postfix) with ESMTP id E942D20008 for ; Thu, 17 Oct 2024 06:45:07 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OjO1b8Ov; spf=pass (imf13.hostedemail.com: domain of suhua.tanke@gmail.com designates 209.85.210.52 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=1729147443; a=rsa-sha256; cv=none; b=NxBo0Bl5n8YbBo9MvEz6WYtPqitypIZGj9+EgvCngK4gf1Eds7AKUDOBEFhRdPEI1IxvAK L4H+frgio8NzHEsO6+JMpa3k/Ijz2BZeuFWtT5NFCbaH1COwmMg2kXzbhqjYHJRb7Adx5f x6dgaesvdCEm5KYTc9jL8h8nRKNMSN4= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OjO1b8Ov; spf=pass (imf13.hostedemail.com: domain of suhua.tanke@gmail.com designates 209.85.210.52 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=1729147443; 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=eg/dARpVJ2zTTx8pkql0HrYbCe1sx56SrqKsQKDyKAU=; b=shwfGkBTRUQoU20e320QpuIf17oEICZdKCNQvHG+AryQPoV3XnSlSxYTFlgb6xL4p4N9Ky xe0GeI1nMwBfhf0Wjmc6zn/blhLIOwrWz6x3OwLzsRSTt+5ouHCu19H7yXj0pGVQkH6lPC VBkWyHdHTLCeZ2AhPC/H8kSrS/+MVEw= Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-717d3ca6a68so327570a34.1 for ; Wed, 16 Oct 2024 23:45:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729147517; x=1729752317; 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=eg/dARpVJ2zTTx8pkql0HrYbCe1sx56SrqKsQKDyKAU=; b=OjO1b8OvqwdRWPrgU/34uVvumNO3r0W7JEdk+Cq66+pj6nn/a1TbiKIpgkDDQwxJri 43UYru1lrrhSsuZmrNibGC9nVit1VjF0w/9UnC9sV1i+paFVahOm6dWDlZWYMK4Nuq0q 5PJVNKBnCBdqRBVfpRGRzNwKde5IDCNhTwnWLIfo8VcTrNYi/ghPLrQhoDE4GK6J3Ol9 l/0G3P8bs2LY04oVoQyy2mfvxylKlsJnvBuPeTGWOYjMmtgynuXwGnbfkzyTJ+TsTVF0 TJHfbkKv6BAZ3VwxAiEba7Byr/FlezZhPABHDfoaTGLxIpNRnNCyHHcOpSdllWfZ1Pnv 0ELA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729147517; x=1729752317; 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=eg/dARpVJ2zTTx8pkql0HrYbCe1sx56SrqKsQKDyKAU=; b=Y3iGuZtKiNTi1O5FJwwk+UbOR+6oA0/FbABFVRAdv/Aushq/0W8HWRd1u4FEBrgkkr eurbHI978ZwsPeg29lo8hpE4gBoiKJ8dxCZvrfG52HK48MIoKrs+6mpo8HbWHD6omrAZ XMZkXj2fq3sW6N8vjnU97731aMfNb2M1cQR4o+pSU3df6wtW8PBm94hNz09V9cjnk2p1 JwU+Ow0wHut7r5qhBvBf7dynOCtPAiW3rDbmLtZqmE3GnoJzOBVk3t5bH+lW9bBB6+lb xdOE+BHZgou20doYcz4+TzZmH9w/Zhc6YTkvfIxsseZeN//ltI3Dmmmng7dl5meRG/xA ZL1A== X-Gm-Message-State: AOJu0YyGJgspbeQ400tjP6opd5fRbqCjpp25J4O5QpIBOHRHR+C84xv2 B//+2oi+221jmXZoeTsrCxmn8HkMAKNxtB7NGRMFAKBmN3M3EiHH X-Google-Smtp-Source: AGHT+IF1DJW63BwhM/9vKTDCclBnJXSQwNkkDV6bcfzfZaiy4cL0voT2x8uYBIqZgOWO/E9pCDkYjA== X-Received: by 2002:a05:6358:248f:b0:1b8:6074:b53 with SMTP id e5c5f4694b2df-1c3783f58f7mr579392455d.10.1729147516676; Wed, 16 Oct 2024 23:45:16 -0700 (PDT) Received: from suhua-virtual-machine.localdomain ([36.112.24.11]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7ea9c715c17sm4313391a12.84.2024.10.16.23.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 23:45:16 -0700 (PDT) From: suhua X-Google-Original-From: suhua To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, suhua.tanke@gmail.com, suhua Subject: [PATCH] memblock: Uniform initialization all reserved pages to MIGRATE_MOVABLE Date: Thu, 17 Oct 2024 14:44:49 +0800 Message-Id: <20241017064449.5235-1-suhua1@kingsoft.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Stat-Signature: qgtgq41uctbnmik3wgao4ijohmqgyosx X-Rspamd-Queue-Id: E942D20008 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1729147507-787933 X-HE-Meta: U2FsdGVkX198m+tzfEdv0KzkkDFkuJ6lfUtwO/aZTk0pL5uOc7+5lOTa625L28JptUYpKDgXdlorsGG7Ps2u6aIp7Lmyolu3jrCOLC7RPgjFI0HmTJxV750TICQs4Pgr4LEK5X2AeJRx6xFdbdnLVV1JO1QLWYn1DZjfoBm4dTilz5IFyfwSoJz6WdtmTc0Wb0IpGDvfeidch9CcCJtvzuAxgOibwydFWApkmvae98ocSUx6cMWsfrQHhzR1lmevos3bwSuy+U2N3Vr/uHnnhs3y2M2ksvQYppHjZOabgjYtBDfPeEL0whO5mqeFUUczK073+9ucFToAYebXw45JlQsVeP43ClcI5ck8TlZYHq3OycXDlPa3W+Q/l8b7gvz1Bd8pa5Mvd5SBmvZGyrAWjq2txzj+f4S0tyGCQQep3hYSgfSDXvZCG+xkSACy1SkqUHnnKtkwym90mxX5ImHvYwltP0olIxAwj+lTOd4W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ity: Ham, tests=bogofilter, spamicity=0.000019, version=1.2.4 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 stores the metadata of struct page. When HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON=Y and hugepages are allocated, the memory occupied by the struct page metadata will be freed. 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: echo 500000 > /proc/sys/vm/nr_hugepages 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: suhua Reviewed-by: Wei Yang --- 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