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 DC23B3328E6 for ; Mon, 27 Apr 2026 15:18:08 +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=1777303091; cv=none; b=kqdP/K9uOTYeSEfH4jSkYqRaRC8yATL1244z3wWtywaB3TfyPLgciMTk07SW84Ov5SgBUqSsn3/Gux77BI3NyQ9/TzUZoa6q4vLDLcszS3IAPGaqtIAcpEYVshSlmBcaq1aq8nC+xRRowV0jrx46sPKl0BcGKaJOZTYYYbQmgGg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777303091; c=relaxed/simple; bh=D+2h7xzpt7GbaEk60JIFREm5FvhK4UL6KmPvk8SIeTM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=A4zh+MvbbVCBbcEgV/jiaMK5fEvqRqZ27OpG11ia74K7BPHXzlETGcPDoWzRfZtGLw2c8dT13rHlNNWsopdLCnK5b1Du2sQrPNKLTiEPgQLw6QwSafNFq6EIVUCnSx/+Fr7kQgLnAxGkpuNcUfzQFuz+eBi5+zxYbCsE4um8OJ0= 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=BX4qHPnq; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=I4/Z2sI9; 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="BX4qHPnq"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="I4/Z2sI9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777303088; 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=wsHOVCUXvaEIYIkpmuMRaDJg98RHwYpOJQfqxhVn1Is=; b=BX4qHPnqSxtkSvsXFurxwiKyD1znrRfEOn+HgMgOe0BtWCptc4Bf9yvtXJ89EGvG0CGm48 j/sAhBD1XZMlGBhFWtfcyedtbrT1Y1jIylEetFO9fmLI309Fk7iz8Q5PBLYR1xd7SZhk4w fUYD8JAGefB3GFYZXjfG/FbzuzQ2460= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-mPLSjlHpPZqRG-fb2Txvfw-1; Mon, 27 Apr 2026 11:18:06 -0400 X-MC-Unique: mPLSjlHpPZqRG-fb2Txvfw-1 X-Mimecast-MFC-AGG-ID: mPLSjlHpPZqRG-fb2Txvfw_1777303085 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-43d70c27214so7201813f8f.3 for ; Mon, 27 Apr 2026 08:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1777303085; x=1777907885; 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=wsHOVCUXvaEIYIkpmuMRaDJg98RHwYpOJQfqxhVn1Is=; b=I4/Z2sI96hpvppbzUhs50Pb1LDNCF2F6n9jpgoDSYH1bgq7Th8uFjEoobOKQoskaWT PpXqSi7kJ/4D/YjaS1vu2LgBnhnju1ZV9u3Q0W/oVLGUKpoftGDnyKHiVG5MAlx/RK8u B5uug9FDPTZW2FpLyB76AA/2K3gkOik42JWaKKxqiHvvhXuEynZm0AvD+yTuZM7NTUQp 4nW+CXXhQcf7Rsb3T2/RshhYdE1zkAe3ZxRAYlRCt5i8L723bYFQ6cWOoEfQ2J3bVhJc /G8KItF9BkkfpYFQIDhIxmXaY3fLg83V14ZiV/o/x9zZ9AbbziHikeX9/CJfP5teZOpb QA6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777303085; x=1777907885; 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=wsHOVCUXvaEIYIkpmuMRaDJg98RHwYpOJQfqxhVn1Is=; b=di5TMtCTdofcB7Kc4RVvQz56GHP2yJBw09RlV7IWij5vfl1y4C+/lZfU568rSs+rWo SHKCsiWbAX4mf5pKSOnSb5alNop6YyQnN7S+/TL7fEFLbjDOJw2kmiAILR3IiRmBobAS qZs6ZHUJ+qoQ0l0g1cFuAqw/j+8H6AMts31kLZihXg6o2NAx6JInpEj5GWR69Zux3hFf aO0OuVmvxZAPTVA4KVMyp4p9qqLnDppTewzCF7JmVoovHX9kJIjD/zt52ss65etGatW8 fCAGL+5oX7I3OvKcTpRwV9zIy7eKXe68YpRoA1YeiuuJBzvSDi4gjtEvNC/0sqXC8rrd z7HQ== X-Gm-Message-State: AOJu0YxegJYqPxvfRwwlltRgdE3Ynq9x8J70bTC7PhEVlL+7uUc1Tmzp WBv4KUVtrAidEWPpB/oslWMrHGFllokItuxHWP1speGMQzl3RNtTIRD3GNM2Wek1CcQQPcdyAXM hYAJmSB7ioXFmpYTYlo9/3Y0gyuwvASXYbmDWlLbrDdspbesirwENaX2SSWGL0A7R+w== X-Gm-Gg: AeBDieuydVIsnyDuF1aRjfVDsHJh2wJzO2lhiQfrzZ4qf/ywAq7IOgNVuVs1lKcaKsU 2Ir4JFBROzraBsZcHBzYm9kk4qDqUbZSsiCwteCnCdnBSqDStdUpOjY2Wn0OPFDxFaQLoCE+7bX We3dS7yEQtorluV/ygdNpT/6q/YhovOiCjaGLXuPdCjtcbZ9s/KdOOOtmMNrR7rz2NSd5E3F4NI 5xOqnj/ahqB/OA+8VWdBKGORuoIO8+8Flrnj0WqWCU6HRmO0vX/GQcRtEkIXLMXdR3PdPtFeCyy UBc5oR+m45NABIBVuDmS3Tpdl8clmxHwPsK13/wp/BH5S7b5g7BIJl91PnVytDqYZxHUMAHVSJw XSGT8zR4d5xPZrsqcZs+0CVKwnPB8T9qHEswssJXvr6MnwcOfPTy5YUhq X-Received: by 2002:a05:6000:40de:b0:43d:7946:badc with SMTP id ffacd0b85a97d-43fe3e073dcmr66488028f8f.26.1777303085270; Mon, 27 Apr 2026 08:18:05 -0700 (PDT) X-Received: by 2002:a05:6000:40de:b0:43d:7946:badc with SMTP id ffacd0b85a97d-43fe3e073dcmr66487949f8f.26.1777303084696; Mon, 27 Apr 2026 08:18:04 -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-43fe4e44f69sm85358069f8f.25.2026.04.27.08.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2026 08:18:04 -0700 (PDT) Date: Mon, 27 Apr 2026 11:18:00 -0400 From: "Michael S. Tsirkin" To: Zi Yan Cc: linux-kernel@vger.kernel.org, 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, Lorenzo Stoakes , "Liam R. Howlett" , Mike Rapoport , Johannes Weiner , Matthew Wilcox Subject: Re: [PATCH RFC v4 14/22] mm: page_reporting: skip redundant zeroing of host-zeroed reported pages Message-ID: <20260427111724-mutt-send-email-mst@kernel.org> References: <788d5a09394ed1456beaab23f75d91846ceeb611.1777223007.git.mst@redhat.com> 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, Apr 27, 2026 at 11:13:44AM -0400, Zi Yan wrote: > On Sun Apr 26, 2026 at 5:48 PM EDT, Michael S. Tsirkin wrote: > > When a guest reports free pages to the hypervisor via the page reporting > > framework (used by virtio-balloon and hv_balloon), the host typically > > zeros those pages when reclaiming their backing memory. However, when > > those pages are later allocated in the guest, post_alloc_hook() > > unconditionally zeros them again if __GFP_ZERO is set. This > > double-zeroing is wasteful, especially for large pages. > > > > Avoid redundant zeroing: > > > > - Add a host_zeroes_pages flag to page_reporting_dev_info, allowing > > drivers to declare that their host zeros reported pages on reclaim. > > A static key (page_reporting_host_zeroes) gates the fast path. > > > > - Add PG_zeroed page flag (sharing PG_private bit) to mark pages > > that have been zeroed by the host. Set it on reported pages during > > allocation from the buddy in page_del_and_expand(). > > > > - Thread the zeroed bool through rmqueue -> prep_new_page -> > > post_alloc_hook, where it skips redundant zeroing for __GFP_ZERO > > allocations. > > > > No driver sets host_zeroes_pages yet; a follow-up patch to > > virtio_balloon is needed to opt in. > > > > Signed-off-by: Michael S. Tsirkin > > Assisted-by: Claude:claude-opus-4-6 > > Assisted-by: cursor-agent:GPT-5.4-xhigh > > --- > > include/linux/page-flags.h | 9 +++++ > > include/linux/page_reporting.h | 3 ++ > > mm/compaction.c | 6 ++-- > > mm/internal.h | 2 +- > > mm/page_alloc.c | 66 +++++++++++++++++++++++----------- > > mm/page_reporting.c | 14 +++++++- > > mm/page_reporting.h | 12 +++++++ > > 7 files changed, 87 insertions(+), 25 deletions(-) > > > > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h > > index f7a0e4af0c73..eef2499cba8b 100644 > > --- a/include/linux/page-flags.h > > +++ b/include/linux/page-flags.h > > @@ -135,6 +135,8 @@ enum pageflags { > > PG_swapcache = PG_owner_priv_1, /* Swap page: swp_entry_t in private */ > > /* Some filesystems */ > > PG_checked = PG_owner_priv_1, > > + /* Page contents are known to be zero */ > > + PG_zeroed = PG_private, > > +willy, > > I was discussing with willy and David about removing PG_private and > repurposing it to PG_folio to identify folios. IIUC, PG_zeroed is only > set for PageBuddy, so it should not be an issue to set it for allocated > pages for folio identification. Let me know if I get it wrong. > > Thanks. > > -- > Best Regards, > Yan, Zi Exactly. Trivial to switch to another bit, of course - most are unused in the buddy. -- MST