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.133.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 D0CEC3BED78 for ; Mon, 11 May 2026 09:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778490233; cv=none; b=OLfFFm7ClOBu+HMu36s3ZFAuAlsK+AWs7buqfoubc5DEeiqes4WFNiKARlk13wrA6U7X5frdjRJTzkSSSbx3A+8vnHuE67ftxq1fw5ag9ycs5Kr5PiyfxKALmpnUAUy8SCRrj2HkYfPJ3otNVBzOQJYsffA7ZH7zwhnuHA4z9nM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778490233; c=relaxed/simple; bh=NGAOCZ1WWFki8ZjzkCn4xgO9pK8NqvqtlCATI7T+TGs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sr3U+XsR7cl/6jFj2M/yrWPlFJqIv1yAj3FWiZwTBOls8rfRV1KTGBNg5i7G4p22d4cjITU7wWSs2MQDkjvh5jHfpf1KBhDZQq/72iyZAh/hS1W7fwG1j8LiDsR9mWrkLP2cyO+J+rd5uag2S3xfv/RHjYcJIz7gSdmgfC5NSZg= 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=WK+CRUrs; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=F5jpqNzq; arc=none smtp.client-ip=170.10.133.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="WK+CRUrs"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="F5jpqNzq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778490231; 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=ahWBOyIHSf1xwmLBF3en/Ugor1Y2nztY4A6z0DPh0SQ=; b=WK+CRUrseA99QuFnBgWmKTwyobarp63BCqrKVfiOMA6XApdqzTDQLbGebV+2w7p8SjLqPv ideDgPh09G9D5CElzK/tZNQJBpps47bpRmGehgLZmTgL3lYfLMblM8bUbSFAIP6MlW6lai r5iMqg+nDwClIfXBVj8f2HMeR2cVecE= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-394-yaZphVDiPLGbdwSIP95b3g-1; Mon, 11 May 2026 05:03:49 -0400 X-MC-Unique: yaZphVDiPLGbdwSIP95b3g-1 X-Mimecast-MFC-AGG-ID: yaZphVDiPLGbdwSIP95b3g_1778490228 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-44d68ed8f95so3208679f8f.1 for ; Mon, 11 May 2026 02:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778490228; x=1779095028; 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=ahWBOyIHSf1xwmLBF3en/Ugor1Y2nztY4A6z0DPh0SQ=; b=F5jpqNzqP+uwXv2N4F12X9KbimgK1F97WdhdP3tlhcHDrZwPQ3VblAntG7nTUCbhc/ qEJyHSb4VAwogBHgxv2FBMHlW/6oIiA3f1jJkxfpCk2Jk8GVpnk/qQ7291J7nUl0Hs41 BsjeeifDmADsnSTgciV0II+y0sXOPKYrsyiptrMb60cgf5/WaS09l3zif/Z/e3iMkyWz rGpq9picAQwBJ8lUyHnxm/F6CwdT61BfBVr0Rs1Y565YKFmYi3eyDvrRc3qfNCRI/MrR qAkF9+mvVIR/sqbxAxZ2uLnA7xjNKhCZrWSEb+XwAqLdx+iq61EPnWMjUbK5ZMMUDy0C C6oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778490228; x=1779095028; 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=ahWBOyIHSf1xwmLBF3en/Ugor1Y2nztY4A6z0DPh0SQ=; b=M2cu+fxnLz9DcpDdlESxK2qoQYvUykbb+3CcthRskyHcZbYng+cT3Yj582YqZnGX5I ANTVGcWENKU/4AW2Vzvi9XoS2zerQe+6e3d1hbvYdU7uA3Zi40KK7eS3W6bMTjimAQ2H dWBSUImjycb3iblI/k45eC6GTI6jHP7pRrMGdcUdDIWnoQKhyDLS0r/Ruiz690B46MsA exwIP6U6y/0Ru5oR0zxyNjB1ksLgbhlUKiYQmbBAPdrGYWq+GQZ5d1Ml0uLiYtbhOnZx 0TFtktMQ2qGnIkpcDupaFIj0HLjCN0CpA56XUcsSIJr9+acvHwCSeG4HdWp43suTApz7 0XWg== X-Gm-Message-State: AOJu0YyjLciBIJAdF/Puds7/7drCpteolp+uoqfcck1l+U+f3RhN/2Hv pPq4aPH1Jfk3vzUTs2T4uzLGOiFIh2R+g81etLPEfPLGBj0sU9x48HPSzqfcPoT9svajB+4obD/ w9uValbYyi+CBM1gsRFUcOS9XGKU0rixyTLnA7WdIUehqtcqg5957WYT2Wi1hGAqUoO5GgV6m0m /FExiFLu/FzXysRU6p52q7DdT+YIzbtWXrQ5SBaGgF/cg= X-Gm-Gg: Acq92OHQm9AHLzQmgjtRtnovPduT/+rbIXKJOh0JUmk4VtoZQCEKh1Oes9EpPC6F+1C 6B11B/TDY8b6Rfbij2nr1OCxXChx0Q0irWzMn/+6RqScc5BHTAf1c9jiPHGL8N7/ARtwjlzqI+s gk3Eq/7B9DPQBUDVBnsU73jFJnDD9snr5IiSo40PowXwSJ0xrhDg3KxjCw2xTDe4VjpEO7qK5Zj ZRbGoY+JAp3YFy2oVCkIAtcA/rXNKNTAgEXXorLdj++GHHO7RL/DRj3XHjZ5NTLGtyUeaKACqyd 5GIOwtcwqqea8f7bM8ds0gbYByNoKQAQNKnxPpEjwaLuYP2xMbWydm0RwLkPXP2MdY5mMFVdRrr fNMAJawnDvaztbfA4/4njWqxiQmsQ296Jj+meytWF X-Received: by 2002:a05:6000:270f:b0:453:9897:76aa with SMTP id ffacd0b85a97d-45398977768mr16819475f8f.21.1778490227524; Mon, 11 May 2026 02:03:47 -0700 (PDT) X-Received: by 2002:a05:6000:270f:b0:453:9897:76aa with SMTP id ffacd0b85a97d-45398977768mr16819377f8f.21.1778490226554; Mon, 11 May 2026 02:03:46 -0700 (PDT) Received: from redhat.com (IGLD-80-230-48-7.inter.net.il. [80.230.48.7]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4548e6a5b65sm25226099f8f.8.2026.05.11.02.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 02:03:46 -0700 (PDT) Date: Mon, 11 May 2026 05:03:41 -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 resend v6 21/30] mm: page_alloc: preserve PG_zeroed in page_del_and_expand Message-ID: <57d30ce615c23d3f3737e38d300f4613b3ebadbc.1778489843.git.mst@redhat.com> 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 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 d70c9ba6b329..468e8bde7d34 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1712,7 +1712,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; @@ -1743,6 +1744,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; @@ -1754,10 +1757,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); } @@ -2335,11 +2340,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