From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (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 2AE4E3ED10F for ; Thu, 23 Jul 2026 07:49:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784792946; cv=none; b=YT8wl1kSxWt0wcWOTJiaAU6ElCRTWQriWCilTO4MX5leOn7pz3IfgQfdhFqXemcbnmnEmivkhpGWAY/2HGSAhTx2+zxdTe/BxsgO1ud9ZuiLqAqOnHPtZzAav3AJm6cEfJG/diQCWFiY3EA4+MOGY4wXOlzxrJWO6v1sI9SdqNc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784792946; c=relaxed/simple; bh=+y5EPVQy7hFgUeMswJkFhfZHv4MZYlVJY2+t/kECWBU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ftkEMeJZYk1Q/5J1Ty2bs5lPVKN36ZtP/Eg+X8mIrUX0T4vJJPqNyNWBsNDuqioqbbLScoxKTOkcUYKnDvq5w1iRooHpTL45uArbM8k8nUt/aAgzls5rc98ttARekgFXXBhKBeRMGUUpFyFh+uh0epPEQj40GlJPzTw9Wi7488c= 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=Htf/pjZA; arc=none smtp.client-ip=209.85.214.200 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="Htf/pjZA" Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2ccb6f6a3f4so3254435ad.1 for ; Thu, 23 Jul 2026 00:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784792944; x=1785397744; 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=6yaa4cCuGB/KMi/unBxDmfPea8S92ERyZzt4MyrotbI=; b=Htf/pjZAMAk92i0TWGf8LAYoY0cuoOybh4VW5fNyL9EUfxkP+Kvr9BlZF/GRVeBYLo /WFlTelVowbbc9M0MPM2ElAivQ0ARiFm41PdyBa8LlmXrC/yoyTu+V4KC1bGupVZwKX8 SjV53EHom2iqE/u1yOx3pG6R/md+gBoAdhWEWK2yDmSrnIh3bbYnH8Wqsl8+QGXI1sUi wSygxGAicxYGZ8O134BhWtadz6GLH5zbZ3NUKKMBUemG0BYk19hwN25Kq9ROjJmHpVyr 3B9HlfOYdTfahQk5gV6nloPzBXtTePuuA5n5Wp89FxlTFPyAOKqNAFSeWMt9i0FE06FB UHyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784792944; x=1785397744; 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=6yaa4cCuGB/KMi/unBxDmfPea8S92ERyZzt4MyrotbI=; b=DTTlTp4Y9Px+7pxpaYrjJOq+qY5QRP1vWYqOpchHFjIOxk05guK+VWU3tt491B/uU0 22I4uDrlpzXwT/6AHpkQxXyILdSj+358UQE5/N9nwyi7hwWgQukbIk3w3pI9YY3KcwId r+2TmBGdO7UWto38i65P0Dq9dYfun839NCnwvBIONMw/5AsCTkAmPGHvENcgRhEebOn4 XlS1AE0UFPzFWsy39BrJtBwEQ1Ma7OQyAxEGVPvWuJC34zO9Pre6q3cBh03EminckPnZ ueASjWRLD1C65DrhZd901EAsvgfkBC4LCFnWRMqTYROH041zxNmgJwSg8oZE291hOhp/ jn6w== X-Forwarded-Encrypted: i=1; AHgh+Rr+UyLnfp/Eysz3xfr9bGh3uLiOxXIrpB0gyOTaaQQtEeQS8l04yt/+JNlsEfWMpTLN3JgqNpajB3sZI6M=@vger.kernel.org X-Gm-Message-State: AOJu0Yyv/+mXsKbfSZw53NlDZcisCXGVEwGxs1QhWoZMa842Pf71y29d V5C80hAYa7z4OB1Bj5t4oTxhigZ8H+QZ9JsBO8b9mPITCIYb3Rht4bhzkDo3qJva37AVX3kSqEm QWu9z+JrAXg== X-Received: from dybnw12.prod.google.com ([2002:a05:7300:e70c:b0:311:5a71:d53c]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ef04:b0:2cf:b23a:3e68 with SMTP id d9443c01a7336-2cfb23a415bmr503015ad.25.1784792944076; Thu, 23 Jul 2026 00:49:04 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:05 -0700 In-Reply-To: <20260723074854.1013941-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: <20260723074854.1013941-1-jyescas@google.com> X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog Message-ID: <20260723074854.1013941-2-jyescas@google.com> Subject: [RFC PATCH 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, 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 Pagei 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 --- 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..c8fcecdca6ac 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 + bool "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..dfdc2ee2eafe --- /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 + +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"); + 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.229.g6434b31f56-goog