{"id":2219931,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2219931/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260405125240.2558577-7-songmuchun@bytedance.com/","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/1.2/projects/2/?format=json","name":"Linux PPC development","link_name":"linuxppc-dev","list_id":"linuxppc-dev.lists.ozlabs.org","list_email":"linuxppc-dev@lists.ozlabs.org","web_url":"https://github.com/linuxppc/wiki/wiki","scm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git","webscm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/","list_archive_url":"https://lore.kernel.org/linuxppc-dev/","list_archive_url_format":"https://lore.kernel.org/linuxppc-dev/{}/","commit_url_format":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"},"msgid":"<20260405125240.2558577-7-songmuchun@bytedance.com>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/20260405125240.2558577-7-songmuchun@bytedance.com/","date":"2026-04-05T12:51:57","name":"[06/49] mm/mm_init: fix uninitialized pageblock migratetype for ZONE_DEVICE compound pages","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"9f6dd1a723410ec602f0cea64f81ffe1a64c3034","submitter":{"id":78930,"url":"http://patchwork.ozlabs.org/api/1.2/people/78930/?format=json","name":"Muchun Song","email":"songmuchun@bytedance.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260405125240.2558577-7-songmuchun@bytedance.com/mbox/","series":[{"id":498783,"url":"http://patchwork.ozlabs.org/api/1.2/series/498783/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=498783","date":"2026-04-05T12:51:51","name":"mm: Generalize vmemmap optimization for DAX and HugeTLB","version":1,"mbox":"http://patchwork.ozlabs.org/series/498783/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2219931/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219931/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linuxppc-dev+bounces-19336-incoming=patchwork.ozlabs.org@lists.ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=bytedance.com header.i=@bytedance.com\n header.a=rsa-sha256 header.s=google header.b=An/jjgi4;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=112.213.38.117; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-19336-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)","lists.ozlabs.org;\n arc=none smtp.remote-ip=\"2607:f8b0:4864:20::1032\"","lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=bytedance.com","lists.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=bytedance.com header.i=@bytedance.com\n header.a=rsa-sha256 header.s=google header.b=An/jjgi4;\n\tdkim-atps=neutral","lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=bytedance.com\n (client-ip=2607:f8b0:4864:20::1032; helo=mail-pj1-x1032.google.com;\n envelope-from=songmuchun@bytedance.com; receiver=lists.ozlabs.org)"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fpXTY1zP7z1yCs\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 05 Apr 2026 22:54:09 +1000 (AEST)","from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fpXTR0gfYz2ynZ;\n\tSun, 05 Apr 2026 22:54:03 +1000 (AEST)","from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com\n [IPv6:2607:f8b0:4864:20::1032])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 4fpXTQ295kz2xMY\n\tfor <linuxppc-dev@lists.ozlabs.org>; Sun, 05 Apr 2026 22:54:02 +1000 (AEST)","by mail-pj1-x1032.google.com with SMTP id\n 98e67ed59e1d1-35d9c7bf9a1so2804258a91.3\n        for <linuxppc-dev@lists.ozlabs.org>;\n Sun, 05 Apr 2026 05:54:02 -0700 (PDT)","from n232-176-004.byted.org ([36.110.163.97])\n        by smtp.gmail.com with ESMTPSA id\n 98e67ed59e1d1-35de66b4808sm3748505a91.2.2026.04.05.05.53.54\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Sun, 05 Apr 2026 05:54:00 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775393642;\n\tcv=none;\n b=jzTRD/BdIKRH/Jy9W0bWxyPPLnBHVbIM+uMxy8H8lwAbTTZacHm2J8FgOOdqcEYs+GQweUFAjdpetckRka19Fk/cPKXeZ25UKVDYa17QY75yj8QdZfL369knAGhsw2fdY603ZICqr8GwDpvl52kPcgHvxJ91b8UdtSYgxjeqPYYj35PLO/ig2u3wI6eJM7H3bII6MkUTChWjgi8qG81e3/SxZBpYCKLi03BQlBZD2/prkgbdlhl4L6o2A2eoPcVs4uTsihlrfAUe9mqFY2tZ9G2g9/NiXOyTRTsVU7Nh4oyhkXbxu1JJxD6pMNVeB1oEm3A3npVUINZNdYLwKWilZw==","ARC-Message-Signature":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1775393642; c=relaxed/relaxed;\n\tbh=XDmw/QSiGpmicKvHs3oRyZcvGRBcNXeGZ4EHaUFkJWQ=;\n\th=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:\n\t MIME-Version;\n b=dDyuBNhHwBNJFIsLrSM50El5k3RqaPvGqVLhSWe1TGYXKh1JLe05drL1l23P1KcMEsnZlt9LunUaAVmLTvv4I8L9nhkP84wHfk1S1tM12dveXCwqnnAcGO4RXvhMs/50yJzix4XfCQ92GfwxscPBaq9xjj9Il5kdGzqoTL56+B7xWsLuLd4qsmnUl/NjWHkHxBj4qua7vyIIFrmax6q95+ZLMa+HHti/eVm1nDmmFzw/lFC4XJt66dvCfh+kMUeptV/m4BhK3gJbkDIZCF8pdfKEypggM1k82Fk7fdQl+0N3oAUfiZoZwBimppWNzDxdYtu8+RJryxRUDQ4YoJOT5A==","ARC-Authentication-Results":"i=1; lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=bytedance.com;\n dkim=pass (2048-bit key;\n unprotected) header.d=bytedance.com header.i=@bytedance.com\n header.a=rsa-sha256 header.s=google header.b=An/jjgi4; dkim-atps=neutral;\n spf=pass (client-ip=2607:f8b0:4864:20::1032; helo=mail-pj1-x1032.google.com;\n envelope-from=songmuchun@bytedance.com;\n receiver=lists.ozlabs.org) smtp.mailfrom=bytedance.com","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=bytedance.com; s=google; t=1775393640; x=1775998440;\n darn=lists.ozlabs.org;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=XDmw/QSiGpmicKvHs3oRyZcvGRBcNXeGZ4EHaUFkJWQ=;\n        b=An/jjgi44ohLpm+4oSzPVsH8vNY/bUpGHPaS1ZuhSo4RZBNNNlmI1icaRU/D+B7frG\n         cL0ROzuh/KXq27fzyQL7UOGidWVUtTjwX6w1wjwkCmBCcQSBDI935J/h/NNRMkjKl4IR\n         oxflzBQJJ1smM5oUQ49Te4fJgWXMm9ZHnAJA61Vau6x5btrF7iBVnMz1boeF4q79+wL8\n         1p6NXJdFKR8IqDxMd6E4mYIyLOF//QMbWWvsTKn4+1HNC6obAuNqJ6lQSkSZLeO/tVCB\n         ctmHohGmcSoqam8yKvlaPgVNDGCOpBi2qQgMfVX392Y6BXwM6/erxVWc1RXwNu4hPhqY\n         fmMA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1775393640; x=1775998440;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n         :to:cc:subject:date:message-id:reply-to;\n        bh=XDmw/QSiGpmicKvHs3oRyZcvGRBcNXeGZ4EHaUFkJWQ=;\n        b=BHesykLst8/1RhvZFe5vF8hyv/fonSZpSMM/b+h57TcWRSEsPWcZcHdfhhQ3Tl2G2P\n         YS5VEE8mEk0qqhrXEUfkR6YYCQxNEd74O23Ub9i2igJLm6WU/a3ZL1yIUamw2eTdNBhX\n         ERsu9xPm7+bQe823ulj7pU5ShXn8oML3tLSKGznkXqEbZY88CAsQA1IdekkxxA8bumrB\n         6Ydr81CgswQzfLamghjkFCkOBRnG+QsiD7qWMD5XqGVm0f7/EI5ZTAba79T/SBBlLH9d\n         UKpVjdZhhtHJDojYMmIiuMAZxEmjBO5B06f1qlcuSO993X+Bk/snSvu10R6J79VdaDls\n         1U8g==","X-Forwarded-Encrypted":"i=1;\n AJvYcCXe/nq5SpvQeE5uaZD+1RE31tw/GdF+gD5A39iY5C5kylo8lo3244+rJbW2LEKGfMeRcH6HcnjQBY7GBFM=@lists.ozlabs.org","X-Gm-Message-State":"AOJu0YwzEhT7sKFdvx5VEFaNQDkEAz0W200jyQUs8MQL2hSZrveIGC0K\n\tiFYqvqfTqB4/QT7skBI2Hk0QyJXOUJg3xhMYtOfCUZJW5bX9dJX1Hetw5DiL1rbVLEU=","X-Gm-Gg":"AeBDievNDL6iF5wdY50pgQhoL3cvSDCeKGaZyxQMfexnyLgXoSBY/gGnskj6D/hZUdD\n\tUYK349U2tSaX6AY0qpXVe3rxKtzGICDU5dTc47mTXEE0YhbTIzUOM8DmXRF0PeACMe+Zpp/Xe6e\n\tQjq7KwNKXJgWurjBfVvEdVlLoqiWUvGSouX1y8/SWQtEytn1+AkpSKEhr/sRDB8Kerl71/MhAde\n\trkeQFI3frKJ4rO7L2lxOg4/XklenFN352KIrtcA+LsRO3+arGjEmQMc/x7Cfzf4rBIeOhgOXwyL\n\trMhKZXOs53uHfDxSbccgz6e+W7xq4drYGNPj+l+7c1QdqcROQMSQcE3o4FZ9trzWWJk77mVtRly\n\tqOOrLc1Rmoprv2cLahOF8f6iO0+NVTE8PrIWqh2MuihpaCsOuKczaMjbBcfoYVz529/16P7Eoof\n\trBVqlbH1oaT3YBrGVhEOwuiRso4pzRVBTMQ51URN9aWYo=","X-Received":"by 2002:a17:90a:d005:b0:35d:9d28:e897 with SMTP id\n 98e67ed59e1d1-35de699f483mr8490321a91.28.1775393640457;\n        Sun, 05 Apr 2026 05:54:00 -0700 (PDT)","From":"Muchun Song <songmuchun@bytedance.com>","To":"Andrew Morton <akpm@linux-foundation.org>,\n\tDavid Hildenbrand <david@kernel.org>,\n\tMuchun Song <muchun.song@linux.dev>,\n\tOscar Salvador <osalvador@suse.de>,\n\tMichael Ellerman <mpe@ellerman.id.au>,\n\tMadhavan Srinivasan <maddy@linux.ibm.com>","Cc":"Lorenzo Stoakes <ljs@kernel.org>,\n\t\"Liam R . Howlett\" <Liam.Howlett@oracle.com>,\n\tVlastimil Babka <vbabka@kernel.org>,\n\tMike Rapoport <rppt@kernel.org>,\n\tSuren Baghdasaryan <surenb@google.com>,\n\tMichal Hocko <mhocko@suse.com>,\n\tNicholas Piggin <npiggin@gmail.com>,\n\tChristophe Leroy <chleroy@kernel.org>,\n\taneesh.kumar@linux.ibm.com,\n\tjoao.m.martins@oracle.com,\n\tlinux-mm@kvack.org,\n\tlinuxppc-dev@lists.ozlabs.org,\n\tlinux-kernel@vger.kernel.org,\n\tMuchun Song <songmuchun@bytedance.com>","Subject":"[PATCH 06/49] mm/mm_init: fix uninitialized pageblock migratetype for\n ZONE_DEVICE compound pages","Date":"Sun,  5 Apr 2026 20:51:57 +0800","Message-Id":"<20260405125240.2558577-7-songmuchun@bytedance.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20260405125240.2558577-1-songmuchun@bytedance.com>","References":"<20260405125240.2558577-1-songmuchun@bytedance.com>","X-Mailing-List":"linuxppc-dev@lists.ozlabs.org","List-Id":"<linuxppc-dev.lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev+help@lists.ozlabs.org>","List-Owner":"<mailto:linuxppc-dev+owner@lists.ozlabs.org>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Archive":"<https://lore.kernel.org/linuxppc-dev/>,\n  <https://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Subscribe":"<mailto:linuxppc-dev+subscribe@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-digest@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-nomail@lists.ozlabs.org>","List-Unsubscribe":"<mailto:linuxppc-dev+unsubscribe@lists.ozlabs.org>","Precedence":"list","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Spam-Status":"No, score=-0.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID,\n\tDKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS\n\tautolearn=disabled version=4.0.1 OzLabs 8","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org"},"content":"Previously, memmap_init_zone_device() only initialized the migratetype\nof the first pageblock of a compound page. If the compound page size\nexceeds pageblock_nr_pages (e.g., 1GB hugepages with 2MB pageblocks),\nsubsequent pageblocks in the compound page would remain uninitialized.\n\nThis patch moves the migratetype initialization out of\n__init_zone_device_page() and into a separate function\npageblock_migratetype_init_range(). This function iterates over the\nentire PFN range of the memory, ensuring that all pageblocks are correctly\ninitialized.\n\nFixes: c4386bd8ee3a (\"mm/memremap: add ZONE_DEVICE support for compound pages\")\nSigned-off-by: Muchun Song <songmuchun@bytedance.com>\n---\n mm/mm_init.c | 41 ++++++++++++++++++++++++++---------------\n 1 file changed, 26 insertions(+), 15 deletions(-)","diff":"diff --git a/mm/mm_init.c b/mm/mm_init.c\nindex 9a44e8458fed..4936ca78966c 100644\n--- a/mm/mm_init.c\n+++ b/mm/mm_init.c\n@@ -674,6 +674,18 @@ static inline void fixup_hashdist(void)\n static inline void fixup_hashdist(void) {}\n #endif /* CONFIG_NUMA */\n \n+static __meminit void pageblock_migratetype_init_range(unsigned long pfn,\n+\t\t\t\t\t\t       unsigned long nr_pages,\n+\t\t\t\t\t\t       int migratetype)\n+{\n+\tunsigned long end = pfn + nr_pages;\n+\n+\tfor (pfn = pageblock_align(pfn); pfn < end; pfn += pageblock_nr_pages) {\n+\t\tinit_pageblock_migratetype(pfn_to_page(pfn), migratetype, false);\n+\t\tcond_resched();\n+\t}\n+}\n+\n /*\n  * Initialize a reserved page unconditionally, finding its zone first.\n  */\n@@ -1011,21 +1023,6 @@ static void __ref __init_zone_device_page(struct page *page, unsigned long pfn,\n \tpage_folio(page)->pgmap = pgmap;\n \tpage->zone_device_data = NULL;\n \n-\t/*\n-\t * Mark the block movable so that blocks are reserved for\n-\t * movable at startup. This will force kernel allocations\n-\t * to reserve their blocks rather than leaking throughout\n-\t * the address space during boot when many long-lived\n-\t * kernel allocations are made.\n-\t *\n-\t * Please note that MEMINIT_HOTPLUG path doesn't clear memmap\n-\t * because this is done early in section_activate()\n-\t */\n-\tif (pageblock_aligned(pfn)) {\n-\t\tinit_pageblock_migratetype(page, MIGRATE_MOVABLE, false);\n-\t\tcond_resched();\n-\t}\n-\n \t/*\n \t * ZONE_DEVICE pages other than MEMORY_TYPE_GENERIC are released\n \t * directly to the driver page allocator which will set the page count\n@@ -1122,6 +1119,8 @@ void __ref memmap_init_zone_device(struct zone *zone,\n \n \t\t__init_zone_device_page(page, pfn, zone_idx, nid, pgmap);\n \n+\t\tcond_resched();\n+\n \t\tif (pfns_per_compound == 1)\n \t\t\tcontinue;\n \n@@ -1129,6 +1128,18 @@ void __ref memmap_init_zone_device(struct zone *zone,\n \t\t\t\t     compound_nr_pages(altmap, pgmap));\n \t}\n \n+\t/*\n+\t * Mark the block movable so that blocks are reserved for\n+\t * movable at startup. This will force kernel allocations\n+\t * to reserve their blocks rather than leaking throughout\n+\t * the address space during boot when many long-lived\n+\t * kernel allocations are made.\n+\t *\n+\t * Please note that MEMINIT_HOTPLUG path doesn't clear memmap\n+\t * because this is done early in section_activate()\n+\t */\n+\tpageblock_migratetype_init_range(start_pfn, nr_pages, MIGRATE_MOVABLE);\n+\n \tpr_debug(\"%s initialised %lu pages in %ums\\n\", __func__,\n \t\tnr_pages, jiffies_to_msecs(jiffies - start));\n }\n","prefixes":["06/49"]}