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 191C73C7E16 for ; Mon, 11 May 2026 09:03:50 +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=1778490235; cv=none; b=PvjMKk4EeIwIazeSDOvHikiQKYzT1ClXh8HP9CsoIweTP/e7kQ62PP6PA9PjdEHVJw8QRppTnNPl3TFfAQ+vjEx59U9cye+7dv7Wq4Vlm0qbxXI+Rx/4dbA2294SAzCLdwIlbk5bzvQIgxuikpik+oem2sPhO2H8FFl1LWFdQyQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778490235; c=relaxed/simple; bh=S3lspdseAiA9VDFP1z5oU53ONzTmuB9EAtNlvAmS1xQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NnKR1DbJnu5tdtQWuu2mLItwhp0/xPfoSn+tk5pLlNtnph/AADLvKQPxo72Mll+iDc1D521K1S5h3PGzx6Xktl5Ubi+/0FcPhRfZdYNlKYFtHwRzNjVVScaItA8qr+u3sHoKN06Ge7SmNvLhO4zUeNorAY+ftYreGMtJHfu3vek= 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=T7iI+hGR; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=QZeJ6Luc; 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="T7iI+hGR"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="QZeJ6Luc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778490229; 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=MrvzrHYJp3qtzaZog5kuCX8qehdfFd6F9etMXff3gHQ=; b=T7iI+hGR65dA8n7CbMAwn778PfOhLjK7Vxr0X643TlxdZrjjgOFDoOvv1TCsxqlMFHOaI+ kgueLHuQ/IwC2VyJi8iTNEy//cU6Gig2Y54m7BAmiW8iRuqfpa9TVZZSwqnh/fLJn0aohn fgmRFs/ktTDNYLtSV1DTdweob+d8x0k= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-127-eLTaaN1gPQq96dUz5HtkPA-1; Mon, 11 May 2026 05:03:41 -0400 X-MC-Unique: eLTaaN1gPQq96dUz5HtkPA-1 X-Mimecast-MFC-AGG-ID: eLTaaN1gPQq96dUz5HtkPA_1778490217 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4470d6d2a4fso4376266f8f.1 for ; Mon, 11 May 2026 02:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778490217; x=1779095017; 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=MrvzrHYJp3qtzaZog5kuCX8qehdfFd6F9etMXff3gHQ=; b=QZeJ6LucmlepDlPK9ydQT4SfmAeZ9zXPMTAvCfCmIbrKqpHtyVqbZlfULhBmTy9j/V 6Pft3Zv3P1fXU4mTW3QSBZDJVikvzmwEM1dWk/55OkjBTOEIIH/cJHbBd5ySSyf8nYr3 XVShpWwYMGT5wydh22aMcnHHkBoVmPXnbRxfn3vLEc6hWJikkwQCO5f573PdcMZ3YKLy pJYo6HoZIJQscYimI7J1qNi0NQ4+j0bE6FzgjyVvodviWq+k4Bd52HhYFNt+9SB/y4or /nPS53FQattU+5NmEAieBP6uqDbABxdvJRoMC9aDciusK16wEgw/o5d6qk4vkgySGst6 48RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778490217; x=1779095017; 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=MrvzrHYJp3qtzaZog5kuCX8qehdfFd6F9etMXff3gHQ=; b=GZdqAbJ/HLLCl8EQbrJvUH/++PK4lrWwUt6sbe7OxVrn9f3U3TUN895T0OsO89kU2Y XEX2ezmSVyk3L6A+pDiNi2holYyShYIukZhk7J3h5lPuAcMskTTGxi6MchJSbhCyQlFV 0Il8+WlJ6tARwB0Q7RHccnyRbvvZvOYkVxNxtb++X0oj3MlxP66q1y6ltAmvO338FBBE GBj+BDPkrzQJulTqHG5c/AbTb7mqOs9PWxDK8KdYLxDehBi9bcdEk/sNCGs6xMUYrLUA LtrG0SImtv9m/1Ln6USsCxOSCyu9tgQ8rwo1PWl8XZYIDJNCnF3X5CjZ1nBzE1vBSdi/ 4tOw== X-Gm-Message-State: AOJu0Yz5Pmu5jxy8ot6n2apKaPnV3JRZXe515I015cOUNHN3VoyxWVi1 zF4lTp0MGP6ow+lRV64ESGZjOW/KANKkXDf30r6J2RzCNBI738aWamPmT+2TJgWGhf5MjsxseKB Ian9m0CPqAlIV4GLmRLBm/CEdfhjZTeKvfBCCR4tXsQslzP0Rij5d6PGjeowa4l0sFbqllwCRQp UYkvr7Ql/vT5xdPzLKNJoTzMV9AaJvX/29afg7XR2lBZg= X-Gm-Gg: Acq92OG9Q4QgNzvEeUX55bD8mG/hu/HTcc7D/i9U8E0Kq0jtxzI0JTBgyVdSj0k+O08 6YFw4QrRYkbqqEIZIwzOwwAejB4+mmNSKlZKsfvnTD6ztgAgtuJaZQbETy1QNKxCUNodSzqy1js 5rpMR4sNiiLMHduJEOPLGEt480UBHL1YtyfB49W1Jnk4ZRO4uM/0Sh/Z+1asRf1aHkSj3ld+PxN 9N0xoAYG66D1cBEZwXiyajg9eG90+DZHqwIwWNqeJ4qNaw9Qj97wbjmiCt2N0JN57y644pU5QDQ qfOYNwwrPbw3wXKfPXXNNW5AW22m1sL/IFfaoLV9UAD89JfxFV0OTJJLb4+KgiWshwnQ7DLm7ei odY35OWoRTofpnVX4AmJziyJ2U+l/2DJWs5dEVcOg X-Received: by 2002:a05:600c:4ba6:b0:488:a882:c7 with SMTP id 5b1f17b1804b1-48e51f4bab4mr214596045e9.25.1778490216205; Mon, 11 May 2026 02:03:36 -0700 (PDT) X-Received: by 2002:a05:600c:4ba6:b0:488:a882:c7 with SMTP id 5b1f17b1804b1-48e51f4bab4mr214595015e9.25.1778490215419; Mon, 11 May 2026 02:03:35 -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 ffacd0b85a97d-4548ec6b071sm23711514f8f.14.2026.05.11.02.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 02:03:35 -0700 (PDT) Date: Mon, 11 May 2026 05:03:30 -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 , "Liam R. Howlett" Subject: [PATCH resend v6 19/30] 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.27.0.106.g8ac3dc51b1 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 37e4fce9eb38..6c957a9daeef 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