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 2A9C53CA49A for ; Tue, 12 May 2026 21:07:03 +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=1778620024; cv=none; b=p0HcoR/cDfA6JH1xtKpBStlr0VZpu8PmNUKpranXpphAcxJVbME0pVSBFSBT9Ww8jAs/P/lwV7SmsEe6DsJV6VqnFv9jI9fXBtjei8X9jvyuvLvfKliMFzytoKuKE3OL7ZDtOOroIzbBH4Ctr40XHzbQGtl+qiCf2J4lzdOhC60= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778620024; c=relaxed/simple; bh=S3lspdseAiA9VDFP1z5oU53ONzTmuB9EAtNlvAmS1xQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GaPCd+ue4/bTfcQYgIayDP0OfRRKoLg2xpm7A5vQ9BA2zM+Ats6pTkKbwBF5OA9fNqzmJK6KsKnWG+exehbr20duRzL2FzIfGQQQJvs9jFbLS39h0jdvHHpv5ZVu1vKn2yLRFcSkIXCQYk8VTNS45UBZi5GQ3lOWCvKfSGrz958= 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=LtYtIIDi; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=HXpk3uTb; 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="LtYtIIDi"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="HXpk3uTb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778620022; 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=LtYtIIDib7iHZUhkzRwiep8gStQBfSm5oC5DU1iL0XgfEFe5B5VIZbVREkpTElgDG0QJNn Qpbu+vNfXfoTC9VOfWkdldgilViM9uSVJ116bKewh2+x6ggC+ibWRrUI95Wa/PKNpQEglK vy2/o9dHfbMlUBHOihuw6kCnRGTXZlA= 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-235-ZeoJ5R3HMuqws3VgJBEsQw-1; Tue, 12 May 2026 17:07:01 -0400 X-MC-Unique: ZeoJ5R3HMuqws3VgJBEsQw-1 X-Mimecast-MFC-AGG-ID: ZeoJ5R3HMuqws3VgJBEsQw_1778620020 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-44d9ace59efso3950392f8f.1 for ; Tue, 12 May 2026 14:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778620020; x=1779224820; 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=HXpk3uTbcH5piHJgiQFw4NDC7LZcqlobEp7S6UJSe7uQwEvMznQPT+cpw56vO28swX Ut4gXoSSZ+g7ZmEE9ciUiBSpUrrwxndXiYha5uwZUoIfyzzB9RuZ6s2rQcxbO4cfVJbC yWw3WSkKmjcMcyRnUnhj9ItYxzYY5m+j/AVI4k2HnYMf47XISXO6ZAeXoG5xsuTD/a2Q rlWH2qgJH2QPPPXpAVFwE4WvbrzVlOdoMxG7DNHqVSEa/gkub53sk5sLdzDPSeaLKuBf 64JhZlwNr7BH2EpOQ1EXbVUAVPeR1gZxboPaPuGIfSWzaBl3VUdsd56K8mReOEznBWT6 YK6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778620020; x=1779224820; 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=TzNo45EHoiYUHAuP1ie2INajPKrpnmJC0DLJ4MNEk0hgnL+/UP3sNwgREAOpTKAR1X zePMzpas2Ak9QHrx3ToXcgcGoUlqotBJPHCCto6ayQCFjmH9oqMmdxZ5F4DcE9ekfQPA NQciPmils2KbzLXQkMn7nJhGoZjfagMSazgMM8Myp7WbmROcq9PVN5b4PR+WaDgYV6Hc T/XKG4d71ctZ/b6HD5dradqx2W+JTwxgXT4cM9azIGipdyOX5sZ9+qYzNrEYcfm6DOFb wBCbryV8xzy8SyRERpRrvxT/lpXoEG33zs9q9rjbb6xeazohUrI3CYiaUEYlhRf0Mwm4 5uxQ== X-Gm-Message-State: AOJu0YzlV42bJpNI4bGt+RdAQ77TLTp704ySnUZhaJBnyb99V3zdIOjW DIH1Mq0HpDd4zMDMJ3u0WnxNygnGgOm8h2Ij9L/ZL/S9ItfeNGyv8+qsX+tgZDWXXuG021VbHE7 N4k+CzLcsOy45evg97ROdNCDdPl+jAB24GaczsvPJkriBsf9QHPsxuIcNngR4l/VbCiP9ES+53P f5PiUk6y5sAL72uufvkht7Z0uRaiiP/QK95bEumGgIlm4= X-Gm-Gg: Acq92OEELsa/JekETY//tiLCSgZ75dB5ouLHJo4s/2KeObqJm6tV/w4wRT6zaKf3pVj /2DKrAqWHf2YgxC0k2jDnCaZltb+tmQtc5qKxSQFxix2vWch457a1S3H9jv6KfUW+71HAH7JIxb Ka+jvZF/oNDEkiU+X8MDdNtvfgTSEOVIOf11CFqYrfNBNZyqdpHJjaltmpb3JlIbLfB/I8PAGZS PmSRAnjB8q4Q70RzxA0DzREcfSaMyE9k/dREooUoo6fC0pd0MoS4nd7GhvZpsuL3fx2ATU2hV2j Gn7s7bBz+28xdTTtloeiWgymRt4tBTVGv4B560OnX8a4gYeUPn6oKpP6ZuvC+MjDnP5hcvbRjHZ TMaeXfhA201CP9Jsxf/9XKZg8X9jir8He01wfYZi6 X-Received: by 2002:a05:6000:2081:b0:454:86d:b4d2 with SMTP id ffacd0b85a97d-45c57536c87mr530504f8f.8.1778620019599; Tue, 12 May 2026 14:06:59 -0700 (PDT) X-Received: by 2002:a05:6000:2081:b0:454:86d:b4d2 with SMTP id ffacd0b85a97d-45c57536c87mr530415f8f.8.1778620018807; Tue, 12 May 2026 14:06:58 -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-454916df968sm36702334f8f.25.2026.05.12.14.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 14:06:58 -0700 (PDT) Date: Tue, 12 May 2026 17:06:53 -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 v7 20/31] mm: page_reporting: add per-page zeroed bitmap for host feedback Message-ID: <929bcbf8d4bdd51c038ec302e2db26d82d942ba9.1778616612.git.mst@redhat.com> 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