From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (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 908B03E1717 for ; Tue, 12 May 2026 16:32:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778603546; cv=none; b=pZiW/yEuwUxq7G/KrSjISTtkITTGClGqPWJLuC5DB6cswEEwAExAZjlVsSlCNkqVtRXcSyj72q6pQt34R1EMovGynjer+22cswAPlsrvo5Ni3Qavb/e1eZwh/LCx6yLD23vPWWdF7807UZ08gEajnQR/7YeABaFNDbqDcPE5+gA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778603546; c=relaxed/simple; bh=JRKdZeY+vE61wMluB5D7aDBZ1E8VEWRJfkASzlOm6KU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MdIxgiUnW7d/xTDKwp95YeUBI1be/q4c2a/9SCYa3IqtJQ4+dJ2tIhTDtheKDSqyDChCLERIF08dgBiD03Ldw1pkfY8xDbkheFiFAyts9hZBhLwLdCBVVyGfjjOtj2bPerVnYFKaEoAseLHqjAdkSyvO8n88r2U4ZQbE12sv9fE= 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=UIwN9gix; arc=none smtp.client-ip=209.85.160.176 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="UIwN9gix" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-515226c0cdbso5202161cf.3 for ; Tue, 12 May 2026 09:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1778603543; x=1779208343; 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=AUBFCivNGlkf0q4LVho8uONOLnLA2U/Jo+KB+lWOcJQ=; b=UIwN9gixd6TCUcsfLNgLSxezdTs4eLyPz6VRjQtrxoqHyi6NVV6eP5e6CtA+ROyUUd 5WXXvaK0rpBtWFUuR1OU8bfoOBi+WlDU51iDP6ujDM6Aj7TK0HXBnMkKbCYQixuLax9Y GsWUt+WVtWNzBh+Y6094Qle0nVaw6M2ZQ+7zFeukKoSIHyGUko63Cdk9xmopRxd3mC8A ctxzb5VMYtIrDaRrWnPkNzO/bBf0zMhCbWRcil3gOvsYj599EQVxpu9AkTQm5Jn+IlB5 2SWm+uxJEedyy/yuiZ5K/MCVnL3v0UuwReStfLt0eJOBSO1w8+B8qgOxLgcMoTlg91F3 a1Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778603543; x=1779208343; 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=AUBFCivNGlkf0q4LVho8uONOLnLA2U/Jo+KB+lWOcJQ=; b=l1eE4N9YJf08V1dWb2aytRb6LagLwr7VdzI5eTbi7a6t+8MaLQRYDRxwj5JhTxIIF0 qOw6a6lHX3W9PKHsZre1fJQ2KcdBbv2lTqkjOHQ9HXFkdZMeKo73FxS74ovVXXJ7N9XG +iwrH16EVF0BF3fqaBxmxR5lEcHAPGzPD9mkN4VJxSPYdJzEr2UO31KznBO/TWCpaQma tLPlwembXMfYU9WD2K9Uhablxffuw3+vKzolFjxGXqlzjjJrOPRLUfClqNww60NbRE/a EuZ6e740InQMH7/aOeeLfAkUI8uhfXGQ/hIjCEE7UzMwhgd8IdzYABPgM38ENH5wO3N+ cGxA== X-Gm-Message-State: AOJu0YySr2OPEet6bmaqnBZXTYhSGxYV0WA1M/XCwK+C2wh8NptVLvP3 LRq1Jc7mCAlZ3xHE2V7sGlhJLfyY3jvjLraxSamisCmy41rDy8R8KipFVqAQvbu0r0s= X-Gm-Gg: Acq92OFg5DhOqk+oImj4QSO3ApSd0KbWqb9WM/CHTXazux8sfrex9pU8zKMMqr72zqU 41XWu+nu/1M4Lch+YTuQnSOzgsPgFS4JZFiEUSlXSzf0/V7dKIlyNXC5i+kPDGyv8joPGX6Lbx6 V/7ahxgvlRl8m3fqw4su4PYu90cT9RCkjPKpQboNUDQyyzKB9+uqooBI4HA0JwYHGZa6lIMYggM CwSxEqQPfescAGYTixM3mSV0Rr1QjB7H+Jmi8ZwLSResNM4oiL2JKqL4ymidEmRsSsj7FLEfntj dW1BQ4xKFUzzzAWdKMOmgXxzUN5ABssovCqkPZFMjN+EYWc/YLHjqhDmZLwDp5HjNxzUizws11r D6bICGDVvFZQs2YLZIoveQG0YaWbd+Q2XWvZJnDVa9JExcIP1F0V2qA8r07ZN7KomIYAas5+gnl Qw2KizMpdZhfXVWaw6rOMUvd0AACsC+WBYEDPyB78qQr+ZVhr4GcStLK9VvLSPRpzV5HZplH9ay sDLcsLkoTbd X-Received: by 2002:a05:622a:14e:b0:50e:5e8d:87d2 with SMTP id d75a77b69052e-514d1c1fb5cmr54799371cf.1.1778603543444; Tue, 12 May 2026 09:32:23 -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 d75a77b69052e-5148e68a963sm123339831cf.13.2026.05.12.09.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 09:32:22 -0700 (PDT) Date: Tue, 12 May 2026 12:32:20 -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: <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: <20260512115805-mutt-send-email-mst@kernel.org> 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