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 871673C3459 for ; Wed, 20 May 2026 22:23:06 +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=1779315787; cv=none; b=HH9EdwTDkgymoDfcMpG7KkVEn4uC8jSUhjrm6LXshyan1PjCGp/5du/oNjDG0mpnRAw3/AQU5KeDX0yelN5jTykq3NdRFrJ9Dzc0Iaw/upPsLo5xM3flG8jm1AVxfa20st276I/1LutyeXoipVLx9aYOhI/FQQvCMeGcn2F9n9Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779315787; c=relaxed/simple; bh=flUZ+cOTUcPYfWzZ31XAct9k/k2k4jVzLXPQVMmAbwo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tttv/VTIfE8MkIE3qmMZlywtvWkVX3Wr3L0o5lq9KZsMH3Y8V29ZNCN8ylpqHIhCVdnqvJHFl1Wt0A84+gHLEA4PLVkaQJ+7nPOfvxAiDOuqCnWZBsAY0iEXZpMiXOP+OPXXW88m4QpiZJgCz1JONJtw3T1H38lJ4kNWG/kZHak= 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=dcck6qxZ; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=TkNIUBbs; 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="dcck6qxZ"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="TkNIUBbs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779315785; 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=uUKKOK0OmR1aDSnh65Nr9KPiL6ZvxY2ICpkCGdvKy4Q=; b=dcck6qxZmAGcANwTowxz3lo0FaT21luv0324uIfQodWOMv0R409hVp8FqxxxVahJkXrKGD gi7+rZPkIP1iLRyMVM/kxBCWG67u6rPugOFOILloUmVFJrnGbkpMXRfayWxZpW/N6uZIpL AyMN6ge5SG3tmNEDPJnf9IUawnJ2D4s= 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-651-13KqapE8NoaMa5SYPsQOFg-1; Wed, 20 May 2026 18:23:04 -0400 X-MC-Unique: 13KqapE8NoaMa5SYPsQOFg-1 X-Mimecast-MFC-AGG-ID: 13KqapE8NoaMa5SYPsQOFg_1779315783 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-48fdca5c638so39671635e9.1 for ; Wed, 20 May 2026 15:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1779315783; x=1779920583; 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=uUKKOK0OmR1aDSnh65Nr9KPiL6ZvxY2ICpkCGdvKy4Q=; b=TkNIUBbs2pL7HBi471mklKw1DXqzeU2tTHvFEsANl1pn9mnlvNWn4xOYP7RJU0tjNw 9T6LzEP+OwEEi3RhCFe4jmSwo6vgbjizDEl9OWJHghx6YViKfJhxRpZLz0UgP55Bcj9Q DPZvLCSH0/7QyeKSygINO7KQqS4wQOj2dCCw1dzBtFEiw3KGt/OFc0zHV6QADUQTGP75 4jjCjrBjQFy1vXUsYYBTvWhie+FsWK7SOqu8JE2uexhXCavVn6vG8e86O78M7RcNlvcj D8fyVt2+LR7mo1rFT/4+UtpieYLjMogD8Ngd6S6b1Hu2YCcylbDuRCJx83FSN45mcmr3 plOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779315783; x=1779920583; 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=uUKKOK0OmR1aDSnh65Nr9KPiL6ZvxY2ICpkCGdvKy4Q=; b=oTKyL+PWdN0Z1ER1DwPFAmJV85t9IfxpiwiWcfYRcxx7tE6KwgklULr5yBlIpf09pb 0ZCTg2gmuiekrQ0jiDnyE6UdGBWUbgG5VZEVl/+izV4XCKVisLWvZnKL1pf4G44fWF/A J39kriponQRW5TvAhCROxPPeJefOpy94GNJEZZ9oZmR63I4HD+bZVMQ61ZUEIPGFzZf2 4Av53NbXwMXW/G0jMtKWiJpCGEGXnc+kzO7rYpR0MPkCS1gaeOBLyq0ODJTDFt0qIkQC Xv03QXNcXxgj2a+wH5vqwlHfHdxwftd/t0TiE2NIA6harJLlio8sjVreJsvggGDU5iST tWDA== X-Gm-Message-State: AOJu0Yz3fFbrGJzKbQGYd7/GJ/ugJGKStDzJat38n3FHoKmnNc8yXfz1 b63Y4mUafqCJCQyGsBuuddeKKe26yDqzWV+5qCeE4kNux8ijduXDciX/WqU9ztNb+S6R8gdWL6g hQd5NyhXoEi/c11RdgNwFZ2luEzgOjmVjRIin2uIyhPsD7BzGbDtfxIXxIr6fGZFL/5e27jUe0O KB9ocFm+Jn1tTo497ABXdbOjiVxYeEn3Q5G652n2ZsR3M= X-Gm-Gg: Acq92OGVuu/q6fqRJTaDGnUfxbKVSw4Knr1uPm+Fctd+vAu3eeTMsoIBdr0PmsV2kBX ypcIcnhm8/QEIc0kP2Mxo/B5kth9sMCUdR2e6MdTBg2jHW/NMvQ2XTbY2ahC4R7O4ihAl9B2r7Z xm9M+X5mEjzp5U02Ob7RZi0OQGl/CaVDOiBE8pFfk/iT2K8/wuqRtcvQztStYv7rlX/GSq6UZTz tJh/5/bZrdNYaMDOZd7c1O3d3EC0pUrr9Tzhndg5/RiCqKEG+TUv7+TWnC4QJdPlzyanujgT5gT nUkYL1Rz4cxZtsr0+wU9G6moOsyZuPXi+Q97b9oZtECH/v+dJ6MRswO6dvQdhtBLU5FAgQHEAho yNfAUCiAH3FxUb2bNB6oYbosBk3VKAfid/qNBObxukto= X-Received: by 2002:a05:600c:31a9:b0:48f:e6de:1cba with SMTP id 5b1f17b1804b1-49036089574mr1979165e9.17.1779315783076; Wed, 20 May 2026 15:23:03 -0700 (PDT) X-Received: by 2002:a05:600c:31a9:b0:48f:e6de:1cba with SMTP id 5b1f17b1804b1-49036089574mr1978505e9.17.1779315782397; Wed, 20 May 2026 15:23:02 -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 5b1f17b1804b1-49033d3e9cbsm16828155e9.4.2026.05.20.15.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 15:23:01 -0700 (PDT) Date: Wed, 20 May 2026 18:22:57 -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 29/37] mm: page_reporting: add flush parameter with page budget Message-ID: <842171d4147bb97a96b87386772a4ee2f058fabe.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 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. 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 691a9e66aa5b..8b278a494ea5 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