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 3C4F03C1402 for ; Mon, 8 Jun 2026 08:40:01 +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=1780908005; cv=none; b=tz1mdsaU6ttB3vFyUPt/CmwJAxgqyfmpiCBK8lGkRb7Oy4UhIWwp63D2fP1qm2tAc2uUEJXsXL3h4MKdS9ZgBNAYgDRXG+YJ1yeOp0vc8W2SkCyGCBrMkP/d/BQm2QpoBG9vQ1d7fGF8/LdSmb3bdkKPTPsOHUwF1ha5p71/CvE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780908005; c=relaxed/simple; bh=5wGTQWwTRWiz92QjrAnqbfvJyoSWYuOrxYhosbDCVVo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=b8hYgCVcHTP6Fch6/K1aUjHKOazfwwd26BW5ZT4L4uQYDi1TbvEi7CNgBS5cVmRRdwu3PEnx6vIn8NbgiDBshktBO51nLA2fK0aNNNXCYZwlIs1D+g+LeR1fe9Gopo9ctzCsySR6mJPoMdKN/zmXA9+mAb9KfsM/dq9Mtbga7To= 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=NaTnWor3; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=C7pqns54; 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="NaTnWor3"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="C7pqns54" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780908000; 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=w/d/SpfWsyx4WFKJs+ZrOIC973gnVs56nqbJSdvDWbI=; b=NaTnWor3bRWWSxIbwABgGIAOYs6wJeflVzD8DUnbJjZj68pRBHJWJkKM/tvlxMZA6F+YwA ZIpB2ot0IY7VlQuDYCE03LvX4ZzAGS8z+EpHUPSslMc3TZT+lRsE9FHFP9hihO4sySoRFz dLhAbA6EQ+jS+gLnECj5juGkj6WADig= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688-fmomM6H5Ne-pQVZPYFCr5A-1; Mon, 08 Jun 2026 04:39:59 -0400 X-MC-Unique: fmomM6H5Ne-pQVZPYFCr5A-1 X-Mimecast-MFC-AGG-ID: fmomM6H5Ne-pQVZPYFCr5A_1780907998 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-460129ef947so2392954f8f.1 for ; Mon, 08 Jun 2026 01:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780907998; x=1781512798; 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=w/d/SpfWsyx4WFKJs+ZrOIC973gnVs56nqbJSdvDWbI=; b=C7pqns54dJYadr4RbB0Q5l5qNFAqssZOqua423Tgl0LLsJBaN0dpq+gjlEgEwcnAlc C4oNCLrnDWvbZqPmj+TGg3/sWek1gN51WAl9uhl8su/AUB+Jtjkj8ZAO2wjiyiFRVWtK ge9/8gX+deLiBimH8/1wcqlVo88B6nYca5cSesvidRQW4zClQfixWqzQaRTYW40Mo94/ GWXgdzWRiMPzQwIkvoga81YZ6Zwia/UIOtSWq4jXM2n2jmv4C40842g9sIxFfzlBJWms 1SHA1FydhRB26XnvhIedbfjVQosWq2DeYbJrUT7b8FojSgw+Ab4ydN/EOx2iMg8GI/J5 jqZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780907998; x=1781512798; 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=w/d/SpfWsyx4WFKJs+ZrOIC973gnVs56nqbJSdvDWbI=; b=cHvBELngfyKGb3BWIzbpsiGkk6/hPA8Lg6ND2QPdimgVsxd2BkeOsT5k7r4ioQyggp gA/BeJ3SLIusMDdp958U8fafQViAGGWD2uxIua8gRxB0aZu5t/iF2mDI35ONMgxMMN2i DBMtM8KbLB8Z90FOeaRcj96w+GJLbRxgebGn26f/mBmZGflQRrAXSEPFKwK8HIP1vhTo RMQsEkoWaHnwNrIJeAyMRrtgcxP3J0OwTPyttbF+47QT/bVzvE+q5wXRH+OV/YJc3O8a 5RCn4iv4C0akPiifhjBC0aoYAhY4LDjMFt7kHnux77LMHZcrvYvShwjkUxfhKHEcV6Am aNvA== X-Gm-Message-State: AOJu0YzfkZOxGXX+/EWLAMj8iwOBA+x1rrjeqfLOtUTVh+p/0FJzMscq FzKlBHUguDdYmw6h2wDrhyIyCOCxmuuhhwom9tiHSkByDC/TVZPROLKou0tyJIDh0HaeBEqkbnN NA75UdFVyAfeWLZ/jPCRd7PTC1A/JSgczE0nsZhseOrT+ncE/6JOA1CWCTdgPhvug5ndKatRlH1 xL90JrXK7hUTQrOOGafky7sjp2IpcQ9HCKDeIfjmzIwbY= X-Gm-Gg: Acq92OE0Um1+jiQspTw4Cg6fl06kEqXTL7Xdswpj9F1d3SVMqIovy5s1jekcZ2mueo4 Hvw/T7Eg80VJJ29r/nN0D7XstQDi7DJJl2MgeBv96zWCndzmijdWWexMGpWTLGwewT6pXiPXcT9 k4Uau+AyOgj+dIesuff6NvzaI819P593JwFMK/f6TepUGr7xnWNDP91euEthUlnx2AO++ejUbKt I6A4OXtjQtDyMrDdO71Krq9AaciNoq5AE9CJeU+iIOqyHqHqZy+UTYKghkj2obPOi50oFmMbjzw Hix/ezEnwoT3zmEgYEUOCTWc0aAml9Z9WozQ/DzotsZjPRXEJrWBzNa0lObFk0bhTuT4fre9p1F 08N2Y4wOHOtgB9vWJBdLXH5o= X-Received: by 2002:a5d:6e84:0:b0:45e:f2bd:2b17 with SMTP id ffacd0b85a97d-46030501f7fmr16740289f8f.21.1780907997549; Mon, 08 Jun 2026 01:39:57 -0700 (PDT) X-Received: by 2002:a5d:6e84:0:b0:45e:f2bd:2b17 with SMTP id ffacd0b85a97d-46030501f7fmr16740213f8f.21.1780907996901; Mon, 08 Jun 2026 01:39:56 -0700 (PDT) Received: from redhat.com ([31.152.37.159]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f344558sm48512372f8f.18.2026.06.08.01.39.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 01:39:56 -0700 (PDT) Date: Mon, 8 Jun 2026 04:39:49 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: "David Hildenbrand (Arm)" , Jason Wang , Xuan Zhuo , Eugenio =?utf-8?B?UMOpcmV6?= , 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 , Gregory Price , 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: [PATCH v10 30/37] mm: page_reporting: add per-page zeroed bitmap for host feedback 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: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent The host may skip zeroing some reported pages (e.g., due to alignment constraints or bounce buffer fallback in QEMU). Currently, when host_zeroes_pages is set, all reported pages are unconditionally marked PG_zeroed - even ones the host did not actually zero. Add a zeroed_bitmap to page_reporting_dev_info that the report() callback can use to indicate which pages were actually zeroed. The driver's report() callback is responsible for managing the bitmap: zeroing it before sending pages to the host, then setting bits for pages the host actually zeroed. page_reporting_drain() checks the bitmap per-page in addition to the global host_zeroes_pages flag. No driver sets host_zeroes_pages yet, so the static key is off and the bitmap is never read. Behavior is unchanged. Signed-off-by: Michael S. Tsirkin Assisted-by: Claude:claude-opus-4-6 Assisted-by: cursor-agent:GPT-5.4-xhigh --- include/linux/page_reporting.h | 7 +++++++ mm/page_reporting.c | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/linux/page_reporting.h b/include/linux/page_reporting.h index c331c6b36687..e2e6a487ddab 100644 --- a/include/linux/page_reporting.h +++ b/include/linux/page_reporting.h @@ -17,6 +17,13 @@ struct page_reporting_dev_info { /* If true, host zeros reported pages on reclaim */ bool host_zeroes_pages; + /* + * Per-page zeroed status, indexed by scatterlist position. + * The driver's report() callback must clear the bitmap, + * then set bits for pages that were actually zeroed. + */ + DECLARE_BITMAP(zeroed_bitmap, PAGE_REPORTING_CAPACITY); + /* work struct for processing reports */ struct delayed_work work; diff --git a/mm/page_reporting.c b/mm/page_reporting.c index 84ebc4547119..9c39448e758b 100644 --- a/mm/page_reporting.c +++ b/mm/page_reporting.c @@ -108,6 +108,7 @@ page_reporting_drain(struct page_reporting_dev_info *prdev, struct scatterlist *sgl, unsigned int nents, bool reported) { struct scatterlist *sg = sgl; + unsigned int i = 0; /* * Drain the now reported pages back into their respective @@ -122,7 +123,7 @@ page_reporting_drain(struct page_reporting_dev_info *prdev, /* If the pages were not reported due to error skip flagging */ if (!reported) - continue; + goto next; /* * If page was not commingled with another page we can @@ -133,9 +134,12 @@ page_reporting_drain(struct page_reporting_dev_info *prdev, */ if (PageBuddy(page) && buddy_order(page) == order) { __SetPageReported(page); - if (page_reporting_host_zeroes_pages()) + if (page_reporting_host_zeroes_pages() && + test_bit(i, prdev->zeroed_bitmap)) __SetPageZeroed(page); } +next: + i++; } while ((sg = sg_next(sg))); /* reinitialize scatterlist now that it is empty */ -- MST