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 90F1939BFEF for ; Thu, 7 May 2026 22:23:25 +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=1778192609; cv=none; b=lKtr5pw7AzfO39SOyiXtd0M+IeTeUP4rIIPzasiL1n2TkLlFuMX4/vtXKGnZUhel8bJ9kJ7CVpwPH+PxoVzDw979LLKtbhs36UKQuiib23HFHKReZpReMBtkhcRqIA+/bSAY5YB6hFKzqJcK8Z2mCdGITfoG6J/hOjbP/rF1yDo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778192609; c=relaxed/simple; bh=h33C6BLNHiocTz5KC1arzWXU6+/Zulu6S8cQDI8rRLY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hmim4foJOKi6MRPzQsULr+snNn9516wOmecV5JWBvpt7ntfUd1zfWJagBOzaWvQlxlA+T/yvpHPB2kl4Hpfbvrnv7qKdTOpSsl0NwiZAkKdS0STO5OubsYiraO3UlJnNj2M8NrSTiiT3ueGrd4Q/b+d8p4+EgZ8G84wpWVXL7Mo= 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=eboJ9nyN; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=aZ3+Oik+; 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="eboJ9nyN"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="aZ3+Oik+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778192603; 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=b/zNXUvir974pwEF1ci0jhyssPrmgKAWIncWIRRvDt4=; b=eboJ9nyN0J6Xz1uPqmF0zIYREMUnd0WqRIpmf5D/ymBv98xSxNRenfH4edBSTxYjLzUy4i yrIxkVfdWSFHUB6g/ZVl9qcaVgXMvqHcc4+Hpuh2rrFGyUOUO4CN+/qUhX/J24O5dWX3cM ch+UmGI6YECEFl0LcngxHFKnqTsd15w= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-694-_Lv16i2xO3uEsf2mCldeKw-1; Thu, 07 May 2026 18:23:21 -0400 X-MC-Unique: _Lv16i2xO3uEsf2mCldeKw-1 X-Mimecast-MFC-AGG-ID: _Lv16i2xO3uEsf2mCldeKw_1778192600 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-48a548b585cso8249655e9.2 for ; Thu, 07 May 2026 15:23:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778192600; x=1778797400; 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=b/zNXUvir974pwEF1ci0jhyssPrmgKAWIncWIRRvDt4=; b=aZ3+Oik+za4ZWLU29Nk8pRsV8288EZVlSryr868VBjYSoRNg4diFPZzVfGeNlBeqSD UDktZXpBx2uPRCj8uxANKufwZBKiR24BtfeYkkt3iZz9YGisClf7Sggv+rq6YMQGsTtD BOuY1wAhhmvrfiim0g0bkvjl4S7GBh451T5glAuYblftRdvtFg7b/8Mc5RpUUl5oNYYl ZGV0zE7apzaAEcty13m6jSeAe76Lh+Ult0ixM8nQhT8L0+RZV3qOGXzubwtz+VhWceHU 3jRqw/jimxPbf/mcinKJ/M5W/MOQQurwXQsFAtUA5uhGRlXusTdcI0DeAlDof8giB8dj FMwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778192600; x=1778797400; 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=b/zNXUvir974pwEF1ci0jhyssPrmgKAWIncWIRRvDt4=; b=oyJPzIas1RG/q7uEeALf7vYtkHMVB3fLU4FEo2nqo6kS4HJId/a8dPogtoHXqfjbmu lxlpPJE7cRNXQ4weC6/qX0UJCYhgCsd1v/B3jlpv5a0+u3AkvbbJZRzxuq+pZE9g3bEK 6DplGLb2A7C7vFtOwKilEQ0SuDlbjQkCRu2u1aZ0EDkOUgxOS5Rl5DuZMSn3euMKB5EX fjdbKRz5YzMbxUKfyq7mGkyM5AF0NjKpD7/EEqZpgaMGf0vo+cLOoJfhkPmyGwqI9qqA yz54+cZyL5DMwpoCij0M4WSDv8eXzOYjL7shSpuWdysGJDwrZ1LfrSpXFVbhiTh88joj A7+Q== X-Gm-Message-State: AOJu0YxjtTPQ+QQRP1meR/b15S3PwNovVxnFZDTXDZM64tSOBtyV2B0S RRenZqDgnNRJCsqwaFwLkZvmA9IvnhOuA+6ANeoaUknx1bXyXZm39QsHNNZ9pJwe9+pjVJYKKo7 mvDYBgUCwLENG3qH5eqVpPNwToN+3dhuZfoV7xqEYf5SageUiS51CP1PL/dSXqb025f3kGeFZei coZZR1jBcLBTKIVEfYSuWPQH+riTEdcqykEYS10WLaAq0= X-Gm-Gg: AeBDieuZE1k4l9EoRvPon6ydb3AEI/S+o8UE2GwolUEat2m963CjxVgbTC1pmxf9/Kw n9qtbm5E8CJ1Pcr2SsDjoTJRIwQvooKsZIHu+R72QSEOhtfBcuyvKrbGmV5ic4fOi1uicj1xByS sXZvN3+begySaIMfQfYNPPZdLbU7EiIFkVsMK7mCzNZanrKFkoDkEknK1CSMqVw6/ecfA+UcP5Y 2yuWVeE/5PoycspkYes0K8ktG941s2537PSEOQ0ZkKqzO4qbfuKAzMCsA9wU3w5lte8dKpvxZUT H2upw4JKy5i4udfwjoejcfdCmUSfBjKGPJTiDlh36snoYxK2Nsib7mSILBaa8aJiuNOM6qrhcwC HjtKE8FVX5wFCMQwjMCWO5EDN++eI+aIdfU5hzJVN X-Received: by 2002:a05:600c:c094:b0:487:5c0:671f with SMTP id 5b1f17b1804b1-48e51e1a7c4mr115500095e9.9.1778192599496; Thu, 07 May 2026 15:23:19 -0700 (PDT) X-Received: by 2002:a05:600c:c094:b0:487:5c0:671f with SMTP id 5b1f17b1804b1-48e51e1a7c4mr115499725e9.9.1778192598907; Thu, 07 May 2026 15:23:18 -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 5b1f17b1804b1-48e539109b7sm142179255e9.15.2026.05.07.15.23.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 15:23:18 -0700 (PDT) Date: Thu, 7 May 2026 18:23:14 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , linux-mm@kvack.org Subject: [PATCH v5 17/28] mm: page_reporting: add per-page zeroed bitmap for host feedback Message-ID: <8f7e00cf0ab76d2d393e043bf82cca32546e9e4f.1778192416.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 81e5a2819b3c..df929f682901 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 1f48fcd7c042..8137ff50ce1c 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