{"id":2223483,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2223483/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260415111412.1003526-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":"<20260415111412.1003526-7-songmuchun@bytedance.com>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/20260415111412.1003526-7-songmuchun@bytedance.com/","date":"2026-04-15T11:14:12","name":"[v2,6/6] mm/mm_init: Fix pageblock migratetype for ZONE_DEVICE compound pages","commit_ref":null,"pull_url":null,"state":"handled-elsewhere","archived":false,"hash":"c4eaab2cf037ce14251f7d13ef4871fda663570d","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/20260415111412.1003526-7-songmuchun@bytedance.com/mbox/","series":[{"id":499970,"url":"http://patchwork.ozlabs.org/api/1.2/series/499970/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=499970","date":"2026-04-15T11:14:06","name":"mm: Fix vmemmap optimization accounting and initialization","version":2,"mbox":"http://patchwork.ozlabs.org/series/499970/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2223483/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2223483/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linuxppc-dev+bounces-19769-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=jDglYO+g;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-19769-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::634\"","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=jDglYO+g;\n\tdkim-atps=neutral","lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=bytedance.com\n (client-ip=2607:f8b0:4864:20::634; helo=mail-pl1-x634.google.com;\n envelope-from=songmuchun@bytedance.com; receiver=lists.ozlabs.org)"],"Received":["from lists.ozlabs.org (lists.ozlabs.org\n [IPv6:2404:9400:21b9:f100::1])\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 4fwdpm2xHRz1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 21:15:12 +1000 (AEST)","from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fwdpX5hjKz2yxk;\n\tWed, 15 Apr 2026 21:15:00 +1000 (AEST)","from mail-pl1-x634.google.com (mail-pl1-x634.google.com\n [IPv6:2607:f8b0:4864:20::634])\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 4fwdpX0HcPz2yxf\n\tfor <linuxppc-dev@lists.ozlabs.org>; Wed, 15 Apr 2026 21:14:59 +1000 (AEST)","by mail-pl1-x634.google.com with SMTP id\n d9443c01a7336-2b24fdac394so60010325ad.3\n        for <linuxppc-dev@lists.ozlabs.org>;\n Wed, 15 Apr 2026 04:14:59 -0700 (PDT)","from n232-176-004.byted.org ([36.110.163.96])\n        by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-2b477fd3724sm19509485ad.0.2026.04.15.04.14.52\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Wed, 15 Apr 2026 04:14:57 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1776251700;\n\tcv=none;\n b=C4P9jNDG13Wbu/ZyaoW3f1ALfY/bvq7gNVo3rFBqikvAuRerIqQTnXGTSJwGzwS+DmstTuGKU2otEborrUu+5WO4GhSXLyyfxBD1dNfvHvIzF5W8m7rpGMfBy0bfK7j8B0QToA7Ngf2fuxNMR3qaMvZ5h+/btFD3S2TpzLrpkr00InnxZ4Oc4iX6wYufsPa/13INIEjHtSrIOrdRqSOXaVLbZRLyFr/O3ACmeqa19egLXhLL7TdER2LvwSDAgXIeRhjDJB0zOxpuoVQGJEl1bIrYfgQtVhKYerLzaanHtvq2dUeNLVFCOalTR+B03ZgeA/25V79R0v4ZCskQvJ7hoA==","ARC-Message-Signature":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1776251700; c=relaxed/relaxed;\n\tbh=M2tbh3r8pv+EpSWaqLjjsd7slEO4DRhf7DkjZnRXEmM=;\n\th=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:\n\t MIME-Version;\n b=LG0JmXorB9xhm/5QrBf83kNgwwhbQMkqhcTV2cRAttZW34IH1LLKImdT2HtFFO84S4NEHSsMoeIeuQCDZFIhQpgelSFEM1BgyvestmL4DnnWgCW6A+iy6E/LhpwqjpLSPxeyMCyu1icUbO5zQ7wV0b0ElhffxM9pRwrHY77jAF6LU6Kh6SBcBEkMEzRVAjqOyMsyP35fKEiJE2u/0dBS6qvgj3mqHehLLlRFSFOuX6EwfVF24YnJ9i8YfwIbYRPkNA8x9mxNl4N/TuP0Xe54Rb2ClgsFXdIF9DbOxyZa2FB9WDHmbmJ1co6cLilmfhXEQ9U8ahmuoVhWRKwPJkyngA==","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=jDglYO+g; dkim-atps=neutral;\n spf=pass (client-ip=2607:f8b0:4864:20::634; helo=mail-pl1-x634.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=1776251698; x=1776856498;\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=M2tbh3r8pv+EpSWaqLjjsd7slEO4DRhf7DkjZnRXEmM=;\n        b=jDglYO+g3Kzd49bALq4htgBWzE0VktPX5PHVaWL1VSOTQKBZe5uESv65e0gxP+s3Wd\n         ZzQzM1EtcXoeOpvuFoHHcUs7zke3dV5xyhL4T1WymSWmDhy6ug5139pU13++pG6XI23t\n         DpmpapHOaLKfzr4CoqZQCpr6GIMAgsZdJPofhx2VDoW11bfNRmVylK6jNiSBAb+ehhtl\n         M9FroG94/QhrWJYTfRRO3Vl+Ke55N2wQ9Vl3cptnRR7/S6CtMmLzvDkSDIhJzEOozWa0\n         64j4eYl1nJZ+iOF8Lx44o3SEhmzdzDwufCrRqbSGi0Fau8dKeU4IK8+eXVZxQScFJ5S9\n         6DCQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776251698; x=1776856498;\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=M2tbh3r8pv+EpSWaqLjjsd7slEO4DRhf7DkjZnRXEmM=;\n        b=qKK8pu2MeeJzh9ZiinRs+65veHk5xuApkVl+MUl/1g+K+hkqx7e7RJ0nvjQ97ruT2j\n         vFCbHWto77l2Rl94WriJOgF1WxcGzCukvcR59C/q8YIfPLpHjOvCT5ceZO6tbpC30kt2\n         k7Y238pZZpHchSWzbtbykjI6+ccfFd3z5NNaykBue+FVBZuJZqqfR0xM6+b+iR7qo37T\n         WzvEHNpRIsJqp6/V9jxmT3YD2UODVwxX4aORDPQ4W0fOLty29GdyQ4D26C2Em7Y210u/\n         Es0sKI8fPHk15bHIfkbg6OkeaU3IYcEeFTlx7/vhpO/gOwKTXRoRTT03GdITxuXTLFvV\n         AUTQ==","X-Forwarded-Encrypted":"i=1;\n AFNElJ9KKPfvDDiKFt8qL8kyR6F7zPCWA0a+zQKWIOWzLGXRepNy0rpPy18l7JvKzW7vZyWgaUQH9zZUBy2ncTc=@lists.ozlabs.org","X-Gm-Message-State":"AOJu0YyoAIH6oay3s8GP9Y3EGIfpqb7BVS+K0dlXiJyE3QMwsgQGZlUz\n\trVjgn6cLns+W/Yn+D35xTd0b5apPsmkD3pUMTbpEf+ZXjdD18TrLAm4w6Fhb9HIeNwY=","X-Gm-Gg":"AeBDieuB7GxH8QhWlDiCtN5Rsv7/o8XUJo8RrAGJD/o2+nThzAZeFfd4U8d4/7RgCoz\n\tNysAM6cHdjw1ft0cOrOhw3iO7ZKG/07Z/d/k74VGVxg4KU5dTPylXEk9JCRibE6k4WRZbDgYruu\n\tPUPiH7U31DtYL5G75FP6nPnLke7eiJXr4J4Ph37t9uU48kkaecmxC6q0sfWaNndujUW2+ZsH92E\n\t3zJItHUVQ8bRcAGsj4owxeO/EvZXV133jmLl7euC2VbVobAEJaaQpiD0kkApbLRQqyFYBlCmRje\n\tZjAHcsxG9BkZiIORNJNc24y96fzOqKiBNs/8zClzUeDhztga+efIOTrPzYWH3w89JipvC29NfoN\n\tnShMFUTyBpVe2ygBByT3PQYVq6mttybJ5O+94Zb8ZnlfGOKVRIJ3cEK/hop/iHaeXt57qKeF6ju\n\tvUSIKTqwjwL5JmT8tc8WTVeqhtIYFrN6foqq7z4JQLfVI=","X-Received":"by 2002:a17:903:1a24:b0:2b4:63c8:ce18 with SMTP id\n d9443c01a7336-2b463c8db7emr113441015ad.12.1776251697718;\n        Wed, 15 Apr 2026 04:14:57 -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 v2 6/6] mm/mm_init: Fix pageblock migratetype for ZONE_DEVICE\n compound pages","Date":"Wed, 15 Apr 2026 19:14:12 +0800","Message-Id":"<20260415111412.1003526-7-songmuchun@bytedance.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20260415111412.1003526-1-songmuchun@bytedance.com>","References":"<20260415111412.1003526-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":"The memmap_init_zone_device() function only initializes 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 remain uninitialized.\n\nMove the migratetype initialization out of __init_zone_device_page()\nand into a separate pageblock_migratetype_init_range() function. This\niterates over the entire PFN range of the memory, ensuring that all\npageblocks are correctly initialized.\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 | 42 +++++++++++++++++++++++++++---------------\n 1 file changed, 27 insertions(+), 15 deletions(-)","diff":"diff --git a/mm/mm_init.c b/mm/mm_init.c\nindex f9f8e1af921c..30528c4206c1 100644\n--- a/mm/mm_init.c\n+++ b/mm/mm_init.c\n@@ -674,6 +674,19 @@ 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\tif (IS_ALIGNED(pfn, PAGES_PER_SECTION))\n+\t\t\tcond_resched();\n+\t}\n+}\n+\n /*\n  * Initialize a reserved page unconditionally, finding its zone first.\n  */\n@@ -1011,21 +1024,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 +1120,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 +1129,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":["v2","6/6"]}