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 BBEEA35898 for ; Sun, 26 Apr 2026 21:48:31 +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=1777240114; cv=none; b=osKTsiuKVnCru6Bhozm8Ol80E/QfPxSUqvP+jUicXMZ7xfcS+ZvX4fG1rSupVeYAcoSyBJb4UJsab4Wi7BcOjxszSdxo51LtTNCvSUlWMJnyCQEAeG148V3AIoc4MuW7Ej22UnY8SHsWZu8g0j/vxHOkuUsF+hGoAe/27flJj3M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777240114; c=relaxed/simple; bh=/H/b9HRDS/FqkVfSUr24VvwENCpz3EuK5eZWes4C9AA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aBtYch+jwgMKZijbuUzGGf9XImv7J6UxwI8+sA+pr3CLCHZMswj0XFXh9QmvE+Gs2AJcVqNlmrTOHYglfg0alAR2M3JqiDeITbpw8H4F+dRr83Un8e6eCAgnPk92x7yinwyyD9FcA3fZYPxuEFQGeY7ukYYix9l5QVXjWpQ2co8= 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=SwcsLbti; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Olmy6e6U; 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="SwcsLbti"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Olmy6e6U" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777240110; 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=fYAXl7F7h4aq1MzyiFunWzYtUjLEe/+xUEddBLdqVEQ=; b=SwcsLbtitcVK8jbszpUgM3IryzkOa1gNUYYMushC/1zT9kgtGN6nN6cGsqnJLeC7HS74zb 6A2OavUx2pj2sP964qLQZitSLAeAgnJSuysnXscGMyTXI0NYgGRPc+xsv905j/N+UP+xzL +R9v0tPcdF5zB0dcEgpw8c7nRUodC28= 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-367-OVAC0wu0ObG6ugIUpzcKLw-1; Sun, 26 Apr 2026 17:48:29 -0400 X-MC-Unique: OVAC0wu0ObG6ugIUpzcKLw-1 X-Mimecast-MFC-AGG-ID: OVAC0wu0ObG6ugIUpzcKLw_1777240108 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-43d1fec59c9so6059654f8f.0 for ; Sun, 26 Apr 2026 14:48:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1777240108; x=1777844908; 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=fYAXl7F7h4aq1MzyiFunWzYtUjLEe/+xUEddBLdqVEQ=; b=Olmy6e6UIf+Bh1unV4FKEwxFSvxID3rwgmdhTp4I+6SiR6L7ABQbUHVWPbJ2Gw4lys JcvNzeq5Cqw3oxTbXML2gRiCAM7FCcrETJEpTMG0YxalFQOkbu1tnXkmgbL+688A51la t6sme+ocPA4Upou2ZZKzYtMpG+9oNaql7VR/kJ7BCGMUkbOvfYeztsAi8i7JwcO9CL4T PmPpV6bKIdWFnPopKZr6k0AiD9zGp+N4U7UYJrhkgROT4h1JPfID3MnFopTLg9awUlbO UFeWHTcXsTSNOzipo4luuP6xoFYKftSDAs7PlXayAQgyR7q+0R8AGfw6uo+7arvucKQ/ 8+7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777240108; x=1777844908; 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=fYAXl7F7h4aq1MzyiFunWzYtUjLEe/+xUEddBLdqVEQ=; b=M+tcG9YGhEFNnPSv9fEiqObFYIYzZlmiknzHBLfHUowt3wXDnKqYed0lUu6ZT9I/9u KHVizDlKV+IkF56+onBgoV1xJjnUvdtPOhjRi6r8BHh3BejVQRtB5s+WEtRMDRSQFSdA 9DSit7iDX+Rnjlhoskp8PWrnvsRyyURYsR3Hpq4n3MLD6UhlUoMxdNNgtS0T62RWhD61 yAsp3LSKurmlhc4wks40Vuxs6Ia2i1VeNp04VSMimskUcUpkpB2jPZJjeUxLVa+K+FYQ jBG5nxULuhBBQ6hUsRs8EbZaJLGWSuSfQqR/Jk7ITw5goQ1HG00rc2Tq/BmSfUMSTdOx BQ5g== X-Gm-Message-State: AOJu0Yzq084+1bWZv/riRbxWCTSI1hYAviBL7ClVyZQvVbK4pRPaf6Gi IWncuW9UHVCLW/vM6mkRpj1P74AHu/A3UA83vG2mRnqcA+bXnaFgKC8srd9fzDiNqPupjZoJuhY ZtJTL/8J1DYEhmdWExvemd/WJ5SyL+dbzKb2kwqI2Rkl/vGp6ayqs0GLS3ks40yG1LoJP1lKr8O uyj0ZRZD3ttSQg6c5HqfuBjHOXJWs6SN7g1nC5TmRbsRs= X-Gm-Gg: AeBDiesYuw7etspcREVtfRoqp8s24LHA4/FHfJfj8XlKFp2EFRtmVU0WKgcIT9dniu1 p8j+2xrW/5Lg4jjAimGQfZ0WGXZBswxS25HTZ9bRSq7vleuEL1pVJhn2gDR6FklZ6f+iQ92wjOE a/OrF0xUCx1YPMixYaZ10Vf7EmB6PgH/rSNvf6n2mJPJwPAra4vYWifNEsjZQ219H/gaexdwWKq 3p39Nau80hUaFDbGX9+U0NnFRDJsB4jl8pEP+CQ6aaC24F6m7rY20wQRoH5llciS2UdO/wuzesW xXkBVXhfHO7Uu+XGv553qcFHf+ntMRTU2kFqSow6j8B5ZQ16RbIV40mmhHnHpeIdim69rTO0BMR hELN7Y9ayrB9WnBmGDFUIC9y6R2664Nw2oFVuBhZtCZBVg0eVdf0L3pnh X-Received: by 2002:a05:6000:290c:b0:43d:772d:2b61 with SMTP id ffacd0b85a97d-43fe4073831mr59751637f8f.15.1777240108122; Sun, 26 Apr 2026 14:48:28 -0700 (PDT) X-Received: by 2002:a05:6000:290c:b0:43d:772d:2b61 with SMTP id ffacd0b85a97d-43fe4073831mr59751578f8f.15.1777240107558; Sun, 26 Apr 2026 14:48:27 -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-43fe4e3a79esm79138134f8f.17.2026.04.26.14.48.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 14:48:27 -0700 (PDT) Date: Sun, 26 Apr 2026 17:48:24 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: 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 , Zi Yan Subject: [PATCH RFC v4 17/22] 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. Before calling report(), the framework initializes the bitmap: all bits set if host_zeroes_pages (optimistic default), all clear otherwise. The driver's report() can then clear bits for pages that were not zeroed. page_reporting_drain() checks the bitmap per-page instead of the global host_zeroes_pages flag. No driver uses per-page feedback yet; the bitmap is pre-filled based on host_zeroes_pages, so behavior is unchanged. Signed-off-by: Michael S. Tsirkin Assisted-by: Claude:claude-opus-4-6 --- 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 10faadfeb4fb..5b63de21949c 100644 --- a/include/linux/page_reporting.h +++ b/include/linux/page_reporting.h @@ -16,6 +16,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 6177d2413743..61f7f08d02d4 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