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.129.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 022C53C585A for ; Tue, 12 May 2026 15:58:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778601521; cv=none; b=RY7dS9yzJuAucusgMv/Fb4LICirR0yu4RurFG3hUJRmH1DhwpdrwSFGpt13oX8fICcrhW38gPMpONoOan3LvE0tDxD6m2rikal5DnZa6wAWBrWWJJbEd1lgToakQyhAd3Bd2f3xw7G/7b2tD2gqUJp+ctKcy13bwPn6q64/EaiI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778601521; c=relaxed/simple; bh=mFetL9IY8I56RXGEOxBcuN5Aswd7wGUXfiI2cWEQz1g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XwmY4MI4O5hHzcwbS7WsP6gwEcQBi42SyrGK1ax0nlojHXjuBSSXZheScKfYHvvuGKM7nMrVZFHIvOvfXRA3B7eO8N8givI/I0uzhbdxaVY/nRzEzZYmwR3nfyu1Brh4K8VdgnXRu8ACMSSifm6D0hr6v7PUpNcfZQsEneNH46s= 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=PeIJBkw2; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=hTwzkxCy; arc=none smtp.client-ip=170.10.129.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="PeIJBkw2"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="hTwzkxCy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778601516; 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=XJW4f8tXo6Lfw2obSKyz1GioGSG/zB4IqguSnk2BuqQ=; b=PeIJBkw2++2FsHg1LRSRKHyaeWtpPa05VL0aCXgw7igSpm2jg5uK8xKdfi2Tj79zwRVvE0 IfhISITcTs5KX4Ea/d8mq98ub4tLED34z1dC/mSSfVjhFxD6pSoDZOkKj/SvgEOlMqU0qU 9zYU3xguq4sxOgoRz+u1fbe6jRxM51s= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-195-uBG3OGVOO3GwNV8IfAc04g-1; Tue, 12 May 2026 11:58:35 -0400 X-MC-Unique: uBG3OGVOO3GwNV8IfAc04g-1 X-Mimecast-MFC-AGG-ID: uBG3OGVOO3GwNV8IfAc04g_1778601514 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-43efc93e4f6so3816371f8f.3 for ; Tue, 12 May 2026 08:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778601514; x=1779206314; 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=XJW4f8tXo6Lfw2obSKyz1GioGSG/zB4IqguSnk2BuqQ=; b=hTwzkxCynRb2+yCyvyg6QVfXmSrMJNtFRSxaOIgk+eP26COhgrJpd2sM4Y9LzehZcz m6Sd9bxdiLK2bWZgGxh75USlzolF7YIKGl/6Q5EshsjgaYj9u9d2Tp7BcCM9UzNzxPjh SnTZO9YZjyXozGDavnG7fLmjiqrAVDd20yY5TJXTOhxa7ReBbGqsk7Wrlg2KgdcxvhEJ zKjz39GLmgiVFhGVckgZerhJOGDKeSVJD8u3hkQQe3DeK6orZC1w/HjSdIhJb06oPOJo N8YZJmNGiJXS7MTLeqyWZIh7PPW4HoPZmmbluFdPMHTD/7e1yXXYlP+MrkxLOw5jrtxR rcBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778601514; x=1779206314; 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=XJW4f8tXo6Lfw2obSKyz1GioGSG/zB4IqguSnk2BuqQ=; b=S/ZQnOgtfgJ/eEyu9mXj59rTLubV39F/LanYqaSZHHNPz23ifXf/z+glk+Q8GXCy2w TanvGFWC3Xzibc2anFndgwxFD7tCm/OsSM2GOgEANl8x+WP5hXy3n6miflXxjQ54A+Mh f1T57oJL75uVbrnmMSVVD2+oLp0f8hHsf2q3kBHxI8r1WR4Nv+LC+3h7yJoyRBLzROTV 4ZyYyXgju4Akba2ZdGTuKVs/NuCtqOI9xVtHABPK/fePOq9k0IBh65xTaIVnEeugHWqq BYSYOgRuB05IWA/3A/OYY+XP1F5/NECkxOZGtVW10yTR9+qX+efAYA/WRPB+XJvMqlgj IZHw== X-Gm-Message-State: AOJu0Ywq+PXLjKnoBqud8Vq/aND2pyXldncMZ3t7NY7QPWT1ZFCMSLyJ gNDUkwqKIqMtvt4dmYrBFB0HdG6gPULU6+zjK8Po7+uKSKg/EQWDDD+yT9LZ7ZaUJguqGp598EK TCfZA6v4VAslYVfpFX61PuaQZvz7lX5UuntLtdIXLWs3/eRoWZNdvYg6VUYH32O6eGA== X-Gm-Gg: Acq92OFyzVxchSviulxfEdclg8qIK6zzAsGPBKzg58SGt0La8MelAojVh7G8XuHN6tQ cwmdhzerovvqK/RRXKxiXbDIH78gxjwEB5OgTBB+sJ9KD3/wWbzAn5Rc+X497GmiutENo12NWoD w8E+icEyAoLkp6Nm/qBm60weUETP9+1eowMd+dUBsj0ehSAf5kK1amrGLUL7Tszq9DT69MjSOCN WNM6dLVTpe6uN1KbpBH+fO5g8aZnJlWdvFkElqHgpfEV6MPbXCaDF+rhHscExMCsAboBdMqv3J2 PNBpgzswuhuEPs6JU3OpH0fsaiPp6OF5vWt2HpYKQf5CVCa271fa7WHxT6I231rngqlG6XTwC5P /1mCOG1mV2A4ExHiJ9CLXyCl07GiqEBo5n+mLiBUf X-Received: by 2002:a05:600d:e:b0:489:ad:7b5b with SMTP id 5b1f17b1804b1-48e706d24e3mr228848145e9.24.1778601513783; Tue, 12 May 2026 08:58:33 -0700 (PDT) X-Received: by 2002:a05:600d:e:b0:489:ad:7b5b with SMTP id 5b1f17b1804b1-48e706d24e3mr228847285e9.24.1778601513245; Tue, 12 May 2026 08:58:33 -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 5b1f17b1804b1-48e8f4247fasm29156585e9.9.2026.05.12.08.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 08:58:32 -0700 (PDT) Date: Tue, 12 May 2026 11:58:27 -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: <20260512115805-mutt-send-email-mst@kernel.org> 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 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. -- MST