From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E61A3A6EE9 for ; Thu, 6 Aug 2026 01:11:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.70 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785978671; cv=none; b=O4iaexJVHIwzo3Rtk8z+zyuittlVofOs4QlDQFST5T7SYLUfzYl1jnMTrqfqjxt4gYGDdqzaPr6qBWW00bb5xUeEyz+3o6TUPZsPUKXENTreNHVwrRci5OX0VkxgdwOCBj1F0IitV2hwpvvwDuTjiUYqoUVNQZymbjmwP//SEEs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785978671; c=relaxed/simple; bh=Vy8A71qsL16PzVXck8lTWsRtkfvzZQTzE7M1TN7synE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=LOcs0XM68j5fl1uYEeng4KDoJOKpWbiDjGLwKEpWcGB9nLn80sgtBSjuY/0mOdM/QSr3o3PDC/OyGDV/RqZXkAM2F0UvcGSIGMgK4i80i/hrPrvYboLxQbHGugggYLhI/xJSkYdzRjrSAzrvfFiBdNzkv0J+JZoJRN8rX3j+1Co= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jyescas.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=FdJLPBvx; arc=none smtp.client-ip=209.85.216.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jyescas.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FdJLPBvx" Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-38ea32e57e2so2756501a91.1 for ; Wed, 05 Aug 2026 18:11:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785978670; x=1786583470; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4V9Y8fDSG8MVV4W0n0bDz/rhN/ammIKgNJCb1TELSuA=; b=FdJLPBvxFvQ2Ws1YHVfGmvqjbT7jizf30osItQP+qRkbo92ySpu7YnXr2LFvWKyMZ/ RIPqPNGKo/6oPH6+T6jer1qB6sudTIrFh7nZM7JnxomhJdenKfFeLCK0mdLlWHe+6YYg 5t33qe7guGiYGfphkAN8FYgGkrhaCSQBq5l241w9QJ+FIPZv2sjtoC+Vih48pBxLoIth tlsoulx0GvU2XvsaiFjCsLT6FA9dzY4LSp5l/DkBgEcUzT9oUa6CWKX/ETNq4d0Cs5x5 eENVcvOKQ/HT2HM6pQfBH0t/DBrz6B5Y1GjrBjnL8jXqAxYtJ6JzoP8bTITbWxpVv8fQ RTAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785978670; x=1786583470; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4V9Y8fDSG8MVV4W0n0bDz/rhN/ammIKgNJCb1TELSuA=; b=DkSD3x5HngubXiiGjMAmCK0j0xddqLjAaaSb70oDJPWwGwQH4IjdHS66r+OgqOGFiv HcTfBYvYthbPr+O4fKm8ta80eAhsTYzcNBe0LD1iDFiZYRMkFCuoUyVVbeDRqzR7GdMS tOCEx7BiwWoE4WXo9DvP4idQIqSXo/sjpfDIMNuEa+K1ykicRbC3WPAFTQvLk3A68Kgx yID/sx0TmP6hD+umK6FtyVHCd1tRnx5P1gAnY7DiblXBlXlrgv/WKbeC7YHMbC1qtaux kqAozcXWxXF29K2H0NubO9eBrBu1ev0p213rB2FIya5zPgLm/aPgT881bH3ihfXvrmTV ZF5Q== X-Forwarded-Encrypted: i=1; AHgh+RqRX//0q1AWVLNi7AACswWYsynVNgmD6k57O5fQGj+K7nhN5fZ05cMM9bJsY/3wF9dVel6pl04ffzJfhZk=@vger.kernel.org X-Gm-Message-State: AOJu0YwDqGE+gLbNNlrszeFlDQzDqhiLZqkHsrErf4HFKjrqXM8xT1Vr 8XrijB+1XmSmdckQvCLZyeGJOHPXoKAq6I1/UqZL5RRPddiB1q9QzyL/6r+Zf081Y3ueQgOnTfT hIlaTV//EjQ== X-Received: from dly27-n2.prod.google.com ([2002:a05:701b:205b:20b0:13d:1da6:85cf]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4d84:b0:381:5bd6:eb19 with SMTP id 98e67ed59e1d1-3903c5dfd9amr10541054a91.18.1785978669221; Wed, 05 Aug 2026 18:11:09 -0700 (PDT) Date: Wed, 5 Aug 2026 18:09:02 -0700 In-Reply-To: <20260806011048.517229-1-jyescas@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260806011048.517229-1-jyescas@google.com> X-Mailer: git-send-email 2.55.0.629.g250fe7f194-goog Message-ID: <20260806011048.517229-2-jyescas@google.com> Subject: [RFC PATCH v2 01/16] mm: Page Alloc Hogger module From: Juan Yescas To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , open list , "open list:MEMORY MANAGEMENT - CORE" Cc: jyescas@google.com, android-mm@google.com, ljs@kernel.org, fvdl@google.com, tkjos@google.com, minchan@google.com, dskiba@google.com, open list , "open list:MEMORY MANAGEMENT - CORE" Content-Type: text/plain; charset="UTF-8" This patch contains the skeleton for the Page Alloc Hogger. It creates the "mm" dir that will be the base directory that will contain the "free" file and the "node-" dirs. Signed-off-by: Juan Yescas --- Changes in v2: - Change to a tristate module. - Fix typos - Use static for the mmdir declaration. mm/Kconfig.debug | 12 +++++ mm/Makefile | 1 + mm/page_alloc_hogger.c | 115 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 mm/page_alloc_hogger.c diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug index 7638d75b27db..bad8a606152c 100644 --- a/mm/Kconfig.debug +++ b/mm/Kconfig.debug @@ -309,3 +309,15 @@ config PER_VMA_LOCK_STATS overhead in the page fault path. If in doubt, say N. + +config PAGEALLOC_HOGGER + tristate "Alloc pages from different nodes, zones, migrate types and orders" + depends on DEBUG_FS + help + Say Y to alloc pages from different nodes, zones, migrate type and + orders using the debug fs filesystem. This helps to generate memory + pressure easily. This is useful to debug memory reclaims issues, + OOM triggers, page migration issues, etc. + + If in doubt, say N. + diff --git a/mm/Makefile b/mm/Makefile index 2d0570a16e5b..b48f2ac6ee80 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -133,6 +133,7 @@ obj-$(CONFIG_IDLE_PAGE_TRACKING) += page_idle.o obj-$(CONFIG_DEBUG_PAGEALLOC) += debug_page_alloc.o obj-$(CONFIG_DEBUG_PAGE_REF) += debug_page_ref.o obj-$(CONFIG_DAMON) += damon/ +obj-$(CONFIG_PAGEALLOC_HOGGER) += page_alloc_hogger.o obj-$(CONFIG_HARDENED_USERCOPY) += usercopy.o obj-$(CONFIG_PERCPU_STATS) += percpu-stats.o obj-$(CONFIG_ZONE_DEVICE) += memremap.o diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c new file mode 100644 index 000000000000..1d31e981920e --- /dev/null +++ b/mm/page_alloc_hogger.c @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Page allocator DebugFS Interface + * Author: Juan Yescas + * + * This module allows to make page allocs per node, zone, migrate type + * and order using the DebugFS filesystem. + * + * When this module is installed and the debugfs is mounted, the "mm" directory + * will be created in /mm" directory. Under this directory, + * there will be subdirs to select the nodes, zones, orders and migrate type. + * + * For example: + * + * /sys/kernel/debug/mm/ + * |-- free + * `-- node-0 + * |-- zone-DMA + * | |-- order-0 + * | | |-- migrate-HighAtomic + * | | | `-- nr_pages_allocs + * | | |-- migrate-Movable + * | | | `-- nr_pages_allocs + * | | |-- migrate-Reclaimable + * | | | `-- nr_pages_allocs + * | | `-- migrate-Unmovable + * | | `-- nr_pages_allocs + * | |-- ... + * | | + * | `-- order-9 + * | |-- migrate-HighAtomic + * | | `-- nr_pages_allocs + * | |-- migrate-Movable + * | | `-- nr_pages_allocs + * | |-- migrate-Reclaimable + * | | `-- nr_pages_allocs + * | `-- migrate-Unmovable + * | `-- nr_pages_allocs + * `-- zone-Normal + * |-- order-0 + * | |-- migrate-HighAtomic + * | | `-- nr_pages_allocs + * | |-- migrate-Movable + * | | `-- nr_pages_allocs + * | |-- migrate-Reclaimable + * | | `-- nr_pages_allocs + * | `-- migrate-Unmovable + * | `-- nr_pages_allocs + * |-- .... + * | + * `-- order-9 + * |-- migrate-HighAtomic + * | `-- nr_pages_allocs + * |-- migrate-Movable + * | `-- nr_pages_allocs + * |-- migrate-Reclaimable + * | `-- nr_pages_allocs + * `-- migrate-Unmovable + * `-- nr_pages_allocs + * + * Usage: + * + * 1. To trigger the allocation, navigate to the debugfs path corresponding + * to your target node, memory zone, allocation order, and migration type, + * then write the requested allocation count to nr_pages_allocs. + * + * For example, to make 3 allocs of order 9, Migrate Type Movable, + * Zone Normal and Node 0, run: + * + * $ echo 3 > /sys/kernel/debug/mm/node-0/zone-Normal/order-9/migrate-Movable/nr_pages_allocs + * + * 2. For each allocation created, a corresponding file named sequentially + * (1, 2, n) will appear in that directory. + * + * $ ls /sys/kernel/debug/mm/node-0/zone-Normal/order-9/migrate-Movable/ + * 1 2 3 nr_pages_allocs + * + * 3. To free the allocation, write the allocation file name in /sys/kernel/debug/mm/free. + * For example, to release the 2nd allocation run: + * + * $ echo 2 > /sys/kernel/debug/mm/free + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include + +static struct dentry *mmdir; + +static int __init page_alloc_hogger_debugfs_init(void) +{ + mmdir = debugfs_create_dir("mm", NULL); + if (IS_ERR(mmdir)) { + pr_err("Unable to create mm directory\n"); + return PTR_ERR(mmdir); + } + + return 0; +} + +static void __exit page_alloc_hogger_debugfs_exit(void) +{ + debugfs_remove_recursive(mmdir); +} + +module_init(page_alloc_hogger_debugfs_init); +module_exit(page_alloc_hogger_debugfs_exit); + +MODULE_AUTHOR("Juan Yescas"); +MODULE_DESCRIPTION("Module to alloc pages to generate memory pressure"); +MODULE_LICENSE("GPL"); -- 2.55.0.629.g250fe7f194-goog