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 34D273C1978 for ; Tue, 12 May 2026 21:06:17 +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=1778619978; cv=none; b=YyUkcvRxQV3RTt8CNySmXBlThyoR6euNXb59S7cAUxkSl2HKQHSoN535cpIuPPObnAV1h0SucxCspRV3bexSVYa/gjWfw1rzyC1YPC5QYmZY00qzlXrgAe3IYHIUDH05fPOuXsjiizph5+4mWvNkxXnhD0+A0KwbZoK3LxuSvTA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778619978; c=relaxed/simple; bh=3McArHIdLgBghzfnrm+TQwXFwqILlkjaIIZYFynnsK0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ea7m1KSvklaohqjiU//BEQT24FAAW4Ao7wBdFXGs4f/xvQE+P2jBUuanuOeFz3APqTJWh85ggnlRDWKVbb9mwOoMwwAXy0AjWL9L1hiIEEqkdVd3pJ4AhgMVGV5x/NzyIEVv1rK3/p3vXS+aMnLA/nXH9/suK0WhHmWQDViM++c= 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=HZ9l4UI+; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=gJmjdfaP; 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="HZ9l4UI+"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="gJmjdfaP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778619976; 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=Tom/uL+543XR2YP2OF3z1y+v/10GzcsXvkyBJuLR6so=; b=HZ9l4UI+q3pDG2uuVCh2mseM69oWiZssSUbJJxZ+7YH2khjWfPGCx0z6JA84JgXBhdbSAV SE5kkqGW7TetyEsKAnI9Ea1cgRNf7Ivkyz5amIXivwyyeGmizVhdUxGA0FIoPXiHFwtYb8 CG4c3L0R+L1kPWzVMK5mIguUDZaaDKU= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-376-1UFbuGqOOtKBV_6UVf47pA-1; Tue, 12 May 2026 17:06:14 -0400 X-MC-Unique: 1UFbuGqOOtKBV_6UVf47pA-1 X-Mimecast-MFC-AGG-ID: 1UFbuGqOOtKBV_6UVf47pA_1778619973 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-48d046fac74so35019775e9.3 for ; Tue, 12 May 2026 14:06:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778619972; x=1779224772; 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=Tom/uL+543XR2YP2OF3z1y+v/10GzcsXvkyBJuLR6so=; b=gJmjdfaPwOQMIOepMxPr8XhLNvGi5F60+cOaLgJBOkv2O/mWPYBay9153P7HacqRoK anF3eiQiuOedIz5dSftsDfxyJ+Vzhy8HwUNyYM8oEC973ovqqFFPG5YF686z7P1PVf8A 1Hr895adMkeSUh7TTRh4TUyrL505ftv82oOYt/JO5NJgSBkyKtVW7VM2ngi2DOsBWSv+ VTdeJS+DToVqUmraZlOY0gCLc3bA3ml0AzYdQdysak0N8nrCpgaDnfpZ5TfbSPhmGvaI id6Hx0DTUjfq67X46rpW2xjpAcVXAW3LFcRwNvn5U2cona4uWkkPrySF8uTMjSBG5xEp yHLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778619972; x=1779224772; 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=Tom/uL+543XR2YP2OF3z1y+v/10GzcsXvkyBJuLR6so=; b=M+YlsgAl55FDFAaJEsfBUTjUwZKsVtPqaxgw7/vqxEHDKJzVYe4YdB1Rrnnd4KTVF6 s8yBKquA5k1XOsXO7MoK5oHGYhkhbzzf0AsuHB4hQwP/i819byGJAEFCe6EHg6oMIBs4 SoEAahJ01Rw0pckjPIKVN3jfldny0pyraHhCYop8uKxjm811A4zTany+nXXOVwv/VPv2 QyS4p2Be8ls9kuGcEoT7qMFmbO75X21ICnMYhdLfSVvsTE+EyFNvshIaCmNv7cU4QBHC CdnBbHlQhy4Gc/8yMPQYJlycPbNoAduZXrFOnq1UDUJpiOYBjbqDxTuoRwx/dsUttYyA 2Dbw== X-Gm-Message-State: AOJu0Yz3THY7mSQlIXxDwMbTswLPa50cZ9UOvtt/R54CAGk5/cWTsM1Z 6BuBkwKG/SwcOKzTzhrRx6n/xjSnNu0Af4W0/CabBa6tG6b1pb6T4UlNQbVTNtJJCswCe6FzJR+ i9eA2IFvN9P0nicpYVT5JKudta7RR4QTzhYJJtQhkobmHg6cXkBIPoZ7kcORYEtAn2g== X-Gm-Gg: Acq92OFgpqc0EqiKrK0CisatMG8pWJLZ9HDkaeZ96xy87AqPCW2SRNYb0ZQduO5l54r +8GKNKdumf8cUQx20xdBtH8Wea6Q77VIQ8ktUsSCR0TQZQofnUuAHBipo6Vs/BqTpsZOUszRe39 NzDlhR3S54ZVs1sbBITs9WNloqdbOdrJiX6XiD9BAgDkMdZAKyXIX/OL6qdQsTIIxasFVReZeKi Y1psTZ8h46hekFjA20KbqE0Nik9TeVE1EIqTUEnKyFMothbiYL4cjr8+Oap5yBKg2wmctcZJm+u yzO8lZHg0gptdjJQ8cI99HBAThZYFyJI2uW573uS23QvBS1LrGy7C0g86jhq+nZA8YXimuPwJKm Qt2Hy5YfrJ2Z7mTW9cUw4bKIecY9m3NrimWTzsPsU X-Received: by 2002:a05:600c:3507:b0:489:149a:f9e6 with SMTP id 5b1f17b1804b1-48fc9a4a5e9mr5880635e9.28.1778619972430; Tue, 12 May 2026 14:06:12 -0700 (PDT) X-Received: by 2002:a05:600c:3507:b0:489:149a:f9e6 with SMTP id 5b1f17b1804b1-48fc9a4a5e9mr5879965e9.28.1778619971777; Tue, 12 May 2026 14:06:11 -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-454913049ecsm34251392f8f.19.2026.05.12.14.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 14:06:11 -0700 (PDT) Date: Tue, 12 May 2026 17:06:05 -0400 From: "Michael S. Tsirkin" To: Gregory Price Cc: linux-kernel@vger.kernel.org, "David Hildenbrand (Arm)" , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , 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 , 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: Re: [PATCH resend v6 20/30] mm: page_alloc: clear PG_zeroed on buddy merge if not both zero Message-ID: <20260512170525-mutt-send-email-mst@kernel.org> References: <20260512115805-mutt-send-email-mst@kernel.org> 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: On Tue, May 12, 2026 at 12:32:20PM -0400, Gregory Price wrote: > On Tue, May 12, 2026 at 11:58:27AM -0400, Michael S. Tsirkin wrote: > > On Tue, May 12, 2026 at 11:56:02AM -0400, Gregory Price wrote: > > > On Mon, May 11, 2026 at 05:03:35AM -0400, Michael S. Tsirkin wrote: > > > > When two buddy pages merge in __free_one_page(), preserve > > > > PG_zeroed on the merged page only if both buddies have the > > > > flag set. Otherwise clear it. > > > > > > > > The merged page would inherit PG_zeroed, and a later __GFP_ZERO > > > > allocation would skip zeroing stale data in the non-zero half. > > > > > > > > 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 | 15 ++++++++++++++- > > > > 1 file changed, 14 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > > > index bd3b909cacdf..d70c9ba6b329 100644 > > > > --- a/mm/page_alloc.c > > > > +++ b/mm/page_alloc.c > > > > @@ -940,10 +940,14 @@ static inline void __free_one_page(struct page *page, > > > > unsigned long buddy_pfn = 0; > > > > unsigned long combined_pfn; > > > > struct page *buddy; > > > > + bool buddy_zeroed; > > > > + bool page_zeroed; > > > > > > If you want to play some code golf, i think you can get away with a > > > single bool here: > > > > > > bool zeroed; > > > zeroed = PageZeroed(buddy); > > > zeroed &= PageZeroed(page); > > > > > > if (zeroed) > > > __SetPageZeroed(page); > > > > > > ~Gregory > > > > Does it matter? It makes my head hurt. > > > > Less code generally means less bugs, but this is more style nits than > anything. Either way > > Reviewed-by: Gregory Price > > ~Gregory many thanks for your detailed review. I did my best to address all comments, and sent v7. -- MST