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 E4C8E2F0661 for ; Sun, 26 Apr 2026 21:48:28 +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=1777240110; cv=none; b=YfNAG69/lG2rnNWBsypMwXEOn/LKPvWHxDX7JHOSkxmCgM9PFc74+5HQK8KiKC59IDAQZ1zeFJypwgsH2WC8gttupcSAublvywGwcBD+SATiRtDOP8ngoLFjShBpMRueT/DFrHcUk/20gINfWWtBjGIMxbp6QWSX6YYO7UjSVpA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777240110; c=relaxed/simple; bh=ddif2Keg7MsypRPUTjBR227ZRe8X6d5tcSgDIOVelv4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eQ4bx520eApdx6z4dJ89v88kcICNCxznFhpHQMUfJju55DHaXZeQcIHx42MgUVdbf5CbJc8MoN082Ie/h4nbM1fQcZ0TwJquyeW3GsVbE2DzR+S36Gs35oEzbOLwoWGrIOQxp3ryoRKUfwUmP123nqVKbzTJG4ik8yRj3d678w0= 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=aRhNMpdU; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=mUzj/irs; 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="aRhNMpdU"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="mUzj/irs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777240107; 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=AlVg98QjuOmMUhZ+nzy6BehsEB+gtg7rKVvx2cLdIro=; b=aRhNMpdUfzeK5d68kgPLAPYJMi5OcNDPmhj/HvXJ1I3/KpcvOer07NBeALNGYyzptYskHi dZacY6LDuvyx2yneNP3Fl4/jYfqnazpkjlFOiqkVtPH0vQ4R0GF2yodLurM96KxTmHzRb7 gsrrtIRdZ5BSfB/PGErXr2ac/uuTxG4= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-660-k9NdOVf6O1ONTNnMu9bVbg-1; Sun, 26 Apr 2026 17:48:26 -0400 X-MC-Unique: k9NdOVf6O1ONTNnMu9bVbg-1 X-Mimecast-MFC-AGG-ID: k9NdOVf6O1ONTNnMu9bVbg_1777240105 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-43fe791a398so7399446f8f.0 for ; Sun, 26 Apr 2026 14:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1777240105; x=1777844905; 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=AlVg98QjuOmMUhZ+nzy6BehsEB+gtg7rKVvx2cLdIro=; b=mUzj/irs2hTh/JpZq3BlZVkL4zZ1u5TI78jCUu0cZ8fOqi777qbwulJ86Ann4L2Dmk e6XnLkjlc5PoIJOMIRp6zj8HqHdyEX2sc4n65JlWKA+k/LDNaCTSx1lUnU7Fnf/bv0Xu oYa0rLnnJBC9pWMJUFDNt+byC80eFWHvsxDaLFMtg1/tPEyAk0c5j7Kkr+J8xQ3h2PL5 MfYxrwFDhItHNfa0+GS2d1TMFK2QIRz5ncfdJknXzZtFqlDAiWxwze6OwkZ7BnpXQzvV vSVsHLFnBU4eEBqX8+r72EG6s6cuhc3h8AFZ7s2sg2E0zowHV9O++fNiSc2GmDtNvsq8 VXmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777240105; x=1777844905; 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=AlVg98QjuOmMUhZ+nzy6BehsEB+gtg7rKVvx2cLdIro=; b=Pr4B/woKpApOEkVV8BgCi6lGzgenO8wqJ7yjT4E0PY/+bQHfya7TDQjup1Ep1DRL6B 7AE/8iovLHCOvn0P8BrWd17F5wfHDQ5Fq1OKRWdafauX0HdvlaUnuu31VW8KIA+mgWVO 6zaMmKdf7qjKzYdfumhuH66u7qEGXfNDK8ti+iMWF6otzZXWvOnCVtm8ao6r5Oj0akQ8 BhHiW9FqLQNQS4F808B67dXiSQLs38/hse2P5/HR17mA4IYwqqFD9TXabqgOZ/cqOaDz Hdf8Va0hVNhLDd+tmvjjLZscJ5c8r9w1QzFFiLg1xoHIWzSpz3Ex5VTA+hQVgANhlyET D5Ng== X-Gm-Message-State: AOJu0Yxx9+lzddBq307wGtUGNmHQUG1WiunIC1KIAQYMUk3Cu9JfY0K0 ZQ1mNVz8c6imlwq4mP5Qzw/kpB9ng0b+Xo4mEboM1pVLtaBRo4WzZQnzbYCEMvO85g4jlMLJcOB aaWxHJNNmcudfhACS1Jr96qQ/OloeLJJyNMioQNYcanDue4cyYzyMPkYmYTNRbOfi9ShC2GTJvW 7NbtYxOOjPWK7I6cHcvY7r1mKW4oiqnjCo1DwCAqVNWTg= X-Gm-Gg: AeBDieuG1DeGaNNZEOD89Hy5XXfWTHQFcuncC3zy6BtI2mWZGj7h574T5f8X9KAH+e1 0lCJ29CQ+bH/uy+Pgz5hKHcztq3WH3qq3Nt62imguevIMFYCw9sYivTn+eiGZwP0b7usXGbqTyO hUFaOMKpuJXWfB+kNjTAcjfjefzo9YVYFhSvw0JIOBrXBUvuBehJ7yU+4bJ6Kb6etsO3DxbmPTn 4m4N8VVkzR+9dyvWKkTg13+qQBh3ol669Iut7JwUqr8qcZfCLIxfb+g28FucgTCsmKpuZ+CNc3V 209VK0biFEfRLWqi+O/d1Q0Kxe6LddeXuU6eIO3n+sHvI1/G8yKIpOVDtIMQnh8PGUeRw4MeU+3 W8nrGNwEV2Zm9b/1e1hzhFo42Wb2ugFMKqIw9VBOXHIAx+v/HxsGnoUIE X-Received: by 2002:a05:6000:24c7:b0:43c:fe0e:5bb9 with SMTP id ffacd0b85a97d-43fe3dd4ca7mr63036152f8f.12.1777240105138; Sun, 26 Apr 2026 14:48:25 -0700 (PDT) X-Received: by 2002:a05:6000:24c7:b0:43c:fe0e:5bb9 with SMTP id ffacd0b85a97d-43fe3dd4ca7mr63036104f8f.12.1777240104579; Sun, 26 Apr 2026 14:48:24 -0700 (PDT) Received: from redhat.com (IGLD-80-230-47-179.inter.net.il. [80.230.47.179]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4e4ffa8sm78084778f8f.35.2026.04.26.14.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 14:48:24 -0700 (PDT) Date: Sun, 26 Apr 2026 17:48:21 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Andrew Morton , David Hildenbrand , Vlastimil Babka , Brendan Jackman , Michal Hocko , Suren Baghdasaryan , Jason Wang , Andrea Arcangeli , Gregory Price , linux-mm@kvack.org, virtualization@lists.linux.dev, Johannes Weiner , Zi Yan Subject: [PATCH RFC v4 16/22] mm: page_alloc: preserve PG_zeroed in page_del_and_expand Message-ID: <1db0cfd570fff4b93688619eba55c655be589b35.1777223007.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 Don't unconditionally clear PG_zeroed for non-reported pages in page_del_and_expand(). Pages freed via free_frozen_pages_zeroed (balloon deflate) already have the flag set and should keep it through buddy allocation, not just PCP reuse. 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 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1183ef3e91c9..1169714406e7 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1743,7 +1743,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; @@ -1774,6 +1775,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; @@ -1785,10 +1788,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); } @@ -2365,11 +2370,13 @@ try_to_claim_block(struct zone *zone, struct page *page, /* Take ownership for orders >= pageblock_order */ 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, - false); + was_reported, was_zeroed); account_freepages(zone, nr_added, start_type); return page; } -- MST