From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 4E2673BFAD4 for ; Wed, 20 May 2026 22:22:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779315772; cv=none; b=rRKdCwm1g5/68s871liFK5SdClAx7P9lESxicyd3CgrqDU66fTjJCgKxASk346ziNjnrNN0xqekVszmBT1bp6BqpvS1cyss5iZYdpxOw115OC9u0Zii0kWHyf2ZgjvS+DIWa8PsPOWwBS3jqbT4iNVQUknvuyggiPrB318LxCx0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779315772; c=relaxed/simple; bh=5mf25/lf1DdZ8laPTDH+Cdq3xa7RrEIj1yvI/mG2wH0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Vj692gjtmArifR9lhasPH/9VuyR+vMxqyvB8pz/b2jLawGH+t1+C99vCmQ05mC2e9ZIISP867Hed3aCjssQ4YoHWAEUzBg3v77GnZ+DIVF/RLF93Wnv5U6SFPL2/W9wPEMQyjLrFoTVCgg1y2f16G5NOUeOfgupAUQCyQxcuvh0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SnYVyqli; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=ls1A5p/G; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SnYVyqli"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="ls1A5p/G" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779315770; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=19buVa4Rma7mh18uS22QrkEHb5BZSKvMOxe4gXL+M+k=; b=SnYVyqlirTTtXhMir4KaNdDYZnmA27RKHkjTQY1rQglsGpOXbf+fE9Y4lC6L1qp5YeDudj 66bfUzTSL5ndUQ3506wbW/VFH3lxw+wPyGlwowEKo6HmUIz3iHlpfOtyKPHTJIZYXsKFy2 KUgdhqvLq9fP9jqShUEZ+2y7SP3M944= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-295-PjtqVb2bNh-8mWSJ_G7V8Q-1; Wed, 20 May 2026 18:22:49 -0400 X-MC-Unique: PjtqVb2bNh-8mWSJ_G7V8Q-1 X-Mimecast-MFC-AGG-ID: PjtqVb2bNh-8mWSJ_G7V8Q_1779315768 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-48ff0eb77b5so51033355e9.0 for ; Wed, 20 May 2026 15:22:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1779315768; x=1779920568; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=19buVa4Rma7mh18uS22QrkEHb5BZSKvMOxe4gXL+M+k=; b=ls1A5p/GCtZbUmqMsglb0U2Lwyr8EzKBW9BE7ZHAVe+da/EvKzaBvw7V8FMJKlrSfw O0xkeCr3cAEoOtVwVmXgNDYofxqmQhr4fMwRR2jXpRAoLpSPh4MwDcPXYDDAsgl82183 JBMB89EOxzksuGvUbeuk5muP76FdAaxHAq5Z3UJbxHLOnPmgkoYXPeJrAsmd7ehZBG6n B43q0D3HCfhD5AQXAzBEPF/48u0/o75+fQRt8VjEN0zMjNPmbQfyPiU4e5JqII7iPrEV EUDju0hMj/VTfjcrY+jQZFSDenEU2or+GyAA040+H1E7WrbxzzoxfAHLCGmojVz8JLIW +4pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779315768; x=1779920568; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=19buVa4Rma7mh18uS22QrkEHb5BZSKvMOxe4gXL+M+k=; b=heZVCCRV13QDoyVEcTaomXnhYojd9thTRAMy+3T+va/BO053lCLJKKmAtJ13C/NFU3 UYBOXbryTlfzAx/QZMfyf3XzwIpxz77EQUfyqKsu3UrGKKpFT/si3HpzNaSCfSe+CG8q xhE+QQ+zkHNcV1ptLn3gXW6Ihsn4GInvtoTbq+1dEhUy0k181U9gtKZrFYBPYuaZX0sG wSA0tBfvCmlo9wpqspDNnfAmXtBZgGFlPGB+Wmh+mje6cKfcQBsGMjd8YAQBncHY21t9 8V16IsWRX73Fr9QvcA6UzYhpe9VsODis+1BoskF9DWYHJzl5Lub8iLS9rgd5BDTFIxSn Owkg== X-Gm-Message-State: AOJu0YzodKVn8XMOax/aQ4KIYMQLAcl8ngOsqyOnR+D7/BLipxMBEOIg SYndh5FeuWj+P7cTFeWGWlKhYDFOnPH3o1MwVeA02KFXPR2sWAK5qUrSEd6p9XS575I05sAFhjX DhcKjOEtw8RkgvwoGCPE3I0QBESbSiDWXZ654uVSBe+nhVx/AsS/ny2BAhwBteWLIE2qWNVHwpU Yq8d3HT+OJ1OJyT6T4kEy00/voov75xeqDFCazUMdb0e0= X-Gm-Gg: Acq92OHUTep0BJlg53WxY+bhUWB5iBDLhgJ+uxgUtfQcu6O5Lwr6noAKJsfQv4Bx/qf BVPtVcablNkx7/HMPLNhCii9LycyBGamf0xW+JpmMVT0DM8HuFDSo7TM5A5TOyfTgDXM4ORwmPP tsFi+8LJeMZDITTygPqnHJGiV6sDw6IdKCeIHWAbizN0goBGmHqyrryVqXKGJfT/AEIdhK0tpmx OYJgRoElZk/18XZ4eE/BmfsmkBzguXC33nUh5xYpxccTXTk1c1ArH8XejhZJNWwy2cu30NiquvA qyZyvnKVc0IXohT7VGZXRscqbv0q3RzAK1OWseJjjrqMasEedzHpruiT9xh8Koi20F4+TBpU8RN boOoIcJ464QbE5H2DKkeOR8SbIGiNqWRg7tKl2EnG4Vw= X-Received: by 2002:a05:600c:c086:b0:489:1c5f:3a9e with SMTP id 5b1f17b1804b1-4903606bb2cmr2183615e9.13.1779315767778; Wed, 20 May 2026 15:22:47 -0700 (PDT) X-Received: by 2002:a05:600c:c086:b0:489:1c5f:3a9e with SMTP id 5b1f17b1804b1-4903606bb2cmr2182985e9.13.1779315767276; Wed, 20 May 2026 15:22:47 -0700 (PDT) Received: from redhat.com (IGLD-80-230-25-45.inter.net.il. [80.230.25.45]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49035f52a0dsm1490795e9.24.2026.05.20.15.22.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 15:22:46 -0700 (PDT) Date: Wed, 20 May 2026 18:22:42 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: "David Hildenbrand (Arm)" , Jason Wang , Xuan Zhuo , Eugenio =?utf-8?B?UMOpcmV6?= , Muchun Song , Oscar Salvador , Andrew Morton , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Hugh Dickins , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Christoph Lameter , David Rientjes , Roman Gushchin , Harry Yoo , Axel Rasmussen , Yuanchu Xie , Wei Xu , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , virtualization@lists.linux.dev, linux-mm@kvack.org, Andrea Arcangeli Subject: [PATCH v8 26/37] mm: page_alloc: preserve PG_zeroed in page_del_and_expand Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Propagate PG_zeroed through buddy splits in page_del_and_expand() and try_to_claim_block(). When a zeroed high-order page is split to satisfy a smaller allocation, the sub-pages placed back on the free lists keep PG_zeroed. Signed-off-by: Michael S. Tsirkin Reviewed-by: Gregory Price Assisted-by: Claude:claude-opus-4-6 Assisted-by: cursor-agent:GPT-5.4-xhigh --- mm/page_alloc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ff614e422eec..72e52f049cf0 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1715,7 +1715,8 @@ struct page *__pageblock_pfn_to_page(unsigned long start_pfn, * -- nyc */ static inline unsigned int expand(struct zone *zone, struct page *page, int low, - int high, int migratetype, bool reported) + int high, int migratetype, bool reported, + bool zeroed) { unsigned int size = 1 << high; unsigned int nr_added = 0; @@ -1746,6 +1747,8 @@ static inline unsigned int expand(struct zone *zone, struct page *page, int low, */ if (reported) __SetPageReported(&page[size]); + if (zeroed) + __SetPageZeroed(&page[size]); } return nr_added; @@ -1757,10 +1760,12 @@ static __always_inline void page_del_and_expand(struct zone *zone, { int nr_pages = 1 << high; bool was_reported = page_reported(page); + bool was_zeroed = PageZeroed(page); __del_page_from_free_list(page, zone, high, migratetype); - nr_pages -= expand(zone, page, low, high, migratetype, was_reported); + nr_pages -= expand(zone, page, low, high, migratetype, was_reported, + was_zeroed); account_freepages(zone, -nr_pages, migratetype); } @@ -2356,11 +2361,12 @@ try_to_claim_block(struct zone *zone, struct page *page, if (current_order >= pageblock_order) { unsigned int nr_added; bool was_reported = page_reported(page); + bool was_zeroed = PageZeroed(page); del_page_from_free_list(page, zone, current_order, block_type); change_pageblock_range(page, current_order, start_type); nr_added = expand(zone, page, order, current_order, start_type, - was_reported); + was_reported, was_zeroed); account_freepages(zone, nr_added, start_type); return page; } -- MST