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 AB87C3A16B0 for ; Mon, 20 Apr 2026 12:50:54 +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=1776689456; cv=none; b=X5f5V59ojhOT4nOpC3e7yNcJj9b+g4UYOHCeUVB3ZMtdaU/sFboQiKBg3WNyOZnOMIL+DaglFsI+8blL28PNQZx5Kv93UKmQVzeTFweMCH9TXh8MgRRqypbdWaBTjLZvkmsSeMAFPgO0kIa3ChnwWSryn5poKNJa5+mTnTuSsN8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776689456; c=relaxed/simple; bh=bRdsihvY4zjKId/liig+sN09ZPno0nPTrQN6V1MCrqQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uzfuEFb22YRoh7AZmJ1EZuOFMrQ64FiHxom/OGkNXJ5BVLbhkOCi7Jfe8Bfr7OvqgQWfsAegm/lQd/ZUeSYYwIdIwuuTM9NDZ4SM6XJJKsx5SjeydjPzlds6+as1mGhCNzriGY6glyUh4+061lsRgNjEdFXGkVB3iuD3ffaaitI= 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=Oj/469f/; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=cvaQrkHJ; 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="Oj/469f/"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="cvaQrkHJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776689454; 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=mEMCfIlCf4bqiMJiTJpP/SQ3egOk7/aPzZBRg9jsyO0=; b=Oj/469f/YOrWRQaFxxtRODheMB9uo805ZGKPB6nkatcRWDdiSPR6c6mRnFFZGGdsvL5Qiq jINrHqzXIDQWVSOv+M97zLWPgTdM5bwwyYb5CIPaYb6z9SN2QkD44AbVqOFbOUKB++fQSU zZTP9RudkybQtMRVyjryXt38N3rJm1w= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-43-zTyGySn-N4u1evJFXeV-nw-1; Mon, 20 Apr 2026 08:50:51 -0400 X-MC-Unique: zTyGySn-N4u1evJFXeV-nw-1 X-Mimecast-MFC-AGG-ID: zTyGySn-N4u1evJFXeV-nw_1776689450 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-488c2a4e257so22395145e9.3 for ; Mon, 20 Apr 2026 05:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776689450; x=1777294250; 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=mEMCfIlCf4bqiMJiTJpP/SQ3egOk7/aPzZBRg9jsyO0=; b=cvaQrkHJfahPqer8xzRhjC7bHKDCksMmECPqnNZmFmxDyiTgCC8QiLUlHumWHx70Az G8fpcpAk0ONSypXLi4JnZcGPx2m5KRo4ILAPlxRYolX5bRu+hwvOcHC5m0ZpVF5YHTu1 hG3PZFWHqpgW+LDGjoe8c00XnDPqMZe8Ci+xha4N0NdFfUmLOUCCg7vcoRI3uxzXSpsM Lg0NOcedxOC8YnsQJlpHg+D+6nfWJX0IUw/Iu6BqqZabXhLyaD+7ku4ApNZ7I52Rqenb lz2Sy3EfSaOHUOiho0UIJ1r/xGbjOI/l7UHYcPPgu0uHNllF/3HNQ6Ez14wX0RigaLFj R+eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776689450; x=1777294250; 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=mEMCfIlCf4bqiMJiTJpP/SQ3egOk7/aPzZBRg9jsyO0=; b=os5PWmsuA7892kvC2e9vlmOVErEIZpfreIFBSOCq0HNgydnEhRdjxlR7f+edYhsXJ4 /XYNO9GUe6m0nF+ij6ilJR1+ZkmPofRH9Y54VYXwEq9hAp2pMdMGpqLOFwstLEWitZUd gNo0k4dMDh2E6Yj81puYhxlKKIRdCJGjYnhsLCvCClchklSgRWQq28WxQwGnuPwgwlt8 StLBRElE1VZKmO8uY35iCzaF+52oOpcyI00llYT6SrbqaXPaDrcj10r4krL/hlS8ajHT jyGsmy88a/UP1nT8Sa5NIi92nPLDuEz3fEfE58TaiJs1x4+hlLSMqOkR0iYJff53xjWY Tz4Q== X-Gm-Message-State: AOJu0Yz8HPVUeRjVf2s7pvtZskLaGzfRbjDusg3bGRzypKPabcg/rtAK cCEDe649B9+Eevfqo1/IH8Aw4E4hJpSs9vz6sHTswyyMJuV9kxiFRSnUekA1NBWOI1nMMfO2+HY 4vaqIFtmOqsF4LictUpWMaUC+O9RCe4I9uKv2NVAsnJIoj2Zo70mYab2hyyJdjtfD5u2jgBuCFn 05ZWMUXqZodF4HitlQYCrTHOiXCbjH2YmUql13tN+l6gQ= X-Gm-Gg: AeBDiesJSbQ9VwvMSNN3Wra1DWQUF7Ew+GcWtzoQbWTvgoZuP4oTuhTdAcO/UD5UaV9 hcKOEkwv+XetQfpPXY7nnAkTv+KXo0UiEDx589w1nao4wRcAukN3KSDAKnJN8w/6SCatH3c/ejK zTHbovcfMtaA+svyVoJ1oJuYl8F33nTb8nQKsZOHWm6vFtPo7uTqSFTR8gdqwf+RRf6UCP1H3gc yW6oy4am9x1AQrBiGfoAqUeL6tl7oJk6PiJlK4pDcueh0qttrqODQgCmXMTWHHCi9feVgD/38u/ G+28qHJhkKqJx/bz7soOdDoTeBWHdm45gYQ/pg8EepsvqqvhI/wI7gvrpci5SaGJMosy46EE22J V3gToYsS1Q5aJEc8pAJgzeIZoCO4Xl1vwTHJ0gydHVpYN+fjvVpKoxA== X-Received: by 2002:a05:600c:1f94:b0:489:1c2d:211e with SMTP id 5b1f17b1804b1-4891c2d2213mr56432665e9.5.1776689449965; Mon, 20 Apr 2026 05:50:49 -0700 (PDT) X-Received: by 2002:a05:600c:1f94:b0:489:1c2d:211e with SMTP id 5b1f17b1804b1-4891c2d2213mr56432035e9.5.1776689449374; Mon, 20 Apr 2026 05:50:49 -0700 (PDT) Received: from redhat.com (IGLD-80-230-25-21.inter.net.il. [80.230.25.21]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4891c08faffsm149479715e9.1.2026.04.20.05.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 05:50:48 -0700 (PDT) Date: Mon, 20 Apr 2026 08:50:46 -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 , linux-mm@kvack.org, virtualization@lists.linux.dev, Lorenzo Stoakes , "Liam R. Howlett" , Mike Rapoport , Johannes Weiner , Zi Yan Subject: [PATCH RFC v2 10/18] mm: page_reporting: support host-zeroed reported pages 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 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 gates the fast path. Set PG_zeroed alongside PageReported in page_reporting_drain() when host_zeroes_pages is enabled, so reported pages are marked as known-zero at reporting time. 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 | 3 +++ mm/page_reporting.c | 13 ++++++++++++- mm/page_reporting.h | 11 +++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/linux/page_reporting.h b/include/linux/page_reporting.h index fe648dfa3a7c..10faadfeb4fb 100644 --- a/include/linux/page_reporting.h +++ b/include/linux/page_reporting.h @@ -13,6 +13,9 @@ struct page_reporting_dev_info { int (*report)(struct page_reporting_dev_info *prdev, struct scatterlist *sg, unsigned int nents); + /* If true, host zeros reported pages on reclaim */ + bool host_zeroes_pages; + /* work struct for processing reports */ struct delayed_work work; diff --git a/mm/page_reporting.c b/mm/page_reporting.c index f0042d5743af..5e1e1a924b0c 100644 --- a/mm/page_reporting.c +++ b/mm/page_reporting.c @@ -50,6 +50,8 @@ EXPORT_SYMBOL_GPL(page_reporting_order); #define PAGE_REPORTING_DELAY (2 * HZ) static struct page_reporting_dev_info __rcu *pr_dev_info __read_mostly; +DEFINE_STATIC_KEY_FALSE(page_reporting_host_zeroes); + enum { PAGE_REPORTING_IDLE = 0, PAGE_REPORTING_REQUESTED, @@ -129,8 +131,11 @@ page_reporting_drain(struct page_reporting_dev_info *prdev, * report on the new larger page when we make our way * up to that higher order. */ - if (PageBuddy(page) && buddy_order(page) == order) + if (PageBuddy(page) && buddy_order(page) == order) { __SetPageReported(page); + if (page_reporting_host_zeroes_pages()) + __SetPageZeroed(page); + } } while ((sg = sg_next(sg))); /* reinitialize scatterlist now that it is empty */ @@ -386,6 +391,9 @@ int page_reporting_register(struct page_reporting_dev_info *prdev) /* Assign device to allow notifications */ rcu_assign_pointer(pr_dev_info, prdev); + if (prdev->host_zeroes_pages) + static_branch_enable(&page_reporting_host_zeroes); + /* enable page reporting notification */ if (!static_key_enabled(&page_reporting_enabled)) { static_branch_enable(&page_reporting_enabled); @@ -410,6 +418,9 @@ void page_reporting_unregister(struct page_reporting_dev_info *prdev) /* Flush any existing work, and lock it out */ cancel_delayed_work_sync(&prdev->work); + + if (prdev->host_zeroes_pages) + static_branch_disable(&page_reporting_host_zeroes); } mutex_unlock(&page_reporting_mutex); diff --git a/mm/page_reporting.h b/mm/page_reporting.h index c51dbc228b94..a53ab22f4c49 100644 --- a/mm/page_reporting.h +++ b/mm/page_reporting.h @@ -12,9 +12,15 @@ #ifdef CONFIG_PAGE_REPORTING DECLARE_STATIC_KEY_FALSE(page_reporting_enabled); +DECLARE_STATIC_KEY_FALSE(page_reporting_host_zeroes); extern unsigned int page_reporting_order; void __page_reporting_notify(void); +static inline bool page_reporting_host_zeroes_pages(void) +{ + return static_branch_unlikely(&page_reporting_host_zeroes); +} + static inline bool page_reported(struct page *page) { return static_branch_unlikely(&page_reporting_enabled) && @@ -46,6 +52,11 @@ static inline void page_reporting_notify_free(unsigned int order) #else /* CONFIG_PAGE_REPORTING */ #define page_reported(_page) false +static inline bool page_reporting_host_zeroes_pages(void) +{ + return false; +} + static inline void page_reporting_notify_free(unsigned int order) { } -- MST