From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49C643A59BC for ; Tue, 12 May 2026 15:56:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778601367; cv=none; b=oWLx7nUlXPe9jN2DbENUIgiT292gOFCq7IXf6ImFq/rRqqKbdVUkS7tPYdJnCqCCb/lH5t8lUbSalNDsVsZjo7OVIUCSWpTkZvj97qQzjiot5NrLXgSIxexUYI+NoatV8w+MyB4jWxIODutdRY5vUECZF43WaOqnIDqjk9DSKd4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778601367; c=relaxed/simple; bh=1EQ6J44yYhZWgn/zkYAncpsUX5MIcPYdUQgdHICoVmY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RBck2hxOZxogWSu3xnJtdLKY9QuYvKEK9ycA6wNqgkNnA13VgDTTP5iHLo2IXhXR6n2wJBaf3qUTmNAi9FgItny0RnJDkX5RWypTHsAibeYBWLW1/P6b4FQA29nhv1z5Py2iF1p4EYKqL4iZ2K0N0YU0c6jClkBIVVhXL0f8MoE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=Lj4/0fth; arc=none smtp.client-ip=209.85.219.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="Lj4/0fth" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-8b98482b253so77227496d6.1 for ; Tue, 12 May 2026 08:56:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1778601365; x=1779206165; 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=Su8Okdv9QVtgiODRxP6QoL4RhbVAvigNNa5QAGhM4ag=; b=Lj4/0fthcjytOT1RSoVnXKn9c1DTJMmeoN/jGFDAOfcvGKZtEOOcxTcDU6HYDRs52m gu6fwH1GAD+TAlbRmFDJcfbJUF6l95KMxNjyiKAMh8s3owLMRTUl+0E0Drx6ajk7K18y 4GzKFIYYdx6xrGI64q8V5B24gz+Nzwp8moRYjWNFVmitEn4k2M6g3Ad0+6HpXnGWsK4Q KCnqbNC9greg5aAdsErCwlIoKKY8e1Uhnu7LCtbzUTYr9EX5t/yMHxbAVwPqvfeKQ52S JCZHOx/UrbD8w2kdaMLV5enASkXVxae3apMMJWigNX+QWowKik2zOLY3pzDrvtrQT4r7 Cwag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778601365; x=1779206165; 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=Su8Okdv9QVtgiODRxP6QoL4RhbVAvigNNa5QAGhM4ag=; b=hJjfIsDfB599ePnjxRqFmZHbbvMmX1uOAPkxirNZlcVjpatjbqud2LVujJlcx0f2pc TZVQFxRIfDidpb5Lis2JUhQYB8VVdDfCktQiF+P4sZZRMfsXG86LN7H/Zmytk4PppfIB 6hHYXXzRTOLl2OQkqLc1LY76egjEU7h3KU43nt5YbpA5MiWh95D1+SUbyOitvFVvH7eE IcdE8enybnE9KreQz4RjdAd6atsiMhOujL7nYV6OzjDLuruZZy7OBofyuQSF4SnzyQBm f5vDZndobQ3rv9zF1H3kfQiv4dOPnAYZh9lFxLCKfbvePATXXtu+a6hpUnvpJfoLnYTi CHbA== X-Gm-Message-State: AOJu0YxidnckVrhgMTOPW+3hJgTd/2f/3nKd48rHqAReMOe1g8F6qq9z o2lxT0OYYcbhoz6mQIdmXQwzMlZL3k/e7USb4oibgm6mzMr9QkMO7ou2zE11elBmWMk= X-Gm-Gg: Acq92OHQU9DXr4fD2w6zBWXlClbE27mGV5I/yXht82IAVdk6z0GUoaBhhY8fxxoKLmE wan838kD4dgkOBaClN56aHq+4rb/J91cr3mKBaIIGULMJ/A6XfX8on8lfkT2W7zqQaDylNgQY/B 2Af6gJLmRsO9kzOXLBSFbRDrGXbHYzmNwwshTp72F38+dn5hQh+dyBq+I5b7l49y/3iCE75E5AS EjDqovcXuXGKkMyqYk5AeNOxpgjwHq79YbnzETGSGBWCA47ppkoFmC6YMAjFytEmw/QRyx+Fa8f 6fOuWcCNlnaS/W48keLPl0B1edsyoU5NMcF0c1t0+xzspb7rCMGdUGDpSlqSX1N3Dzzg808YtyS wPEUffTPEEyvNLakKudIWKfihHS6xy4bUyrc2zKvrduGBhWIUY+nYvkDBomY0lmgleZ0UGmVBqL dYwAW+a6RMr67rEqdvda+Exwq/J0SckC7o+Dc8QleFrBp0SODtQQbItCAZsGiJbgqMERAxO61Ec tRTRImEBrCf X-Received: by 2002:a05:6214:319a:b0:8b0:2017:958e with SMTP id 6a1803df08f44-8c6614dec3cmr60146186d6.13.1778601365090; Tue, 12 May 2026 08:56:05 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F (pool-100-36-248-188.washdc.fios.verizon.net. [100.36.248.188]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8bf3a438e3csm129340316d6.19.2026.05.12.08.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 08:56:04 -0700 (PDT) Date: Tue, 12 May 2026 11:56:02 -0400 From: Gregory Price To: "Michael S. Tsirkin" 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: 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: 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