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 CABC53B27F7 for ; Mon, 8 Jun 2026 08:40: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=1780908027; cv=none; b=geQMR7OiVV0fovf5QWAn16oDuRPhSxFM2wrqK1FWaU/oijbopQMBFgXww1RXiVjSgmAgQqhzfBCHy93w8MzhzJEmewEVK3R/Wn/huHOOQx4yaojqMspxHoPm2cc8ZHjMwOxLZaLO3yGcDfBs+EsPgoPBzbgXLpAUwsdoSq/UzFM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780908027; c=relaxed/simple; bh=lBJ4LLu1g6y3CucnwB/F1BfG3upMe4x3Hxcooku9Cnw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=J3Xj6U000vKgVJf8IxxvGrx4kUy9R8Cc08Yk7QYAX7xligF+BtVCRfzGM3Jhfze14z3Qoh3wi89Jagsg3189Br280GhIeDn3Ec0x0IdbU8UkFg/me0YUhNq5B48vk4OlfX5epwdwMdXTYoVIED3MAWZRY6joiVweQGDhWjIDz0I= 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=Z11GtX6W; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=a+psbBqN; 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="Z11GtX6W"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="a+psbBqN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780908024; 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=71/5gV60k4yG26aCAIxd/scVyaKUto/kd/wMt0/Zjmg=; b=Z11GtX6Wa3L/mhVNq2UoDXcYEB1Eo0ZQEYh861HYCA5g0IeP8iQAEVir3s3hbiiXLViHrE Pw4dOUspS+i+l/XwGlvBgFi+bjoa//GOOJhA7WrWQpudxgjc9bANCB7Un6+CIEyVIcgmU1 Gcjn9J9oOTqakBIj9rF/Tiu3uvR130g= 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-66-zaLVg0aiPJaxJai_ZMASSg-1; Mon, 08 Jun 2026 04:40:23 -0400 X-MC-Unique: zaLVg0aiPJaxJai_ZMASSg-1 X-Mimecast-MFC-AGG-ID: zaLVg0aiPJaxJai_ZMASSg_1780908022 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-45ef0af9517so1922523f8f.3 for ; Mon, 08 Jun 2026 01:40:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780908022; x=1781512822; 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=71/5gV60k4yG26aCAIxd/scVyaKUto/kd/wMt0/Zjmg=; b=a+psbBqN7re3iT5Dy8bwCy7GcGg2/8TUGbbeR+FERTnXEvChHMP0jdOWsndL9DU6p9 BEk2Bs/cVAVqf3ItBzh0u/DLRaA+Ce9UvMzwJQ7KusGdRBfQM1DfDRs62aNEa08BojVB pODXCAf1kYdsL1AzrJFDvLcH1z2C9E2AOiiLBYu9erbk4IQY3JXpVwxpWf2ITSbBZTaN Tzq2IibxoLCjRAa1aKuPkeGogMpog5vJylctAyX7H2nXdqDnpn0Rz5nBkn0nVpiNPNtk 0ni8ICKy8YEe++I/AKQwqGlvTEdAswnfll/XBP4o9BP6Zf6DCLJdoJ1Wokrnlg5BWJ0d ZSGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780908022; x=1781512822; 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=71/5gV60k4yG26aCAIxd/scVyaKUto/kd/wMt0/Zjmg=; b=WKMLbDCUo03YP6vm9calAQBL1b6UV5qGG+KaHu/8TYRRq1Q3q4YHKCXTf1ZWdgthMV 7lTBRNWBapyf87BY5L+LbPAQem1fS+0SwX2QOiv8UE/wc3v3UC4anOXV0KiYwoVuw0Ge OszOoPS69XBdvKxqn+8opEoYgFCcFmDGRqXZhUPDBT7EkNmZcBKPKJlataIBKNEOuO24 fhKINO6rrP4AYeauQ6cPpPeD8HkBhw+q3dCG8bXpWXiwVOPqyNRibMNyA+UYFycXe6mb bSafjSO9CRoN9T6Shve07wWCaCDRXRmAPSmQef8qwJguqYmL89vxs9kXsi3mISiz8YS7 PZgw== X-Gm-Message-State: AOJu0YzpkZeTatChUWwFnHQ4fo4Nkgg4xXUNQBw3HnCRq9jxdNP8Id/2 3tDRVjqpYLWY0cSrQnerVSsGG2ij+KWjb6hlQ6FMsid/HF0hARZ0H2NQ6ba6HteTppVPmTABezp oJgk2H8c9QirJi3r9SUaUxa7htj1DbwAuaF2n0HCX2UwjST602HoHrSgoGPjpZzRCjy2b8D6UrO TldsotB2nGHmB6bgrWwOSEQ7oWes1crOaykgQVwXkqBCw= X-Gm-Gg: Acq92OH3AkaewiEHN/Y+jk7pHKJoR8OLpVk61uZXoMvIlOoWwGpEkHIzlBoODedZRAr n4iYwrHFKAHVrdWGfmsLDMAiOLCW4Fshb48Jb+VROES4DqQfuDmi2nOxwxXgluOYMhlE4fqSK4O v3MFws+i/NurIXxDS+3Bl+o+QDZ/NVWHDnSFsr5yasnQVWi7eVc+sXNiZn+xEDbZuc/sFjdvWrg 654Zod1gHUfDqyQBgpaVIvEdB9Xb9DKHMLimZA7zE5vnvxudsOmTaPVUNzRBsT2x5UOr+7h5VFL 8FQb3DGlUSimkbRiNqXN4VPadrr0TKlQ4WicU0IYrvLYRg7uyHpVN5MC/ALQSwp2zWzMjCBn7nn o1z0iRsj+vEYcGLJiXtz5sdA= X-Received: by 2002:adf:ec0f:0:b0:45e:db3b:921d with SMTP id ffacd0b85a97d-460307563f0mr16344601f8f.31.1780908022260; Mon, 08 Jun 2026 01:40:22 -0700 (PDT) X-Received: by 2002:adf:ec0f:0:b0:45e:db3b:921d with SMTP id ffacd0b85a97d-460307563f0mr16344502f8f.31.1780908021651; Mon, 08 Jun 2026 01:40:21 -0700 (PDT) Received: from redhat.com ([31.152.37.159]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm39846375f8f.14.2026.06.08.01.40.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 01:40:21 -0700 (PDT) Date: Mon, 8 Jun 2026 04:40:14 -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 v10 33/37] mm: page_reporting: add flush parameter with page budget 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.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent Add a write-only module parameter 'flush' that triggers immediate page reporting. The value specifies a page budget: at least this many pages (at page_reporting_order) will be reported, or all unreported pages if fewer remain. The actual number reported may exceed the budget since each reporting pass processes a full cycle across all zones. This is helpful when there is a lot of memory freed quickly, and a single cycle may not process all free pages due to internal budget limits. echo 512 > /sys/module/page_reporting/parameters/flush Note: the set callback runs under kernel param_lock, so writing this parameter blocks other built-in parameter writes until the flush loop completes. This is acceptable for a privileged debug/test parameter. Note: flush_delayed_work is called twice (once before the main loop, once after). The first call ensures any pending work completes before we submit new budget. The race with __page_reporting_request is benign: if a concurrent request arrives between our flushes, it queues new delayed work that will run on its own schedule. Signed-off-by: Michael S. Tsirkin Assisted-by: Claude:claude-opus-4-6 Assisted-by: cursor-agent:GPT-5.4-xhigh --- mm/page_reporting.c | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/mm/page_reporting.c b/mm/page_reporting.c index 9c39448e758b..400150a2aa15 100644 --- a/mm/page_reporting.c +++ b/mm/page_reporting.c @@ -358,6 +358,60 @@ static void page_reporting_process(struct work_struct *work) static DEFINE_MUTEX(page_reporting_mutex); DEFINE_STATIC_KEY_FALSE(page_reporting_enabled); +static int page_reporting_flush_set(const char *val, + const struct kernel_param *kp) +{ + struct page_reporting_dev_info *prdev; + unsigned int budget; + int err; + + err = kstrtouint(val, 0, &budget); + if (err) + return err; + if (!budget) + return 0; + + mutex_lock(&page_reporting_mutex); + prdev = rcu_dereference_protected(pr_dev_info, + lockdep_is_held(&page_reporting_mutex)); + if (prdev) { + unsigned int reported; + bool interrupted = false; + + for (reported = 0; reported < budget; + reported += min(prdev->capacity, budget - reported)) { + /* + * First flush completes any previously scheduled + * reporting work. Then request a new reporting + * cycle and flush again to execute it. + */ + flush_delayed_work(&prdev->work); + __page_reporting_request(prdev); + flush_delayed_work(&prdev->work); + if (atomic_read(&prdev->state) == PAGE_REPORTING_IDLE) + break; + if (signal_pending(current)) { + interrupted = true; + break; + } + } + if (interrupted) { + mutex_unlock(&page_reporting_mutex); + return -EINTR; + } + } + mutex_unlock(&page_reporting_mutex); + return 0; +} + +static const struct kernel_param_ops flush_ops = { + .set = page_reporting_flush_set, + .get = param_get_uint, +}; +static unsigned int page_reporting_flush; +module_param_cb(flush, &flush_ops, &page_reporting_flush, 0200); +MODULE_PARM_DESC(flush, "Report at least N pages at page_reporting_order, or until all reported"); + int page_reporting_register(struct page_reporting_dev_info *prdev) { int err = 0; -- MST