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 7AF353CC33F for ; Wed, 20 May 2026 22:22:40 +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=1779315762; cv=none; b=YbfRuJez7W8BuSKFiQMPJOd4MQcPYY0R8DOxhtIj+PKZFLQcZ8Tu0lqQrNYDBk++LJbM8w6D3xR6RhQUJRoFsyPdOwFmh9NXfJi2f/LJc/d4a8k/oIsq9I5ESPYN8rOdBH/0XSIx/ue58KyyjAYh1hP7fQkdwdFyX3eit6EHgzc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779315762; c=relaxed/simple; bh=h05Q2nCn+o78fr2Uz8tfGJ7k+kZvskvt29CW+J/CzdE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WFEnyeVuad7fM2EOzZsvsfYKFbFNvlwwbgRax85+rnTm1jJJo5kdv4CQWK7dgMYSidVNTOEc75zqLqjXbaYQpbJExU14hTDjifS0kCfnzFZr2XMMl1Z8IzgR+H2xa3HTcJW6JVGtg5AF5iyalx0WyBCXqiXhBJKXBdTCteA5xYg= 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=SnQIQfPe; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=InxaoE6P; 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="SnQIQfPe"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="InxaoE6P" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779315759; 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=ZUJUQcTEBW8Gz9Bvs58sr0Q3FF0IZpsM1OCMvoStcIE=; b=SnQIQfPekwx3WUJI6XlVlApvTGuyUMTttq/3IgawxE57zhnwDz0C3YnytfaBwGwNkadWMA mWIvN8yC7IgHVuhsWj0rjaI3od+GL22tU1chEd1CA7f0yWxZk5I0gPE7av0gFx06vwmkY6 EPhTJrndAgubRTWSNpSfWTPao5cG7aM= 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-152-bEsmkh8IOwSalqrU4mU-8Q-1; Wed, 20 May 2026 18:22:38 -0400 X-MC-Unique: bEsmkh8IOwSalqrU4mU-8Q-1 X-Mimecast-MFC-AGG-ID: bEsmkh8IOwSalqrU4mU-8Q_1779315757 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-43d7b7bacddso3992694f8f.0 for ; Wed, 20 May 2026 15:22:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1779315757; x=1779920557; 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=ZUJUQcTEBW8Gz9Bvs58sr0Q3FF0IZpsM1OCMvoStcIE=; b=InxaoE6Pz6KPOfgFomfRjP0w+Gsb8BulI9UkR4iJlAHMRihkFbexIIZeuPu6uyHQ5X jtufJYgxMJJzMvUWqNEGvIctVedTFYMEYVzcxr0oRIbS4BfdDBqWGItZig5Hu+ZirHKu EU+X09yy/+b3D7c/KIWfS7u3437NIG1LkY2TnA3eBCzkloGZGhtIJ17hRqLC/qhwI1KM GBo9hvpfIOtlyrMhiaZRlBIutrMPSY3pBIh0Bh9b8n6Jn5pfujQqMfB8c/9W1Ec2+0S6 f3Cleiu4BvGPIHlgSSDIggF0E4FYD+2LH086LM/Zd0mbjsTFNQkSJy7VPUnw+SGaTsAv iW1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779315757; x=1779920557; 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=ZUJUQcTEBW8Gz9Bvs58sr0Q3FF0IZpsM1OCMvoStcIE=; b=Z83+5kHL3Z1GYsXXgUY4zZwrKY4+ONnmvD1FfVflQMIvJujiH7HDK5UC68XESNavwW msiax/ZNOyKB8SyYLcCyF1pBFZy/oH3bVW0rfq9U/TOhgvAqOhE6HfCGpTDY6ybbaXeL AQih8d9xepl9K4SDdcMWtiCJaGuz5aZCgesdD/36i6eba1PPAY8y7SOht6dVE1skOITZ l3ytqmbFq4/z9Uye1cowOzGLPcMM/n2IllOSHoc94XXV+MwNslatLRiEyNXkCx5mw8ym TT/9Y5HhmYZsjFBFmNEibkxsnAHRd51gEyj2QEsAOTXJpt5S4828AezZlW9NI61miBFP soaQ== X-Gm-Message-State: AOJu0YyL3wHJgQmkNU7O4+5lZM8UWbmzwfcLHVmR6+JX121M6ibxChK2 FqgfI3gctUSivyHGkOob/KgG2J4iQkKigsiIRKe7Xb1gcZzpV6vd2PVX6bvVcmUp21+Gd3KokTi vH0SS4GV+p5ZOCAN0uJ0RrRK5XA4laVQjxZYkpBoz4zqMgZwQd0GY04kUJfUnyQXzUJt6uvHGlr TjSoiXhWu/h/8EoggjZsULe5zNufR7RruGLqUJK/Y5EuI= X-Gm-Gg: Acq92OFF5sS67LtU//L5yiW22rI9PIDhvsTgU9cOPbdqusjjp91h4j6lhIcq4ZJ9lXZ 63AtSLKUTXtlRlylt9ZcdOC8PBpMqE+X+zAMRywksHv+Te0cxhiDOzIea6sLP8uqAehIr51bEs5 BhR8RYzWtnuViXqqFPnXAHdn3WmLNtpuKpPdVK3+9vCO/tAhhmywIIHIzenXZ9/G2S11e1Zqaed UHJT7nhyDgH6r0DlDkrZq4umzNuCtYi3XS2ebifVGp0kF20RdPNArTgGoygUarK0oKjzsZhROvn D/QCDV9kBQ8DRMQGnyZspIp8pV3XBI0SF4S04cjdQSFTcDrEa3U1gb2ZEdQ2TEwFBZryp/Y++Nf evf3x9g4K8F18PtrCKYbkDdSWl6a9XmgdRZ+5xmBpf2c= X-Received: by 2002:a05:6000:2883:b0:43d:67d1:2022 with SMTP id ffacd0b85a97d-45ea38be3aemr335125f8f.19.1779315757155; Wed, 20 May 2026 15:22:37 -0700 (PDT) X-Received: by 2002:a05:6000:2883:b0:43d:67d1:2022 with SMTP id ffacd0b85a97d-45ea38be3aemr335047f8f.19.1779315756519; Wed, 20 May 2026 15:22:36 -0700 (PDT) Received: from redhat.com (IGLD-80-230-25-45.inter.net.il. [80.230.25.45]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45da15a6454sm58643722f8f.34.2026.05.20.15.22.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 15:22:36 -0700 (PDT) Date: Wed, 20 May 2026 18:22:31 -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 v8 24/37] mm: page_reporting: add per-page zeroed bitmap for host feedback Message-ID: <56b8f941ffcdef444d8c2aee62846bb8ad53ed14.1779315441.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 e42f857485ce..691a9e66aa5b 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