From nobody Fri Jul 24 21:52:56 2026 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-Transfer-Encoding: quoted-printable 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. =20 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) +=3D page_idle.o obj-$(CONFIG_DEBUG_PAGEALLOC) +=3D debug_page_alloc.o obj-$(CONFIG_DEBUG_PAGE_REF) +=3D debug_page_ref.o obj-$(CONFIG_DAMON) +=3D damon/ +obj-$(CONFIG_PAGEALLOC_HOGGER) +=3D page_alloc_hogger.o obj-$(CONFIG_HARDENED_USERCOPY) +=3D usercopy.o obj-$(CONFIG_PERCPU_STATS) +=3D percpu-stats.o obj-$(CONFIG_ZONE_DEVICE) +=3D 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" dire= ctory + " will be created in /mm" directory. Under this dire= ctory, + * there will be subdirs to select the nodes, zones, orders and migrate ty= pe. + * + * 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 ty= pe, + * 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-M= ovable/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/kerne= l/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 =3D 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"); --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 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 4D0423EEAE1 for ; Thu, 23 Jul 2026 07:49:35 +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=1784792977; cv=none; b=R1ToyHPYmqI+dxkvyw/KAKvmfZr0oV3idZmyPQdn/Wa9Zf+OdwU7i43refYdgjOc5WppKd4U1b7q5Nrl6mzyYtlsz+ezbZVjNKvJFBaBZaQgEEpiXo2TYPzUDeyedj9pGk7rBtFjXinNFR66OaGDv9nEPO1FL+x5hc3rTvcOqC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784792977; c=relaxed/simple; bh=cdll2SLRPsK8E8O2KPpha4m5jLkkhgIS39RCDPacR+4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=YcVvB8lhfZA2E3fwkw7WbaERqkpzdQetNyX2c0oVErzRQztT4VilzBaazN3wZfI2Tu6DsbDLcRCn8J6/3D7QuwoqOI1+ez5g/jKCI6g5W+pNCNV7ndCX70d75w5zFmvwYnR3unWn5hlJFGxZt3QY2fsgnlZe2YJllZO6DggiZtY= 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=HQYoAXu9; 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="HQYoAXu9" Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-385d2703b64so245627a91.1 for ; Thu, 23 Jul 2026 00:49:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784792975; x=1785397775; 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=QZ586ewl8Eu4hmRzC2pHlsJckKHztM0Smyid7ZkeCg4=; b=HQYoAXu9NVk2R6zKj2z4YlA1EwLdaJIUFp7q5sSkt+2UiwGEJBfAOIDhLC1Daa13iy OAt3CDP+a0SEzhJaOOsMG4DU0XBpfZ69E/nWEkoBXhd9JqKpZPOOCZtiFG+AOHHAf9PD 7uE3xevJ6NnBLaSKdvnzvJtnbbzF/z1krbzK04B2brU8y6wz7TVh4sJ7ndPrktzzlPd5 2d/O052jU8iLHSfs3PQhGFTsijNk4A95hIAbYXgXU9YpY39IZggFFqgGPrV5s+l/Zlpf x9OXuLSRQZKPd4OSRLEtasMAxy3GDHaT2sWipUvtwYm3E8zGlCjFuF56cidRj2HUvsoc uNmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784792975; x=1785397775; 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=QZ586ewl8Eu4hmRzC2pHlsJckKHztM0Smyid7ZkeCg4=; b=HSJyi5gg8eOjZbY4uRh+PaKSUxMosFFzsbip4YmBMi0Th2WyV5ZRxNarjvigsMJXwy 79R0MbfS+D5gq2nGdAJLxEHswIt2BbBnHOjUplTfObveeR/wgLU27cax0HKdzWcRHhau RyFXNewDHCdo16hnq/e8rNmbgMnDtSwkXdTgJ+ANJdk4qjrHRGeYTS9QTNP1isNa37SP k/+jcCdFwcplgTNBqRzYn5Vu2wvl+axgEJ16KO+WoN7QTzF/3daS63iEWcCH/5dwiuWx kx1aA2sJY9kX7cSGwfZkebz5bX3pqnpxfieixT+y6HCg0jCL49RhD4wjmivUwf4Mx5pC Uk3Q== X-Forwarded-Encrypted: i=1; AHgh+RrEfuxYunbNJiOj08wrGWGXtQHzCdIgDknnF0WqbCQkpo4d4PIouYPJtv+qniVoX/DaAHgVxT01U2c+vaI=@vger.kernel.org X-Gm-Message-State: AOJu0YzTPat02qNMFpr+A3MGh/INuRIJ7vuLPUFGRGa+ercrf08lvHPJ j1coPlgpToOP1C59aW6ksSMkS/xRGEUWelxJvMs4wU7VbZdRABwWcubU4AL6jzMHPerzLL2MOOG No+XX5hfNow== X-Received: from dlec17-n2.prod.google.com ([2002:a05:701b:4291:20b0:13d:1fe2:b775]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2b43:b0:38e:9784:dd47 with SMTP id 98e67ed59e1d1-38ec83975aemr1731583a91.1.1784792974394; Thu, 23 Jul 2026 00:49:34 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:06 -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-3-jyescas@google.com> Subject: [RFC PATCH 02/16] mm: Define structs for allocation requests and store allocations 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This change introduces the next structs: - struct req_alloc to keep the request info for the allocation. - struct page_alloc to store a pointer to the page that was allocated, the request info and the file that represents this allocation. This file will be used to free the allocation when it is not longer needed. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index dfdc2ee2eafe..47b08d056978 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -91,6 +91,34 @@ =20 struct dentry *mmdir; =20 +/** + * struct req_alloc - Represents the requested allocation + * @node_idx: The Node index to allocate from. + * @zone_idx: The Zone index to allocate from. + * @order: The Order of pages to allocate. + * @migrate_type: The Migrate type to allocate from. + * @parentdir: The parent dir where the file representing the alloc was cr= eated. + */ +struct req_alloc { + int node_idx; + int zone_idx; + int order; + int migrate_type; + struct dentry *parentdir; +}; + +/* + * struct page_alloc - Represents the page allocation. + * @page: The pointer to the page(s) allocated. + * @req_alloc: The details of the allocation. + * @alloc_dentry: The pointer to the file that represents the allocation. + */ +struct page_alloc { + struct page *page; + struct req_alloc *req_alloc; + struct dentry *alloc_dentry; +}; + static int __init page_alloc_hogger_debugfs_init(void) { mmdir =3D debugfs_create_dir("mm", NULL); --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (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 D53023EEAE1 for ; Thu, 23 Jul 2026 07:49:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.69 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784792984; cv=none; b=k2AETcRlp5IGpH6xXDISK4w7JPnc14KSH0Z9yk3hkvW7DqJKWFDGP1XYQongOUVGPEVNYVnqs/JFb0LxnLtu1KvRNxyyI4vBKeaZSwuWfpZsiCz512zMNAi2wppcKsoW9gkLvny0JGN9vegWWkrpSDdCabHYTcyxd7oio9r93PI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784792984; c=relaxed/simple; bh=JsDP+IMAdM/jN3KkQ0s3W7AM3KklJ4G09cqWVsyNfVk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=KRr75mCP8kuWM/LXSRww8WgWjXe0u6AELajJej+0bmQvDnv8NwL5dHTn0x6GjiZjTivv5dwuEi8MceSY7P+pX396V3WCyXqcwQXq1MSbg5hrPIfLKrFv6NCOHNZQ14bCi0Ta44dI0uEQNACzY8HlXtSwIr4p5mSlfIbjzMG2S6M= 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=fPCKf02X; arc=none smtp.client-ip=209.85.216.69 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="fPCKf02X" Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-381250979d5so470132a91.0 for ; Thu, 23 Jul 2026 00:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784792982; x=1785397782; 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=CxFUoK0o7AOxXwUayK1WHtnxjmfT1NGEks3Fz4KRfjY=; b=fPCKf02Xd7wQSwUINlTKp7ditUkHom9PDbRuJp/aEbVD8ULygXS5DvVHbVznOUj/L+ SigCgJtPQnGnfSA5IYJa1uYNXT/v7SW8qiF6dW5s9theavyoZUPmGaU/qRy586BoITh5 tGgtoiw9/pyKpVEoT7HV11ckk/fwty7zftWZOhkVDbi74L/lPE4kmWa7QAq9mQS+/4ax gnTMS4idI+cqUXzxshpmxLI6UY+axtnX9wP6ScZ66L88J9BBAktRHJnfeneh2Ph4wJf8 0YtDS2DCgJJUEYGcNXl0O3uW/wAyPoA6Q4BPsmh6c8mIpHR6XyyWm9Fb20X3bmJALZpI zQNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784792982; x=1785397782; 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=CxFUoK0o7AOxXwUayK1WHtnxjmfT1NGEks3Fz4KRfjY=; b=G9ZHNG11eocXhwL6hbt45vOTOVaUQ1XhQm3U4Eap+kigm9Hg220bn1dVtbM0Up9lGS Hb1MDo+gNtvLAO6d2xYyu0j63AE6tP8XbuyQArAVVX5C+EHRdO0P6kRZRAjCmw1Ml+ee FAUaMyRqX+1uQAhuftTvOyzpcVT+ueLfhxorXoD3bz1jPBkUB8KRH+NDJIJMe/hfyAWp ngjjAR9WJgCB7e0ajwoWwJkEi/E+cIL8CVmMHwEZvB9cLQPFEm1KO6E6/lH/XlRzMtWr DkHM52Y3JRuyGlGaoYMywQKaraJNJBdCLW17PZFhheIAlzjqdNZ+lCF+ojJCnQxisKje ajSw== X-Forwarded-Encrypted: i=1; AHgh+Rp43LGW6qaZPrpWwCm2BK8iSLaehXqUy9lHkec5WsyNA05Iu/vDvG0POefwinfqefofR/wBdDwxmLIe5vQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxNkUZnOFEj9TdyDAjxWvut/xjTGR346ctdjox4TrD2e1FvB8En h6yZb2YDf9XJ15ZeXugz/Nm1eESNpY6UXwZXt/mODKiJEipa9UfywRtmgXaMFGZVJsbl3V1O3gu 5MKcXMHUgog== X-Received: from dldyr4-n2.prod.google.com ([2002:a05:701b:4504:20b0:13b:882c:fd28]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4c12:b0:387:e0db:bc34 with SMTP id 98e67ed59e1d1-38ec688a747mr1713501a91.42.1784792981876; Thu, 23 Jul 2026 00:49:41 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:07 -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-4-jyescas@google.com> Subject: [RFC PATCH 03/16] mm: Define the caches for the structs req_alloc and page_alloc 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This change defines and initializes the caches for the structs req_alloc and page_alloc. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index 47b08d056978..52ccc6e99eb5 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -85,9 +85,12 @@ =20 #include #include +#include +#include #include #include #include +#include =20 struct dentry *mmdir; =20 @@ -119,20 +122,55 @@ struct page_alloc { struct dentry *alloc_dentry; }; =20 +struct kmem_cache *req_alloc_cache; +struct kmem_cache *page_alloc_cache; + static int __init page_alloc_hogger_debugfs_init(void) { + int ret; + + req_alloc_cache =3D kmem_cache_create( + "req_alloc_cache", sizeof(struct req_alloc), 0, + SLAB_HWCACHE_ALIGN, NULL); + if (!req_alloc_cache) { + pr_err("The req_alloc_cache couldn't be created"); + ret =3D -ENOMEM; + goto error_exit; + } + + page_alloc_cache =3D kmem_cache_create( + "page_alloc_cache", sizeof(struct page_alloc), 0, + SLAB_HWCACHE_ALIGN, NULL); + if (!page_alloc_cache) { + pr_err("The page_alloc_cache couldn't be created"); + ret =3D -ENOMEM; + goto clean_req_alloc_cache; + } + mmdir =3D debugfs_create_dir("mm", NULL); if (IS_ERR(mmdir)) { pr_err("Unable to create mm directory"); - return PTR_ERR(mmdir); + ret =3D PTR_ERR(mmdir); + goto clean_page_alloc_cache; } =20 return 0; -} =20 + +clean_page_alloc_cache: + kmem_cache_destroy(page_alloc_cache); + +clean_req_alloc_cache: + kmem_cache_destroy(req_alloc_cache); + +error_exit: + return ret; +} static void __exit page_alloc_hogger_debugfs_exit(void) { debugfs_remove_recursive(mmdir); + kmem_cache_destroy(req_alloc_cache); + kmem_cache_destroy(page_alloc_cache); } =20 module_init(page_alloc_hogger_debugfs_init); --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (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 5B1303EE1E5 for ; Thu, 23 Jul 2026 07:49:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784792991; cv=none; b=Gz9HztNQmd+OmTa6XWX0V8fyZ0NORdL/FjE5jw3z+5DMp0XZUT9YvydhbGYbuJODc7ZjczqbA3yDroms6j92JAnLb8AcZ+cFbPUdAb86BT6nuAwIGWU9X7742MfDOmW97tVW6COlXi9I3avZiBS4+OgOwPffOSbhLmbNCrALPbA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784792991; c=relaxed/simple; bh=gPr0cn0JTw05EmZKfqSaDPNjM6FuDTaUXAFggcBHKNo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=rFLPcG41mADv7R3BMNo966iVsiJfXcPLEkZi6DEfSwwEEeJOYWYz3T99JP6SqCHi/dfm3iY3jsSbVN0ZPUpYVfSAwCg8sboHzNQwn/GICddmOpaW24mO6tqOQhnt3DZeYLcgwb9+JYDSVbgh5uxBtL0JnzE093VfPErMji6qm28= 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=c8dKHA84; arc=none smtp.client-ip=209.85.215.199 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="c8dKHA84" Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cb733fc5024so777887a12.2 for ; Thu, 23 Jul 2026 00:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784792990; x=1785397790; 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=loRVgN9ulm8PnZhPf0JyRbFqzx4gb/PePxillDVmero=; b=c8dKHA846y4AwPZ9ZvVK32tmVP97BHkAf8fYUUcnbHNTpx0m6FJmDA1m/qrTXfzh4t /EeB1a22Xg2/ivhNZV9DkuiNwbK6fb4A/cK3PrLmrLqRwWFrBA2D8yyNwyQt7URLpZRE 7lg5iKUzqZzE8QlcM1VcF5OktiOq81hZ5btr+MLX6xCwSAgxCHLARkwR8heMJnJOo1eG /lUsPmCI5Ot2nN2A5JRB6L9lOYw1k1qYVRcw10hi6oBjZH+gPRUoNtgLsvvAVik7tRRI 1PJ9nwKAoGZyL/gfI63NveOF+uLIdalyRgWhkBOzkGPVUDSsVARC7/ReFws9xG409TFt Uzaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784792990; x=1785397790; 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=loRVgN9ulm8PnZhPf0JyRbFqzx4gb/PePxillDVmero=; b=FOMiytmg1HbQuCZkiJynTsRcMuxL+Pf4wZdA5MvXw/9Ho0gdshG3McKISrxgLRvyIx Ry2zZOgSClClyz2KW0GXld/KUuDBbRDYZ4FFIkJ81GprbQhmHh/q+wKOV/GnfjlfbbZ+ akAdy1mXchFV/e3wLJPb27N5uopoyxEDPXBOjxeXdjiVGfe6ih6x5OD7Psr2TwHttw2k HZQGQoI60Cfry0R8EPu3ZXEPPMW7ZJc5LyPOQoFMvjRUKbPdtGHXUbhHG205wb8ur0q+ fBxmDOrX4KxWODRXbWuveFEIzqzYyuvycSaQ58WE8DiE5001/5bvhir+OyPpEXPS78WO lvuw== X-Forwarded-Encrypted: i=1; AHgh+RreV/z+u+Yz4WnGUxVzTJ9LeVhR0drjWEIIpfqQmRHCMKGkwcQqlPkLXW4B4KUPVJiHaPc5CkOZIrZoso4=@vger.kernel.org X-Gm-Message-State: AOJu0YxFZUpvp6RxxjhiVptK3FTjOFuNnzVx7S27kWZHXO+0dBqvyMwi coysUBHvMZstUZ4tDYBUZ+888+0bAskotucoucD93zwKgWv4LHAum8aV1p/rh4MjF+AjerW58k6 AgwEC3BT8gA== X-Received: from dled5-n2.prod.google.com ([2002:a05:701b:42c5:20b0:139:fea6:ad4]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:3994:b0:3c3:bd32:4587 with SMTP id adf61e73a8af0-3c44b1c86bcmr2158597637.44.1784792989393; Thu, 23 Jul 2026 00:49:49 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:08 -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-5-jyescas@google.com> Subject: [RFC PATCH 04/16] mm: Define function to create a dir for each online node 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This change creates a directory for each online node in the system. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index 52ccc6e99eb5..880de1a6e9ea 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -89,6 +89,7 @@ #include #include #include +#include #include #include =20 @@ -125,6 +126,27 @@ struct page_alloc { struct kmem_cache *req_alloc_cache; struct kmem_cache *page_alloc_cache; =20 +/** + * create_nodes_subdirs() - Creates a directory for each online node in the + * system. Once that the node directory is created, it creates a directory= for + * each zone in the node. + */ +static inline int create_nodes_subdirs(struct dentry *mmdir) +{ + struct dentry *nodedir; + int node_idx; + char dirname[12]; + + for_each_online_node(node_idx) { + snprintf(dirname, sizeof(dirname), "node-%d", node_idx); + nodedir =3D debugfs_create_dir(dirname, mmdir); + if (IS_ERR(nodedir)) + return PTR_ERR(nodedir); + } + + return 0; +} + static int __init page_alloc_hogger_debugfs_init(void) { int ret; @@ -154,8 +176,14 @@ static int __init page_alloc_hogger_debugfs_init(void) goto clean_page_alloc_cache; } =20 + ret =3D create_nodes_subdirs(mmdir); + if (ret) + goto clean_dir; + return 0; =20 +clean_dir: + debugfs_remove_recursive(mmdir); =20 clean_page_alloc_cache: kmem_cache_destroy(page_alloc_cache); @@ -166,6 +194,7 @@ static int __init page_alloc_hogger_debugfs_init(void) error_exit: return ret; } + static void __exit page_alloc_hogger_debugfs_exit(void) { debugfs_remove_recursive(mmdir); --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (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 B72EC3EEAD7 for ; Thu, 23 Jul 2026 07:49:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784792999; cv=none; b=KEvxzBrjqATUm488HfSJC7ocmdwHPbT3RVqKRqD4hOG9BJPILaz4zd9XmGygYdVXCot5ZeahLwyMZDcGXKRdcKb67n7sMUbfWFeOyM8Be+OK8xiv4ugpgzY+sZmLsV1UeSl18u+STGC4p4N4pbj6oTVxJLYjbzj8/jrQJmmQkPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784792999; c=relaxed/simple; bh=0SwVKEcKK/mkQ9g52EEyNwIz3tvvQPWAa8AT5fBkS/k=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lQiRrwNKdWtrCVMNYAyKvsExew8rvoSiExRce1YGFxwSHqos/T3DCAFAYKIDANjCQKbDp2Nzfbrj8Ws7S/CO+3xD8j/v6f684JL62OG+ruC4hKeqBQ4pe2WLTE+IP30CfMVKGg4UPKZO+UJ7pbWVkIqlUPyy0MGqDCILuPBz2fo= 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=I5wQSxQm; arc=none smtp.client-ip=209.85.216.72 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="I5wQSxQm" Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-38e7ff7b375so591134a91.1 for ; Thu, 23 Jul 2026 00:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784792997; x=1785397797; 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=mqLzhDVDDZLVR/FPTjNaPDqvXax9+3/sETwGozJ8afI=; b=I5wQSxQmsdm/UrBTamEJN12DsZuQtVZy7O/9sgFthbg+cPK+gZDipkpvT8VhFfaH8j vA4dngyb0qjpi3R5rXTbaQSkT8Mk6uhF3Rm34AkmclynJPLROil+t0TWOC00uINKlLuc MFiQV4q0Cyxdmi2SQWlY3FbS7wtgkk8lHpKcrvJbNXC1Hz/zJTReNXIJWICgEzoj/JUu pCSIoWyvoRVVUvLB3zyLjXlaaRQtaS0oi5OMDNe/e3CsTml/2yVPvv7tNIziPs6k//GX WCZh1l45wmxZJ3334NQevuEBvvnckqh4HdU+boWuqn1ECUWoLRFgQDToY66GDzsOASag N8BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784792997; x=1785397797; 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=mqLzhDVDDZLVR/FPTjNaPDqvXax9+3/sETwGozJ8afI=; b=jQth9bkvoy1rFY/4zeY1X1oUeJ7r+lgM3L3tupWfwSGJEtSvwvWjViM3DOfkL1bQoq CUtJe0dejGEAfDtqM7tvhLEC/5Dw1c6N1sO7x2JoYNxbuQvp5Ow3/rdb2LzUv3imfG0Z c6M6BUGXYUEMMJuTa6GlR3XlQlIGFWjtGXSH/JvznZ9fGH8dliSCjlIeHa06ROc33W08 IGqcCi0N9HjtuKYvpDZOcW/AsI0IgjiEvr20N8tRs13uhpFxqlHTy5+Q4bGc8ITKTbxg ObGteND/UCNTCPCgfzKL0lPPj1/8BtTSxkVuOn/XxkSzdgTEvUqD+wrlGQs8O3u40Eco aONQ== X-Forwarded-Encrypted: i=1; AHgh+Rp3O6kN78uSEwKKcE6EGwAWTQucVfDkzBWiTu+JStyeKxKvkZdouiWF6Ha8tSes8qdisH9x6dHzGPkvGsQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yzzq4VW6oTskLUtgxlV6G8p6jhAV/bk68nGkRI4Na2ujS1e1P/l qnsFgXrsdU1Fhqlavr9aw9Y0w9x9x57e+ODNDrxpgUVm0jN2dfjNNuBSYxFDRPFohb2NZVZgee9 15naSvA0gFg== X-Received: from dlbrh17.prod.google.com ([2002:a05:7022:f311:b0:13c:ea63:bd6f]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3a4c:b0:38e:524:8797 with SMTP id 98e67ed59e1d1-38ec645e505mr2022963a91.13.1784792996824; Thu, 23 Jul 2026 00:49:56 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:09 -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-6-jyescas@google.com> Subject: [RFC PATCH 05/16] mm: Define function to create a dir for populated zone 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This change creates a directory for each populated zone in the node. Note: ZONE_DEVICE pages won't be exposed in this driver due they are not managed by the Buddy Allocator. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index 880de1a6e9ea..1cec9ec5e35e 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -88,6 +88,7 @@ #include #include #include +#include #include #include #include @@ -126,6 +127,41 @@ struct page_alloc { struct kmem_cache *req_alloc_cache; struct kmem_cache *page_alloc_cache; =20 +/** + * create_zones_subdirs() - Creates a directory for each populated zone in= the + * node. Once that the zone directory is created, it creates a directory f= or + * each order supported. + * + * Note: ZONE_DEVICE pages won't be allocated using this driver. The main = reason + * is because they are not managed by the Buddy Allocator or CMA allocator. + */ +static inline int create_zones_subdirs(struct dentry *nodedir, int node_id= x, + struct pglist_data *pgdata) +{ + struct dentry *zonedir; + struct zone *zone; + struct zone *node_zones =3D pgdata->node_zones; + int zone_idx; + char dirname[24]; + + for (zone =3D node_zones, zone_idx =3D 0; zone - node_zones < MAX_NR_ZONE= S; + ++zone, ++zone_idx) { + if (!populated_zone(zone)) + continue; + + /* ZONE_DEVICE pages won't be allocated using this driver. */ + if (zone_is_zone_device(zone)) + continue; + + snprintf(dirname, sizeof(dirname), "zone-%s", zone->name); + zonedir =3D debugfs_create_dir(dirname, nodedir); + if (IS_ERR(zonedir)) + return PTR_ERR(zonedir); + } + + return 0; +} + /** * create_nodes_subdirs() - Creates a directory for each online node in the * system. Once that the node directory is created, it creates a directory= for @@ -136,12 +172,19 @@ static inline int create_nodes_subdirs(struct dentry = *mmdir) struct dentry *nodedir; int node_idx; char dirname[12]; + int ret; =20 for_each_online_node(node_idx) { + struct pglist_data *pgdata =3D NODE_DATA(node_idx); + snprintf(dirname, sizeof(dirname), "node-%d", node_idx); nodedir =3D debugfs_create_dir(dirname, mmdir); if (IS_ERR(nodedir)) return PTR_ERR(nodedir); + + ret =3D create_zones_subdirs(nodedir, node_idx, pgdata); + if (ret) + return ret; } =20 return 0; --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (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 68D053F39EE for ; Thu, 23 Jul 2026 07:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793007; cv=none; b=td8W2DPa3Lo6Cn0LwqQ33vVoJwfbgGgsJJQ7Y6fN6+wA7JJiNkLl+zPA01OyoW8Js+CWhSAncuAcF8b0HJNbSgnTm/YQWM2zNaDu+wkqAwfUOQ9C2Tlx5OWWib/2bUTiz0IJr13W/dXxsHUrB23ayo3FsX0EwXRzqfhDn8MsTic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793007; c=relaxed/simple; bh=qAL5uKkIHv4BorVeGHtI9sxp0dgxdVR+jrNIJhG8MJI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=obG5MnW055vmkIuZcl3LdSECOdYIJNHj11nFqSgVJzH7fPiXnFM6sHd/Q7ZlYv8ZH/BKYXctfE6nN+nh1GX2b2oVqhWEo83BffNfKaCiiuDWExGy8a5gShFkq6aMcsx+j1jFRnO+EweXxEUW+iXuyW3ky+YwnKj9MLzvwCAkrdI= 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=QxHyb79d; arc=none smtp.client-ip=209.85.216.71 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="QxHyb79d" Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-38e8fee6af3so442488a91.1 for ; Thu, 23 Jul 2026 00:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784793004; x=1785397804; 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=4IEwjjGUSei6Ojejw9AeCmT16n0CwbrOZSGJzNcMlIs=; b=QxHyb79dYxGVksErPQ9tsAFSQSOU03U8lXGPyU5LTJMqFPJayjDrYPN9sgMZg1Ztgz errid3NIjOp3o/qRXjoeYHs9in67IXVJgXcny5unWmW0x6Uc9v2DnMd7wGsPjny5evvi 8tCQ+Pjg34cct1/Pbhdzl5AaatPJFa1mHPy3Ak4QMmbsTiIyDajAPel8V83aD76wpDjv pY8nbiHT6Zu9Mipv1JP6sCbJ9HEx0ooIMqg2HiEsdD01XZdyzfgqzeKbZ4gHywmUuDQy +3z1mFukW1lYM23jw3IVjI977eli4H+B2gawoPf0T+ZnVj+oQlL1hy0TVHu3VutbA0vx 8xeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784793004; x=1785397804; 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=4IEwjjGUSei6Ojejw9AeCmT16n0CwbrOZSGJzNcMlIs=; b=W4kMCLi4v38RZ7sekOooV1z68dBhMZMgEgihK4ABxOyQZcXam5443qTFFRoPBLLmPT Bz+xKlZPADSUC04P76XOZQZy+qMIeY7lVQENkECDEMyfyv4UxLO1YjUcA6byVxvwV8kO KHDNilEUJY+hD5jwqcCP9Tt1LCPKBRMR77tpiqtYP3KlrUf45mtg8QXnQgdaxAtOCVqd IVIOx8wQMhXrMisAVzyFd2ENeynQ0UbSXiL8akpXJ99gvcDO7Tq285+BHOT/Sdy/Olc0 9h/dy2sIgFnGzvkpqdwIBRz6Vs4OjFlg080+FchjL2CatHsLYSUkzD6gOqmqfdggaU7k HQCA== X-Forwarded-Encrypted: i=1; AHgh+RqQZjPHsU83EptTw4uTqG5Iq0Bp1wJxRAkCRCJNEVlU0c0tl8TRauATtPQNP4YJoLbKopTYKXSCJ1MefGM=@vger.kernel.org X-Gm-Message-State: AOJu0YwpRBsFtf6EDRHLkSQG+rr19X4dPJH2QD9Z+e0rG2RVw3rP6pMx zt7eAdyNdS04amp5nPtksazoRXjwFXQdec6vcRd6kfy1ZfdxDQtliSdMSXuAQXriCaL8Y6yZ3do d3lhK240viQ== X-Received: from dlyy29.prod.google.com ([2002:a05:7022:69d:b0:13c:e9f1:794]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1dc6:b0:38e:5ac1:9517 with SMTP id 98e67ed59e1d1-38ec6495a0amr2170050a91.3.1784793004352; Thu, 23 Jul 2026 00:50:04 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:10 -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-7-jyescas@google.com> Subject: [RFC PATCH 06/16] mm: Define function to create a dir for each page order 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This change creates a directory for each page order inside the zone directory. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index 1cec9ec5e35e..de86b8526338 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -127,6 +127,28 @@ struct page_alloc { struct kmem_cache *req_alloc_cache; struct kmem_cache *page_alloc_cache; =20 +/** + * create_page_orders_subdirs() - Creates a directory for each page order = inside + * the zone directory. Once that the page order directory is created, it c= reates + * a directory for each migrate type. + */ +static inline int create_page_orders_subdirs(struct dentry *zonedir, + int node_idx, int zone_idx, + struct zone *zone) +{ + struct dentry *orderdir; + char dirname[12]; + + for (int order =3D 0; order < NR_PAGE_ORDERS; order++) { + snprintf(dirname, sizeof(dirname), "order-%d", order); + orderdir =3D debugfs_create_dir(dirname, zonedir); + if (IS_ERR(orderdir)) + return PTR_ERR(orderdir); + } + + return 0; +} + /** * create_zones_subdirs() - Creates a directory for each populated zone in= the * node. Once that the zone directory is created, it creates a directory f= or @@ -143,6 +165,7 @@ static inline int create_zones_subdirs(struct dentry *n= odedir, int node_idx, struct zone *node_zones =3D pgdata->node_zones; int zone_idx; char dirname[24]; + int ret; =20 for (zone =3D node_zones, zone_idx =3D 0; zone - node_zones < MAX_NR_ZONE= S; ++zone, ++zone_idx) { @@ -157,6 +180,11 @@ static inline int create_zones_subdirs(struct dentry *= nodedir, int node_idx, zonedir =3D debugfs_create_dir(dirname, nodedir); if (IS_ERR(zonedir)) return PTR_ERR(zonedir); + + ret =3D create_page_orders_subdirs(zonedir, node_idx, zone_idx, + zone); + if (ret) + return ret; } =20 return 0; --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (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 91D183F413E for ; Thu, 23 Jul 2026 07:50:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793013; cv=none; b=YMADjnAmYHL8QhQhD3H9Lak5hVPCayFZuytpa0Vssp9NBM5C6ljCWoram0T4LV/WzfvzW/OnwJ0bGmxRi+zSaAHBJbpj46Q6/cF1ke7Je80Bog0/rbNr0Nb6imAFvDBlCdg6QGSiTUl9DGtu5klPaZ44k58zfSd5WNw7hYC1InM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793013; c=relaxed/simple; bh=u2fUOQuGIzEu0LzPVl8D8L8TAak1Ws7TcavgU3xXKTw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=RyrVpIEEkPQLTRmFj1TuF0HDmDeEokqKaPTBq8fsGrUqY2SCXUe7jBzPV2MFgem6mhmPSsAkNzhXty8Ib6nbrq9fO9Y/S0pmzVb3zImeaoZ43Bzas9r2Ajugi610KzQ1oyic11QHG/nDGJHH3LlBj3M0pcuW+yOIwXbLRTk1iuU= 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=g3KxhVnn; arc=none smtp.client-ip=209.85.215.197 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="g3KxhVnn" Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-cab041eced3so653340a12.1 for ; Thu, 23 Jul 2026 00:50:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784793012; x=1785397812; 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=41Xn4kxvg4d2m5A/f17AABWitCrv11SosQfQDkutcgo=; b=g3KxhVnn/xWhynPDpECmDhw6OSKTUNZZPHDyXLSRaAiDZ+u1jxkY8A+/GdLWkXHUQ0 ydPY/VCbzvSK602Xb5AWg8379J0B1sHi+2tsNzRqLblHB8CtIqcGmb/2xnOTGYIfYxhC Wunnufd0SWFGPm1p5dhZkp5XbRLwwAbIpEokGlAjtm/BlcCZpZ7gBa8IEhAP03vXmTq/ NzYsqHSsC+XnfqFGhCHesAUtYtwSfFMHS2TLI/XXEEW8Sap5o3ZV0Yobl1J7+siv0oGD 9Y39ltDXbog6yM2iJq2WPgYcCWDeNyzGWOBICtn6/9rxhBZOTILChjkxCFKfPT/GeoCM B8Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784793012; x=1785397812; 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=41Xn4kxvg4d2m5A/f17AABWitCrv11SosQfQDkutcgo=; b=P6uTTqD7GDTn19MxMF9w8WJLI1PsS95Spcs1PeTIzP6MXUM00NO1qYyWYRXsjtegix R+m6zCdcv2JRpVgJ0KZ9l7wmjA2XDnOOTKWLoYwBZXj9Y+VpJm+2hgeBa9IRyDptHbA8 doTH8aIbIZlUIx1hED4pL3kDrObYocYgl7GLx7nj0b1BAEpz9marhw42HiKs2SD3KC3E m+PtBJuUkNPqECfWb+GuHnz9PdSuHN5nfFIW2gXK33G4ETq19VkJaD+L3NdDzIOYs15E b7yS1rxJ46dctRWq/omOqWljg+nueVZlFOicdzi9Z5v7/Xx5/ESqScDWPBKbgd9Qk7dx R7pw== X-Forwarded-Encrypted: i=1; AHgh+Rr+iwxq7+NYZRJiodXEvB06ptvFSdcmcw6+7y29qh11xjTC6CIqXM1w3wtmsONVPniNbLYxNPBtCY3CKJs=@vger.kernel.org X-Gm-Message-State: AOJu0YwQ0UE4KqhTE5OXiFuGb9hWt/gXifg7VCcyF9dZ5vwsmO+e6D8O cbwkZKzEW3mXR60FKCsx4WozXn8qwV+JV+32WK3ZMGonTkmKFPE1hb14HmK0aPNPl4kawxQbDOV 3yAuiSNpkFA== X-Received: from dldyq11-n2.prod.google.com ([2002:a05:701b:454b:20b0:13b:a1b5:d4c1]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:2d42:b0:3bf:a0e5:99a5 with SMTP id adf61e73a8af0-3c44b191b26mr2284095637.47.1784793011546; Thu, 23 Jul 2026 00:50:11 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:11 -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-8-jyescas@google.com> Subject: [RFC PATCH 07/16] mm: Define function to create a dir for each migrate type 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This change creates a directory for each migrate type inside the order directory. This function won't create a directory for MIGRATE_ISOLATE due they can't be allocated using the Buddy Allocator. Note: The MIGRATE_CMA directory won't be created yet. It will be supported in the future. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index de86b8526338..a727c4f48ffb 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -127,6 +127,37 @@ struct page_alloc { struct kmem_cache *req_alloc_cache; struct kmem_cache *page_alloc_cache; =20 +/** + * create_migrate_type_subdirs() - Creates a directory for each migrate ty= pe + * inside the order directory. Once the migrate type directory is created,= it + * creates the "nr_allocs" file and the "free" file. + */ +static inline int create_migrate_type_subdirs(struct dentry *orderdir, + int node_idx, int zone_idx, + int order) +{ + struct dentry *migratedir; + char dirname[24]; + + for (int mtype =3D 0; mtype < MIGRATE_TYPES; mtype++) { +#ifdef CONFIG_CMA + if (mtype =3D=3D MIGRATE_CMA) /* CMA allocs are not supported yet*/ + continue; +#endif +#ifdef CONFIG_MEMORY_ISOLATION + if (mtype =3D=3D MIGRATE_ISOLATE) /* can't allocate from here */ + continue; +#endif + snprintf(dirname, sizeof(dirname), "migrate-%s", + migratetype_names[mtype]); + migratedir =3D debugfs_create_dir(dirname, orderdir); + if (IS_ERR(migratedir)) + return PTR_ERR(migratedir); + } + + return 0; +} + /** * create_page_orders_subdirs() - Creates a directory for each page order = inside * the zone directory. Once that the page order directory is created, it c= reates @@ -138,12 +169,18 @@ static inline int create_page_orders_subdirs(struct d= entry *zonedir, { struct dentry *orderdir; char dirname[12]; + int ret; =20 for (int order =3D 0; order < NR_PAGE_ORDERS; order++) { snprintf(dirname, sizeof(dirname), "order-%d", order); orderdir =3D debugfs_create_dir(dirname, zonedir); if (IS_ERR(orderdir)) return PTR_ERR(orderdir); + + ret =3D create_migrate_type_subdirs(orderdir, node_idx, zone_idx, + order); + if (ret) + return ret; } =20 return 0; --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (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 E0DC13F4DC7 for ; Thu, 23 Jul 2026 07:50:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793021; cv=none; b=bQp6x3hQVPTQFt4SW93fEUv68DcBfxHoCUseUEc8bok4HoPb6ThMS20O5AvP87gyxXsUsOwuLUrLwXLEkCZ70qbLqfwSUhQASAEbA5oXKD4u73I5h/ashIUwpjkFYwPJOcaNurYuHXUrkfy9bIXB7LAClFX2eR74cW3DKgFxL54= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793021; c=relaxed/simple; bh=e6wy3Ur/BAHauo6srooaMZDjM6N0t/WihhOe8fobGGw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kdvceddSbNdI9HPziyQvOkscM1YminP4A3H+shufMDGt5K2SEWpfLJ4DmCrCLdFhHtvLeFBCeyQteVlwbz2jj1w9t06ncFzjGBZLGPUCHs03yr25onDIU3j00YeDoGbwhmrWQIkQyRg2RNQD6qgjbIQ5Ugq8/1Z5q+xnirdOQqo= 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=KX5dVUdy; arc=none smtp.client-ip=209.85.216.71 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="KX5dVUdy" Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-38e2f61c09dso759290a91.2 for ; Thu, 23 Jul 2026 00:50:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784793019; x=1785397819; 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=Rrv5x+4mpVYYp8CMRoch1CZB0fcAbFjciupWA91d6dc=; b=KX5dVUdyGomRYnbcRmBkAwtsGALimhpJL7QfOc/Yf8x48YXGEx+oXG+UQjaOFAXEMU 9fqRXXu+1hjA/jg8YB3OPNdSWXtPNeWNy5pPoZ1Qd/12t/jyFkSky+DHSn1d+Dp0lRP+ EcqftcqH58vW3LJgdIfEttA/3Vgv2nqbJOnEcYKWuCZDxM3MhF/6f7Tc0QaGEWL1WCfr 14Ygywoxuz0Cf2hBQ2mA5qICUHbJoDd5RcTDLyQsT6aMqCRQnFQcjTYpdwCS7KpRC+Nd YG2nFcwW6oFpFDV1DlxoO1mmPAqLbKLZRIgGi2IXF9ZvDZAM8CwUiRiWOzb2CDMdmQA+ 1RyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784793019; x=1785397819; 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=Rrv5x+4mpVYYp8CMRoch1CZB0fcAbFjciupWA91d6dc=; b=sa/bfogsJz4UncyhRycv6NJ4Qa+6vpAMUORO/HKSWeaUmKQ+nZo0YnXbcFTJr0D3Wj A25EiG2OlUfeeyHtyrI4eWvB1ElNNmeYEEeBu1LzQMXDS3YMSraAlkqdl2WBN1QwjAbg zwowZeabn4SWhBOCY+iD0/FDio04T1yb2ZzYxgHro7lKgXQqUzYq3NA4Bi0a2GAu15TK IWTc8kW7Pvqa83rsjgCYnyvdMUShBuxEbZ8uwz66lMm5oWRvCB2VmzUMyYIRVawAu9TF TmNNDFgunBJbVSolc7G9KbpXm/LF3b6Tc91k8rJb+EDAQljHsx/UfGfB1edaHU1SDnPu UGTQ== X-Forwarded-Encrypted: i=1; AHgh+RoBDcoSqvPNGos9U1mHRUDsfIiSlxzn+nPAI4Irx4hrDGMGfdrwUg6AA5+peyySBBaqn6pvTzNV/LxgZbo=@vger.kernel.org X-Gm-Message-State: AOJu0YxyZQ0jeVYKET0QGjdtE1xTddthZgAC0f+SiX/yKXNPrxWCpQm7 KYesdv2fstF+f1WzkljKEKSvL4fgEVAMrTh/5MJl3YsokYMHl5A2KhuciqIkdXyAVgtWoU4tS77 oki/8Bg+W0w== X-Received: from dlec12-n2.prod.google.com ([2002:a05:701b:428c:20b0:13b:848c:abaf]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2f06:b0:38e:adf1:5b03 with SMTP id 98e67ed59e1d1-38ec6665307mr2164293a91.35.1784793018950; Thu, 23 Jul 2026 00:50:18 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:12 -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-9-jyescas@google.com> Subject: [RFC PATCH 08/16] mm: Define function that creates the "nr_pages_allocs" file 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This change implements the function that creates the "nr_pages_allocs". This file will be used to make the allocations. When the user wants to make an allocation, it will write the number of allocations to this file. For example, if want to make 56 allocations of order 9 in the Node 0, Normal Zone and Migrate type Movable, we execute this command: echo 56 > /mm/node-0/zone-Normal/order-9/migrate-Movable/nr_pages_al= locs Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index a727c4f48ffb..3ffad74a0bdf 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -127,6 +127,58 @@ struct page_alloc { struct kmem_cache *req_alloc_cache; struct kmem_cache *page_alloc_cache; =20 + +/** + * req_page_alloc_write() - Allocates the pages on the requested node, zon= e, + * order and migrate type. Once the allocation is performed, a file is cre= ated + * to free the allocation later. + */ +static ssize_t req_page_alloc_write(struct file *file, const char __user *= ubuf, + size_t cnt, loff_t *ppos) +{ + return cnt; +} + +static const struct file_operations req_page_alloc_fops =3D { + .owner =3D THIS_MODULE, + .open =3D simple_open, + .write =3D req_page_alloc_write, +}; + +/** + * create_nr_pages_allocs_file() - Creates the file "nr_pages_allocs". + * + * The "nr_pages_allocs" file will be used to write the number of allocati= ons + * that will be performed. When the allocations are performed, a new file = for + * each allocation will be created in @migratedir. + */ +static inline int create_nr_pages_allocs_file(struct dentry *migratedir, + int node_idx, int zone_idx, + int order, int mtype) +{ + struct req_alloc *req; + struct dentry *nr_pages; + + req =3D kmem_cache_alloc(req_alloc_cache, GFP_KERNEL); + if (!req) { + pr_err("Failed to create nr_pages_allocs_info"); + return -ENOMEM; + } + + req->node_idx =3D node_idx; + req->zone_idx =3D zone_idx; + req->order =3D order; + req->migrate_type =3D mtype; + req->parentdir =3D migratedir; + + nr_pages =3D debugfs_create_file("nr_pages_allocs", 0644, migratedir, req, + &req_page_alloc_fops); + if (IS_ERR(nr_pages)) + return PTR_ERR(nr_pages); + + return 0; +} + /** * create_migrate_type_subdirs() - Creates a directory for each migrate ty= pe * inside the order directory. Once the migrate type directory is created,= it @@ -138,6 +190,7 @@ static inline int create_migrate_type_subdirs(struct de= ntry *orderdir, { struct dentry *migratedir; char dirname[24]; + int ret; =20 for (int mtype =3D 0; mtype < MIGRATE_TYPES; mtype++) { #ifdef CONFIG_CMA @@ -153,6 +206,11 @@ static inline int create_migrate_type_subdirs(struct d= entry *orderdir, migratedir =3D debugfs_create_dir(dirname, orderdir); if (IS_ERR(migratedir)) return PTR_ERR(migratedir); + + ret =3D create_nr_pages_allocs_file(migratedir, node_idx, + zone_idx, order, mtype); + if (ret) + return ret; } =20 return 0; --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (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 4C5DD3ED3C9 for ; Thu, 23 Jul 2026 07:50:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793028; cv=none; b=POiheJh6PrUTfUW0sUMHspQe1Pu/8BewAdrvd+vnGCdSfu1sYzrX8wLBq6et3I3yoc4Wmi7FK0gILZs8gQkTyVyudmxdxZorjNFx64YF5BIGDdL2oqkiZ+Rg32RJ0T3wABd3fn/4NORRvNmA9Ok5uZg1FgOVAOCcf/sYHVyxd20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793028; c=relaxed/simple; bh=N89dStHSM2Saw21HtEnRMuDg0qbt0KxaJqo9WgClq5g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ZGjcF9UkfPGXLTw0sT0mE/puFyYDf3AV+B0QMJZAtd4kXxZe9OwSu2py0oBxs4z8vNcOWLMp2XH0mFxwXYzNfAx16YztXtqD/Pen459OrfyaSq7znO8WCYe2B/vfpJ3C20VUEutlGzAFzg9Qz6WJLm7tXbGIaAknAvvrJXYLVMo= 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=B+SSKiqf; arc=none smtp.client-ip=209.85.215.199 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="B+SSKiqf" Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cb5bdd8450dso349361a12.0 for ; Thu, 23 Jul 2026 00:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784793027; x=1785397827; 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=C7CBNiHk+pogzDyhH1M3QCDP6vdmZRlAwIqSJkV+BV0=; b=B+SSKiqfmGTiWr/A2j34ZyS0NVTrC8zuYh6NXtTrgi0GPwiDGHYkGbxWl7lnUkLB3f 6YI6AAxa7DqBPukWgM8mKJJAbM5QbJXMTdLHZpXhJgpRM0zHunqfhHm+/bMOR11BvLvz jfonWwO5UXrXO3OHHjfJ+FYt1cPcC8nO//22wXam1AGjDmq5gwrJ2CELPqAveLDAEMTg NbKCnaj/GmVpB/UgkTT5zwngrqO8o9gRt3n29a2ygzQs2sqb4ADHGv0ny/tDq0FcQbmg Dn+16akXctRn93RAoN5E+xEpLeqlfAOiymOO5ud9Dm+39vaVGcV928d2lAVL9Z4MEfHF mOkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784793027; x=1785397827; 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=C7CBNiHk+pogzDyhH1M3QCDP6vdmZRlAwIqSJkV+BV0=; b=cTsPnZWaNXQ5KA3oi6lNly3RRIY93zrcP1OlzLumIznSYOUtNJ2KqEY+gcxdMX2fB0 HKkGDXP3wZPaOkOVJKZCuua/Dms91vFf3XSekAx0F/RAgFZe5GHYB/pfFBMZYpLDU5pg P3iW8vkaj5EEUlY/bUHbkPUes+4lbwN5qPl5X5IG/mGg8+eR1lT0aRmX2t/vVNFxdnDY 5AsDODppp5+YiOFeP8Fcivx2AhRxXCwQIcss0w7tFYGP5h+7wTHlN9VJyDN5Km58hmTt pf73xDzjSm1kAozOAfNaihT+1AMAr3RymDy/7dhdG9R6Jsz1v4PpWmR+UYKJhRf3UI7Y 2uxw== X-Forwarded-Encrypted: i=1; AHgh+RpN5oR+0D9hEDHoymUb/p5FkaBY3jcqE5GBtBijR7JiP+o5ssBILX7pIJ74u1f2E5gjXpfSeuMDpyxBJY4=@vger.kernel.org X-Gm-Message-State: AOJu0YzO9ISjmqcZVRj2vUhoxLHKiAczl+18+edChwFa03wJkS6zU8k+ yNLcAaj+KiDh/JsVRGpDIntASDzROw/slEOjrV9S72JkeBulKas/jl9+fcRJcyARFS1nEIpchDp VokJH+AVz1A== X-Received: from dyng25.prod.google.com ([2002:a05:7300:7f19:b0:30c:2bdd:dcdf]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:9f09:b0:3c0:9c19:b275 with SMTP id adf61e73a8af0-3c44b2ae3c9mr2165420637.67.1784793026464; Thu, 23 Jul 2026 00:50:26 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:13 -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-10-jyescas@google.com> Subject: [RFC PATCH 09/16] mm: Read the nr_pages_allocs value given by user 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This change reads the nr_page_allocs value given by the user and validates that is an unsigned long. If the input is valid, it will allocate an array of nr_page_allocs size. This array will store the allocation ids. These allocation ids will be used to free the allocations. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index 3ffad74a0bdf..60dfddf6b441 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -136,6 +136,19 @@ struct kmem_cache *page_alloc_cache; static ssize_t req_page_alloc_write(struct file *file, const char __user *= ubuf, size_t cnt, loff_t *ppos) { + unsigned long nr_pages_allocs; + unsigned long *allocs_ids; + int ret; + + ret =3D kstrtoul_from_user(ubuf, cnt, 10, &nr_pages_allocs); + if (ret) + return ret; + + allocs_ids =3D kmalloc_array(nr_pages_allocs, sizeof(unsigned long), + GFP_KERNEL); + if (!allocs_ids) + return -ENOMEM; + return cnt; } =20 --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (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 BBF423F3279 for ; Thu, 23 Jul 2026 07:50:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793036; cv=none; b=pWpZpxH7WiMQXBMywhfTnztzZD0DbDgG2iXzapWV1o1NXgBkbKIk7NHHytIprJakPKyledkCfXLLRkXZGx9J/ufrB7xTHqInmHljJnujqn90f/lVW+BABa6pCV67oB3/tZstI5LIK5a1wMKXWcYJtP0rZIcIVXgfCwBINnTSjVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793036; c=relaxed/simple; bh=unvaOB9IishwccxqPUHsk9BRdhasozbaZ8cLkz+aJnc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tYNdpWHcYM7WPbc7YqRCRxKZE2xvtW7586JZZj11DiufGNS6ms309EDRhbkn866ClVyAE9cgUyULibF/bCWXI7AtWJcwhzm9TJXQMlUBoADXQEHRSF4UM3krVdvfpmPlcHVGpqe884dXM69aR5EN1u5LEYBYGLTPn0oaBnODCoM= 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=L1P19YRM; arc=none smtp.client-ip=209.85.215.198 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="L1P19YRM" Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-c88cfe287e1so373170a12.1 for ; Thu, 23 Jul 2026 00:50:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784793034; x=1785397834; 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=+D8QBFGuuv7YqblppvOsw7r5pHNiLsUGTC44kaIR0x4=; b=L1P19YRMtsJquoXZZxqBK7uC1bTxdU4duuYJDNAtbinOWRI2BtYft5pa3IQLR7SfKz NtSOR9PEUWeANJ4wIWz0IzCqAXoHDONAvxrIh0KlhWgTsikfdpQhIqGlmCR1vBo4yXdq 039H0ghIw5VxmCuYv+Om/s/5XrOTnFtfGG7XbWP1jHB1+uXhuCcWSEB9OnZf6SXcAuUD gIdBS51HAYFt/iBI9AHrPaAcwg9GqWpFoxrS63ojPN/1aWXYyGYdDIc5eSVS+GiFkwkn oK6ygrNwlhg7q5Xi5977NDWCfkZco8Y64t5PocN1ebRUW0VC73HjO55Zai7Ozr3E0plW uvcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784793034; x=1785397834; 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=+D8QBFGuuv7YqblppvOsw7r5pHNiLsUGTC44kaIR0x4=; b=huuRCA7SP/OAf7txaMCYlZzexb5BIjbOi9nV0cjrVoi/r7c2aEuIhvPl+v6JuvNiHq 2yzTzxQ867yCNf7nrT4J1fdC/8oFv3fQOcgLpUpqZoMx9XT2wwDiIDtFYQDtETJE5ajy jGUQFHkejodtyLgcX1Yf116PWo/ez11vjBtprDqYepY2ro9JZXc4/8YE2T6BWZSP4Y5X Jy0Z75j9pCx6sOeH6au1mIcIBAtxjez+fo2SqyY6oc3SjebeoNnGcCm4HBsIaNEIayAy nWrcKz07ULXzGrBP9/7QUJO/P5t6q9ukrKIJbGNE89FG4DwE2Fq5KRPP/o8G1Vl31ZLF B0mg== X-Forwarded-Encrypted: i=1; AHgh+RpIgp3SovaSHvXKv9KHY8mVaF1XeWPBwXigDoaM3POva8AMA473sWpkWCF12iAajfFZpf6GTun4JUEaUb4=@vger.kernel.org X-Gm-Message-State: AOJu0YxNuzxV85YE6SF1z5oko+ziAffDyaZ3LIeqopGWgUxyAQt39Lkq wHyz1e7FvOJ+uNv1bu5ECf7nLvNyiIoPa9ngsQWcfBhxSfgA2CN0eAkajRRqreDIx2v5y4ftc91 K/EjjiUf9ww== X-Received: from dlam5-n1.prod.google.com ([2002:a05:701b:2085:10b0:13d:1da6:85cf]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1d44:b0:381:149:cf91 with SMTP id 98e67ed59e1d1-38ec658d33bmr1987739a91.26.1784793033910; Thu, 23 Jul 2026 00:50:33 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:14 -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-11-jyescas@google.com> Subject: [RFC PATCH 10/16] mm: Set the selected zone in gfp_t flags 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This change sets the selected zone in gfp_t flags. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index 60dfddf6b441..5c00e9134a66 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -87,6 +87,7 @@ #include #include #include +#include #include #include #include @@ -127,6 +128,33 @@ struct page_alloc { struct kmem_cache *req_alloc_cache; struct kmem_cache *page_alloc_cache; =20 +inline void set_zone_to_alloc_from(int zone_idx, gfp_t *flags_ptr) +{ + switch (zone_idx) { +#ifdef CONFIG_ZONE_DMA + case ZONE_DMA: + *flags_ptr |=3D __GFP_DMA; + break; +#endif +#ifdef CONFIG_ZONE_DMA32 + case ZONE_DMA32: + *flags_ptr |=3D __GFP_DMA32; + break; +#endif +#ifdef CONFIG_HIGHMEM + case ZONE_HIGHMEM: + *flags_ptr |=3D __GFP_HIGHMEM; + break; +#endif + case ZONE_MOVABLE: + *flags_ptr |=3D __GFP_MOVABLE; + break; + case ZONE_NORMAL: + default: + *flags_ptr |=3D 0; + break; + } +} =20 /** * req_page_alloc_write() - Allocates the pages on the requested node, zon= e, @@ -136,8 +164,10 @@ struct kmem_cache *page_alloc_cache; static ssize_t req_page_alloc_write(struct file *file, const char __user *= ubuf, size_t cnt, loff_t *ppos) { + struct req_alloc *req =3D file->private_data; unsigned long nr_pages_allocs; unsigned long *allocs_ids; + gfp_t flags =3D 0; int ret; =20 ret =3D kstrtoul_from_user(ubuf, cnt, 10, &nr_pages_allocs); @@ -149,6 +179,8 @@ static ssize_t req_page_alloc_write(struct file *file, = const char __user *ubuf, if (!allocs_ids) return -ENOMEM; =20 + set_zone_to_alloc_from(req->zone_idx, &flags); + return cnt; } =20 --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (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 2A25B3F8EC9 for ; Thu, 23 Jul 2026 07:50:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793043; cv=none; b=fZSXsxlIrIiIkDBZtjQl2LJgUDZyu3zPWEIrzwKUTJVowosj9/tmOEkkcxJXDNQ3qPWHgIqncNdzhHgSz5ZBZAfbY1l2uWAw2v4PGJt22ncKHSUgCI3j+/u5zUuIEmZRRkaGCVuxmj46Ga/fZQ3s5c+CKPXNSp4s3VTqr89ExMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793043; c=relaxed/simple; bh=7RTjqD7JpmF+/LkfV2OfMmPOJCsOd+f/kasdCvtxsDE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=RsOUVBKKnKTFoBLseWrP4B1UksXHkRKPk05FXOYKrRlxjEkXtkKdfCosfxyXYCc9BBMmX8DCBjVojI8pxZjdHMjq3oCRD3MwgYZ0qqoIBdM+fg+sNG80ztVYB7MLNXt3eGxrenS6Qdxzhz0DPvnF4fhG0G4K5MsRDyvIZ1VQxxo= 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=ffdq/FRh; arc=none smtp.client-ip=209.85.216.72 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="ffdq/FRh" Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-38e54b6556aso494030a91.2 for ; Thu, 23 Jul 2026 00:50:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784793041; x=1785397841; 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=XWxJcdKUwtMW5XvZ+xp1cU8oxCOA1ugDuHmrhdptgLY=; b=ffdq/FRhVR+gI/TjRWAX5H6Bh0UVQHFDXMxTmpx5jDBThSNmRRVFlt0Tfn+HHENg6D DpQTqrcxibDWc0H11HzaVE1JEvB+2P49KyJ/4pLGt4eM/6XBH1Nk7myFuUq4r2qezZmB 5nk2ECrsRFjxoKRC7wyPGTQZ/wvNXnB+oaj4H6P/MEpg3qCDye9b4UFVADTC1lHUNjqu /SRAI2TWULKKHPrySKmPEL6+Gi/DcqI1haoWKM3AB/3XX/ARcK0IzIsiWn+ZztXtsbJ1 i8mbAVk85psBvIFzO4Wd5ukBZ8E8+QxRPduYHL8SqOKu5rEsqvzi4ELfqxhI5Im3apx9 aRCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784793041; x=1785397841; 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=XWxJcdKUwtMW5XvZ+xp1cU8oxCOA1ugDuHmrhdptgLY=; b=mL78ZxK8VS2X+ym/QmqL4i+dV3b1pXJ1Ulu67gVtwz6xdEq5t5csERcrwFVWgXnqQX uG6LqJvQ/irKk+bk1ELI0TEPweMXWc4jbxRlH5e89Zba8Q7oicq3FDF3CFHdY19/CVPl Apok16Tmdkckv24mk5FJdosMrKgp9meQZhlz/7OXyim0o+1uMzv/YvvAftnK3GkyWkpC 84EvtEfzTvzjgWplS9xqQrNxKXIN70lJZDRQAM7rHhXSpzgac0FdwBIG4mygYyw+Fllt mQuDlKJX0zD8W7+3xlO4F36JvW8Hx2BEx8n5jF5qAtQSemMc/9CDaIcIIzmhk3uhq5vH RcMg== X-Forwarded-Encrypted: i=1; AHgh+RqVh2196x33zfsOkEntlwoAiMOYiVO3OKCcxvaFSuTY57fvPK+OWbdBjTyuUHbnv9K2fuAJP3Yh5WQYJE4=@vger.kernel.org X-Gm-Message-State: AOJu0YzIW5N6BaphSWQL/NtbCfVqgBaEphFLgQEP806TOghSRlZU6J5P 4wW9ApQ28ovGdOaxssWeu0LMjXXE/L4Qmcf1n9OLQYo8ZymdOWhZkpxe7AWbW+iukUsXkIJRGwt j0kj2tnT+yg== X-Received: from dled3-n2.prod.google.com ([2002:a05:701b:42c3:20b0:13c:f3ec:de14]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2d10:b0:38c:a59b:5189 with SMTP id 98e67ed59e1d1-38ec698af76mr1930616a91.15.1784793041228; Thu, 23 Jul 2026 00:50:41 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:15 -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-12-jyescas@google.com> Subject: [RFC PATCH 11/16] mm: Sets the migrate type in gfp_t flags 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This change sets the selected migrate type in gfp_t flags. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index 5c00e9134a66..d91f49880f8d 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -156,6 +156,24 @@ inline void set_zone_to_alloc_from(int zone_idx, gfp_t= *flags_ptr) } } =20 +inline void set_migrate_type_to_alloc_from(int migrate_type, gfp_t *flags_= ptr) +{ + switch (migrate_type) { + case MIGRATE_UNMOVABLE: + *flags_ptr &=3D ~(__GFP_RECLAIMABLE | __GFP_MOVABLE); + break; + case MIGRATE_RECLAIMABLE: + *flags_ptr |=3D __GFP_RECLAIMABLE; + break; + case MIGRATE_HIGHATOMIC: + *flags_ptr |=3D __GFP_HIGH; + break; + case MIGRATE_MOVABLE: default: + *flags_ptr |=3D __GFP_MOVABLE; + break; + } +} + /** * req_page_alloc_write() - Allocates the pages on the requested node, zon= e, * order and migrate type. Once the allocation is performed, a file is cre= ated @@ -180,6 +198,7 @@ static ssize_t req_page_alloc_write(struct file *file, = const char __user *ubuf, return -ENOMEM; =20 set_zone_to_alloc_from(req->zone_idx, &flags); + set_migrate_type_to_alloc_from(req->migrate_type, &flags); =20 return cnt; } --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.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 95F223EE1FC for ; Thu, 23 Jul 2026 07:50:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793050; cv=none; b=CuRCnWqLQD1ax6xm6rNz7s1lS3xd/OO5zDde6nLR5/NNyROEnLH5ODa/sHoxO+mEa9JITAAsfyws8Y73+G+MYBFh/iYWUUZmLkeID/d3eIBtEC2o0bbvgs4KhoLAppKie1VRuRrn5L4NtnO8PEEq4LkTckpfU+SptIPtm3xmw8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793050; c=relaxed/simple; bh=Zgp0JxJpZVQ4R23UVsZn8BAcBQHqNs/OP/pPyRV7AMg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=fsWX7omUNXxnA6u8nvQXz5L+79THuEO1YfXAK9r4cPqZeooc7eE7z7Q0dw3I0Y38MIc3tgTL/vjgWoV4905CJ7E849BEOPV2CS/6AHsHRuDZKl9zlmiGSnbvkFix3gJTB6CYChylSQNxgPbWDim9lZOFwcM2DY0zt4zB9qh241Y= 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=LsJa9WBS; arc=none smtp.client-ip=209.85.215.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="LsJa9WBS" Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-c856470fe9fso369892a12.2 for ; Thu, 23 Jul 2026 00:50:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784793049; x=1785397849; 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=BP29+lWQBrVZ0v/6HzcYEqD+hOgCbSaZezdh9Is5B8A=; b=LsJa9WBSBG0SvMjkYEY9E6vc3Z3nD2AKP4TDo5CQWTPd02Y1f8enBpvj7sU7zfUeAD yGYaH7ZkS1oGuspkNKUuhNdthttud6j6rwBXiJhSMy1FFLFi5AKlYWYM2Yn/bHkJuB7i SZfhcj0vcfPWUY+cR+p/iryqBn8VckM3KXMc+uUrSSVXsraN+X189SpVanUf5VdFAe5F qSRZ0ZFofdOdknTmLX+tJrV67dbV5CkQ9qrERU2UlA3SsQheSmCDkoFzZblirploYGbb rXlHebMan0liHf0dqjbz8ho74CCkfj6Y3JlWBhp/OI8Q28nepWohq/Ri6wL7yoaw4KYV wWgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784793049; x=1785397849; 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=BP29+lWQBrVZ0v/6HzcYEqD+hOgCbSaZezdh9Is5B8A=; b=EWdfTh4WU4Wygyhf6rADU/l4TAOlY1CUpV4KXRCt/hhMcCsCJ4bbJc5zEGjzC5hHbF d4xyKTRNKUsA7TpOVc3iu2dbSYryUagLAg+mjh9strCUO/QLxsZ3eGWmck8vbKAZVNc2 da2QgTwx7/CzwPZ4PQ8yZUA0nGO+RyodhDGajiLyPlwp6tJBpKWbMpg4GuOWpC9eA6Xp ZIRruJ29pOsYxv4CtU6tqrKZ6Ey9yhDufhotqlxD86uASjFjxhCwmU7ulFruU+qAwVOp vGgKw3gnL0nHcvte92mWKQJVX8fbph2UIj6KEJt2FaJ0u5XJqY8io36qEtL9uzLH4UIc LbGg== X-Forwarded-Encrypted: i=1; AHgh+Ro3u3CdGiqe2edX9EJjZg8dx/vq0I2XScl777aYP2Z0mvCjp4/t4IdNOaDV+gHGcNsrdwb8ziS0jLFFGn0=@vger.kernel.org X-Gm-Message-State: AOJu0YyzxMjkwcqHuUsQ6FFGjlAmpv5Jg3cpP+MxHsFuURR2GOGQZYja uQZ2VYexNPNV3RLOnrs5Mt0tZ68VBIKIP9ayaviDH5pItH5hhY5beoGNO7ANOGLFj/ySDLGnVBV 5Bg6iycIjHw== X-Received: from dly25-n2.prod.google.com ([2002:a05:701b:2059:20b0:13b:9d65:a542]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3e85:b0:38e:5741:5173 with SMTP id 98e67ed59e1d1-38ec662cdc5mr1864402a91.29.1784793048525; Thu, 23 Jul 2026 00:50:48 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:16 -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-13-jyescas@google.com> Subject: [RFC PATCH 12/16] mm: Define the make_alloc() function 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The make_alloc() is the core function that performs the allocation. The tasks of this function are: - Call the Buddy allocator to make the allocation. - Store the details of the allocation in struct page_alloc. - Insert the struct page_alloc in an xarray using the allocation id as key. If something fails during the allocation, the pages and cache will be freed. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 71 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index d91f49880f8d..7f6eebdd5197 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -97,6 +97,18 @@ =20 struct dentry *mmdir; =20 +/** + * atomic_long_t allocs_file_seq - Represents the naming sequence used for + * allocation files. + */ +atomic_long_t allocs_file_seq =3D ATOMIC_INIT(0); + +/** + * allocs_xa - Represent the xarray that contains the actual allocations p= erform + * by this driver. + */ +static DEFINE_XARRAY(allocs_xa); + /** * struct req_alloc - Represents the requested allocation * @node_idx: The Node index to allocate from. @@ -174,6 +186,47 @@ inline void set_migrate_type_to_alloc_from(int migrate= _type, gfp_t *flags_ptr) } } =20 +static int make_alloc(struct req_alloc *req, + gfp_t flags, unsigned long *alloc_id) +{ + struct page_alloc *pa; + struct page *page; + char new_alloc_name[12]; + int ret; + + page =3D alloc_pages_node_noprof(req->node_idx, flags, req->order); + if (page) { + pa =3D kmem_cache_alloc(page_alloc_cache, GFP_KERNEL); + if (!pa) { + ret =3D -ENOMEM; + goto free_pages; + } + + *alloc_id =3D atomic_long_inc_return(&allocs_file_seq); + ret =3D xa_insert(&allocs_xa, *alloc_id, pa, GFP_KERNEL); + if (ret) + goto free_page_alloc; + + snprintf(new_alloc_name, sizeof(new_alloc_name), "%lu", + *alloc_id); + + pa->req_alloc =3D req; + pa->page =3D page; + } else { + return -ENOMEM; + } + + return 0; + +free_page_alloc: + kmem_cache_free(page_alloc_cache, pa); + +free_pages: + __free_pages(page, pa->req_alloc->order); + + return ret; +} + /** * req_page_alloc_write() - Allocates the pages on the requested node, zon= e, * order and migrate type. Once the allocation is performed, a file is cre= ated @@ -183,10 +236,12 @@ static ssize_t req_page_alloc_write(struct file *file= , const char __user *ubuf, size_t cnt, loff_t *ppos) { struct req_alloc *req =3D file->private_data; + unsigned long alloc_id; unsigned long nr_pages_allocs; unsigned long *allocs_ids; gfp_t flags =3D 0; int ret; + int i; =20 ret =3D kstrtoul_from_user(ubuf, cnt, 10, &nr_pages_allocs); if (ret) @@ -200,7 +255,23 @@ static ssize_t req_page_alloc_write(struct file *file,= const char __user *ubuf, set_zone_to_alloc_from(req->zone_idx, &flags); set_migrate_type_to_alloc_from(req->migrate_type, &flags); =20 + for (i =3D 0; i < nr_pages_allocs; i++) { + ret =3D make_alloc(req, flags, &alloc_id); + if (ret) + goto free_allocs; + + allocs_ids[i] =3D alloc_id; + } + + kfree(allocs_ids); + return cnt; + +free_allocs: + + kfree(allocs_ids); + + return ret; } =20 static const struct file_operations req_page_alloc_fops =3D { --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (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 931933F1659 for ; Thu, 23 Jul 2026 07:50:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793057; cv=none; b=N1EG0muTMwcRcricb3aJyu12J6YM0odACOnsASP0SoBe0jAXDhITtjcAGyxQVC1nIb2iWpqx8SIHAwQZ5eCQbb90ald6NZXI32ExnvbReMSznAQ34Ndz3hprvuvfP1ii0lWc7WIeLRlufRZuYngPW17D+pXnIZlbqF/8m+OFUIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793057; c=relaxed/simple; bh=6/GUZTnm7PcCEVB5fPYxBc6y6EYRp5VR2hoMPMCFWSE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=EHT95na++esbUZMZefbbequFum6AaDf206gqB7MLBXAJ6EKTM/UnaGdDhWniZGemNFRIRajKKNdWKe7ZWZTApeAm3vypB6iO4nsDpCCor+pxLKAFqXp2nnpVidbfxMD/AVmHbeP/XKm/xIdWOuWL0MzlGhMAEuhtz1qShLPp0fA= 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=OijX/KLL; arc=none smtp.client-ip=209.85.216.71 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="OijX/KLL" Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-38e2f61c09dso759860a91.2 for ; Thu, 23 Jul 2026 00:50:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784793056; x=1785397856; 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=FxjTJiqjVFLTCaDJDgC11KYRNKaCxojd2JWjTxQwclM=; b=OijX/KLLjrGAg6CVUbIv1DZnJRDYo/o9Q6gLO5bQgbaTvvmI8sH45kbRPJ5+IZ3yL+ ++J6sskE/i2NV09fKh6NAdeDAypxhMgOvrkVUUjoe94klJIwBPvlM2XTay9tPGcOknc8 p6upwSiWgvITSuz+Bik1XfISiuMOq+nZK4+sK+n8G/0Tv7WfvwPExJb8XnosbdAB1iT4 FAz9TCYYyZkBJ01W9nPlMx9zwxcmZnxU6waR3+v96uDmCgVbfQk/AhlkWR/7uFe7zsJx Zsv3yX4g05GUVhZVpy3WQihLTW/ZuO9db8gVYA4XG07VBMxQ8R79234EQJxN1uJHdCc2 4EYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784793056; x=1785397856; 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=FxjTJiqjVFLTCaDJDgC11KYRNKaCxojd2JWjTxQwclM=; b=TTbdHJSK+50lXcvUOQjEdzl0Tbq+jUwxTR9HexSwfs5yRseL5+qAtfKvcdirOfAgLX KMDwsNfuFbxK8hT4moMghbreDvMeRNLhIlxQ8nymAPTfswkCo3OYYdrcuQUojalw2LIe kS9EsIeLPaQRmoM8LPVCozq3S5jctp3pdgYP1sBIWhq5iFWvBwPtYbXJtgg0BJXU3Elw p4sBA5SNBTR7/IgeEarriPvTzyXli/5yBzHJsPe+fmR0WrnIOOInnxFttxi3AyEfVzwZ 33c+RI8E5a8Cy+K2r0Fi61TpCl3iMKKvyzGlkryxxs35NDSm3Nijy4NHB7YNxjg7LOfA 9RWg== X-Forwarded-Encrypted: i=1; AHgh+Rr7zpv7AgDByq5OQIA4lfLdRNGI8bt26fcJJRadhiGKpau9AoxS1HiLJFFwmG2fKpw9u7ABCIWjnyZxfhM=@vger.kernel.org X-Gm-Message-State: AOJu0YwqwwYMNkGX3ZDtA0zN0YDhjBctXsbMaXcyJczBLrX6Sew4hSLE EKLaMRNLrki8IH9g9pbYO/wZn4Q3b8vuDQiGp+A0x3MycronOBMpYbMFlrlrkmg0KvvjONXVNOO Gfg004665bg== X-Received: from dlep8-n2.prod.google.com ([2002:a05:701b:4588:20b0:13b:a040:bbf1]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4a83:b0:38d:ec31:4840 with SMTP id 98e67ed59e1d1-38ec651c5bcmr2107431a91.13.1784793055781; Thu, 23 Jul 2026 00:50:55 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:17 -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-14-jyescas@google.com> Subject: [RFC PATCH 13/16] mm: Create the file asociated with an allocation 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This change creates the file asociated with an allocation. The name of the file will be given by incrementing the atomic long "allocs_file_seq". This file will be used to free the alocation when the user requests it. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index 7f6eebdd5197..203b71a25e64 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -186,12 +186,26 @@ inline void set_migrate_type_to_alloc_from(int migrat= e_type, gfp_t *flags_ptr) } } =20 +static ssize_t page_alloc_read(struct file *file, char __user *ubuf, + size_t cnt, loff_t *ppos) +{ + /* Which information should be print about the page or allocation? */ + return 0; +} + +static const struct file_operations page_alloc_fops =3D { + .owner =3D THIS_MODULE, + .open =3D simple_open, + .read =3D page_alloc_read, +}; + static int make_alloc(struct req_alloc *req, gfp_t flags, unsigned long *alloc_id) { struct page_alloc *pa; struct page *page; char new_alloc_name[12]; + struct dentry *new_alloc_dentry; int ret; =20 page =3D alloc_pages_node_noprof(req->node_idx, flags, req->order); @@ -210,14 +224,26 @@ static int make_alloc(struct req_alloc *req, snprintf(new_alloc_name, sizeof(new_alloc_name), "%lu", *alloc_id); =20 + new_alloc_dentry =3D debugfs_create_file( + new_alloc_name, 0644, req->parentdir, + pa, &page_alloc_fops); + if (IS_ERR(new_alloc_dentry)) { + ret =3D PTR_ERR(new_alloc_dentry); + goto erase_xa_entry; + } + pa->req_alloc =3D req; pa->page =3D page; + pa->alloc_dentry =3D new_alloc_dentry; } else { return -ENOMEM; } =20 return 0; =20 +erase_xa_entry: + xa_erase(&allocs_xa, *alloc_id); + free_page_alloc: kmem_cache_free(page_alloc_cache, pa); =20 --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (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 1D9F03F1ABD for ; Thu, 23 Jul 2026 07:51:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793065; cv=none; b=JIz+ywK4jFo4RyOMnFJsR4MFokshaKiH3xyTkELZL3oYuIzVF+97yK8SNYIwhJFbc3+UaJogOphakiyZ83A3ude9GEau5G3X3YbIGzhguBwDYVcQ3MHPN/6iCBfCnPQueO4ySwaLTGLtd4vJbuzJoNq2ciFd4d4+olpWT+CYGl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793065; c=relaxed/simple; bh=9w+L1CbicIANDvv7NVICWukpw7jPmYodLJLNjVTP/+8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Omp54KBFwxjzi7xhSxgo0vMU9JUZ8xcH37yudlMHLkB8UM+IsEQCgbOWDlS2cGi1wBTYFiVGzfioiZYvDp0V/ucZxjREOwF6ncnPowvPVZC+4hYo5wzKJG3pvUKb+KHp8a/HJXeNMOZxc8G1Nag30f3NeGWGvR12mWvfy6NU0r4= 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=klbcJkd5; arc=none smtp.client-ip=209.85.216.72 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="klbcJkd5" Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-38e7621655eso726080a91.0 for ; Thu, 23 Jul 2026 00:51:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784793063; x=1785397863; 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=wF4CarUiD02S5s3G5AQzi1sn1tuKaUMCCFINvnzAblg=; b=klbcJkd5v0VlTUrbSSEdrEFPEp5eK+5zuxla9YSP7mFkVqp0i+kPx1VqLtdvfIL1RC i6KAAYWDKHAgqAq43QtPO0UYo5Wh+RCuieYNtQaHSyHReKA+6lJgGKIEvPcdRuhH0jbA UgPbwNNdkdx1QzkesMfc5QiLuIbb3LeyPFikodkepJupkzf+m19u0JIkgCKDp/QypFBy /psI+ZrddHVMX0p2oORSF35fkh86ySEzT7q3C5NQPg/5ZO2gXQSgk/or87UZ3Ifr1fRE 1+dJyLvm86bj58UeqLYcojNqNQEPuteVxPxd99RKwnFHTBLm0RH4QD5SEAQoYgJzXc1r 5gtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784793063; x=1785397863; 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=wF4CarUiD02S5s3G5AQzi1sn1tuKaUMCCFINvnzAblg=; b=ZYyOInDx2xqLoJdMbrhnwmhEBb2ag4+u8fwDzvbINy+HI+soK4ajIEkOZ6e/jvAkyP 7aTj5PT9syr2DZINweON0Tr6WKi/RDyGBgIf2SdkF5A9SsCW6kZVP3geYyxZHAu24i6M 9Y/bG5bC/3fTnMDFXvc9DGc2/IYf/gJ5gpRpOYkANWGdTfT3+FgioXUSI3/rP/aCdx0Q tDq7q+C8Pv5BDYeTUe99b/DjRXb2pZg0KymtOqWkUaSYvorEZoHiPmkjPR62z/WXuZus NBPyfzL6I6p3Esv17RpdcjqEHkl0bwPXR2b7zzJQJ0+38ylrfT0dPKd6wbNgc3BVbCd4 oBoA== X-Forwarded-Encrypted: i=1; AHgh+Rqk3kRvqjsU9Vy+wiF991kReQILbgomhj/V2GTWXnyRWMHRq5dbmXwLrXtIgpgIc2ywI9v1rnTVPwnWJ1c=@vger.kernel.org X-Gm-Message-State: AOJu0Yzp612DttGcTsppiU224MNxmhASgYtTRDgBPDS83sVTbPESo14R mzHEgGyN5P5Pv+OuTSR7se1S6Eoy9JlijDjgFPZSEjYiuIX7PcNbraQPM92T/fjaQS9UH7DYURP dMHDgof9puA== X-Received: from dlar19-n1.prod.google.com ([2002:a05:701b:21d3:10b0:13c:eacb:77ba]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:5823:b0:38e:6bd7:fbbf with SMTP id 98e67ed59e1d1-38ec6a48029mr1828425a91.20.1784793063155; Thu, 23 Jul 2026 00:51:03 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:18 -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-15-jyescas@google.com> Subject: [RFC PATCH 14/16] mm: Free pages, remove files and clean cache when one alloc fails 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When one of the requested allocations failed, do - free the pages that were previously allocated as part of the request. - remove the files that were created as part of the request. - clean the kmem cache. - Erase the struct page_alloc objects from the xarray that were inserted as part of the request. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index 203b71a25e64..e65aac881ec7 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -253,6 +253,23 @@ static int make_alloc(struct req_alloc *req, return ret; } =20 +static int free_alloc_helper(unsigned long alloc_id) +{ + struct page_alloc *pa; + + pa =3D xa_erase(&allocs_xa, alloc_id); + if (!pa) { + pr_err("The alloc_id %lu was not found!", alloc_id); + return -EINVAL; + } + + __free_pages(pa->page, pa->req_alloc->order); + debugfs_remove(pa->alloc_dentry); + kmem_cache_free(page_alloc_cache, pa); + + return 0; +} + /** * req_page_alloc_write() - Allocates the pages on the requested node, zon= e, * order and migrate type. Once the allocation is performed, a file is cre= ated @@ -294,6 +311,14 @@ static ssize_t req_page_alloc_write(struct file *file,= const char __user *ubuf, return cnt; =20 free_allocs: + /* Free all the pages previously allocated. */ + for (int j =3D 0; j < i; j++) { + int ret2 =3D free_alloc_helper(allocs_ids[j]); + + if (ret2) + pr_err("Unable to free pages associated with file %lu", + allocs_ids[j]); + } =20 kfree(allocs_ids); =20 --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (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 47C133F3295 for ; Thu, 23 Jul 2026 07:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793072; cv=none; b=TMJMjaXkje6+OkUzL2uls2D6nfaQOCFCveuCVVTbxb4va7wZnK2QVzm2mFlLD/r98qFYVtnVgbWEUhrMNUFn5qizsHzY7Erc0wfGW3JM+nGnmDpHd6fbZkB6HTtNmZVTLYypyZz/y4UUpjwewAiv4UL1bQdHQ0BLb0Hjachmyjc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793072; c=relaxed/simple; bh=CAmrLKoUa6rho0gBNw+JpG1wan7zSLcKFJibxSb/KKI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=M2G6Zw78SLohdF6FqnEj94fVQb5BkN8n/xs6wj01Nzc6ebSF3zcV5i0oody8odHuG/GJo5lneDctCObe+gePPGbsAloM19hICVa1WEblEAygwd2OywOuIprIuVK6E6TaKm/Rjpw0gBZTgfFQ8D2vIqET/yV2LkDIWHrDybb00P4= 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=ExCo5UEK; arc=none smtp.client-ip=209.85.215.197 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="ExCo5UEK" Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-cbb92868263so608299a12.2 for ; Thu, 23 Jul 2026 00:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784793071; x=1785397871; 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=7DBUAz0DHEFtyZnsL6ARz3oP4Pqf/8loRhE7mS+17IM=; b=ExCo5UEKsvAOwMZHMs1VICDMDZVzVlLiT7I59gW8UYXszbAUO2Vv+g610XxVmU+GNE Y42BoP4gBsj3XPVLg6J2EPtaCtjnTZ7CqRvBXkSEegFYudnc18b/d5Pq/3VN2sifumNZ Gv7JtLMgZUr1Gs4oBoYYHrbwmMly/zTAPKkVpBO73+uG1B4QJNq/1qbYDEIdldPka74/ BSaRigFUE+dMt5g/aNu+FJFzQd3P11BPyU43mTkpsIuUxbU50a0K26mkeavqnYm2vaTp e7aXji/pV4nAZqPdGLu/n462rMeKaZhOqNFu11CIXPmy+kc2L86NYAq6hzNsfvQfNIBF 3r7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784793071; x=1785397871; 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=7DBUAz0DHEFtyZnsL6ARz3oP4Pqf/8loRhE7mS+17IM=; b=FXs8LeukNK6mH7k/eCwUZ+il0f02YfBXXod2BlM/v0cAFwi56gdC5OlwhOBpXM3OYu zNf5g07qdZkms1J5V5ktSjb/8AOr91f+ov8iQMO3s31na//IaSBdZ9vQFJ+IUz8rYSa4 fW4yl0iCmOxorrOConhfgbm2AnWpwOJF0ToJ/7Aq1f+rKw0s4xF52W0uTFFBs4F0pMrV E5ON0O/aY0IZ7Iij5AoXXJYrTyRiIoeCGjlsFKcHjj2YAJzIRw2nKfBn6ku/nCYnHgyP Jg5VeDsxFOoCPawl2lA6Aojf3aY+6ZJaJ+TT7PtYllBa5yacTnDPv+K0UBw8OCh3Sm+0 2rGw== X-Forwarded-Encrypted: i=1; AHgh+RoH6dlT1wgqNovT1B9AD8HPJsGh6zzpAH0J5z9V9WyScBhB7Jzpfd/HufTgwpOZ5Rdv4QEArLa2JrdllDA=@vger.kernel.org X-Gm-Message-State: AOJu0YzVN4kPo2tHfMjThIDVlzYgsHrGbKXMFRU3YUeAGpXsgDIfuJEY DJf9eWTCLgY66fN4SpsQsNBh02HOdtDlKCnPnwxLRRzhSrCcmTlulkEQbX7G3SqOHDL7RG7oz5e vdDGpBZHK2A== X-Received: from dli14-n1.prod.google.com ([2002:a05:7022:28e:10b0:13d:1c1d:bba]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:7008:b0:3c3:8de3:8eee with SMTP id adf61e73a8af0-3c44b222849mr2150120637.61.1784793070348; Thu, 23 Jul 2026 00:51:10 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:19 -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-16-jyescas@google.com> Subject: [RFC PATCH 15/16] mm: Create the "free" file to release the previously allocated pages 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This change creates the "free" file and defines its file_operations to release the previously allocated pages. To release an allocation, the user will run: echo > /sys/kernel/debug/mm/free Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index e65aac881ec7..5fe9c545e884 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -83,6 +83,7 @@ =20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 +#include #include #include #include @@ -94,6 +95,7 @@ #include #include #include +#include =20 struct dentry *mmdir; =20 @@ -331,6 +333,37 @@ static const struct file_operations req_page_alloc_fop= s =3D { .write =3D req_page_alloc_write, }; =20 +/** + * free_page_alloc_write() - free the previously allocated pages. + * @file: File where the user is writing. + * @ubuf: Contains the name of the file the user wants to delete and have = the + * memory associated with that file freed. + * @cnt: Size of @ubuf. + * @ppos: Current position in the file. + */ +static ssize_t free_page_alloc_write(struct file *file, + const char __user *ubuf, size_t cnt, + loff_t *ppos) +{ + int ret; + unsigned long alloc_id; + + ret =3D kstrtoul_from_user(ubuf, cnt, 10, &alloc_id); + if (ret) + return ret; + + ret =3D free_alloc_helper(alloc_id); + if (ret) + return ret; + + return cnt; +} + +static const struct file_operations free_page_alloc_fops =3D { + .owner =3D THIS_MODULE, + .write =3D free_page_alloc_write, +}; + /** * create_nr_pages_allocs_file() - Creates the file "nr_pages_allocs". * @@ -501,6 +534,7 @@ static inline int create_nodes_subdirs(struct dentry *m= mdir) =20 static int __init page_alloc_hogger_debugfs_init(void) { + struct dentry *free_file; int ret; =20 req_alloc_cache =3D kmem_cache_create( @@ -532,6 +566,13 @@ static int __init page_alloc_hogger_debugfs_init(void) if (ret) goto clean_dir; =20 + free_file =3D debugfs_create_file("free", 0644, mmdir, NULL, + &free_page_alloc_fops); + if (IS_ERR(free_file)) { + ret =3D PTR_ERR(free_file); + goto clean_dir; + } + return 0; =20 clean_dir: --=20 2.55.0.229.g6434b31f56-goog From nobody Fri Jul 24 21:52:56 2026 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.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 901B13F3295 for ; Thu, 23 Jul 2026 07:51:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793079; cv=none; b=OKKY2yDfe6rJ/Za4FCYZul3qj/QclyFjq2AUN1CIKoGpNBUnGN1yenFGl3OiCF3pW9STwoRf9i17qvjsHO1vPsf5NahkDNTSCPVo/y8P5UU3SYnryyYDfjed5sYPN7AQdyVYxAIdVNnSX4PgzHi/GXF/ub90iziulkJhyXF+8eM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793079; c=relaxed/simple; bh=6d7zGfBxdjpfyOtH1AKzBxybhaHYpOYr8NQxpni3W34=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=dsgRXxdJx1kG5flzOXdOIbONybEY7JYmV4wdhZoMRVgo82ObdcSqcPqzHi2xe/BPZYGoGpi3J6A95g//mdCCIKD6mew+InSdQ/itZBz4hznDC3ahfBe2cVqFj5+i88ko2ofZzoG6bDMbYNPJ5EEJveZ+X/nRcE366h4784cDkhA= 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=ZQtcmZbm; arc=none smtp.client-ip=209.85.215.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="ZQtcmZbm" Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-cb74d5db64eso507690a12.2 for ; Thu, 23 Jul 2026 00:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784793078; x=1785397878; 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=5YYey/5Hv4fNNykpHycfCnNQ7fymswCzBiRznc3m07I=; b=ZQtcmZbm4cCeEN8tCbr04GMpdop3cpP8uRHhLzDCwKWE8EDi6sGteVi3qw8wjcobdy KmJYdVEEqefcpSE/dYLnhVRKHlbkWl9AnuBfouUvYFZGIKhTbRH116RcJ9++GmPe92aG +gpaY0O3Mv6m4YpKjz1OaTCFn8nKMNK9BSJl8/1S8sj8xEBoiACznTWUwv4yUZIaNbLj FQwnFcVLt/vzGQ5QmADEvmTHeD6MSwOh9wtS/EN+lsUH9Ogygj67pTQ9MPgZgQjmqqSc n2wuyYDchnAihvoSlS9Si501moikN06a2zMLRD35BnZeN2TBSgbclXfj+zQCq+7IdU7l nSCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784793078; x=1785397878; 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=5YYey/5Hv4fNNykpHycfCnNQ7fymswCzBiRznc3m07I=; b=bAt8VzQIU+VfPXnf0lNo+1Sbw/yQv2ZhbmaJD4clRYi7fejcsrRbtbyT8IqbqQ3Y/s qG67+syV/WbkHg+9ib8TI/79m5Tt8Y3RsrZx773GyMnrjUK7TqSl7/r5eTLnymyN4I2u Ve6836nGDJqFp9fM1PUSNtfWBcfyZbZRjN5LgynQ2VPddC3nMrqsU/Jj/Xo6/HXsNJnf LbXYHCN5ZcY4hNcbV98Y2CKjLUPfz857CbgYoEzYGhO1sjzJoS3pE348c8Wp7NWvfcfY BkOaIspCL3IwKlr8ocEy4YJoiwy/mdv5h4KJ1fp7gLhKb2JyxlMWKMwpT9EoLPU4ggSS zH7g== X-Forwarded-Encrypted: i=1; AHgh+RrvKacmmlCOkkAD5zVZdsfvLv7Q4whHES1NVAfWOEjQ3Qri81p1ukc6t3QH6tKZ77rVEDBZygSInAv6tU4=@vger.kernel.org X-Gm-Message-State: AOJu0YzNW5ZnyqxK4Z2eY6sIO9rfcSMBGrV6FF/WHc3f2kOzJkWo3g81 UwAvcFQA7sUz6dR6FnLNNufJJgsu7TY9ThNbeU6ImP/taJV8Xwp5/yZKmoH++uM+A/yBlLlB8qu DQmy0nnVzlA== X-Received: from dyvo21-n2.prod.google.com ([2002:a05:693c:41d5:20b0:311:4890:b1b9]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:7a96:b0:3c0:9c19:65b9 with SMTP id adf61e73a8af0-3c44b26f282mr2124168637.65.1784793077775; Thu, 23 Jul 2026 00:51:17 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:20 -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-17-jyescas@google.com> Subject: [RFC PATCH 16/16] mm: Release resources when the page alloc hogger module exits 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the page alloc hogger module exits: - free all the previously allocated pages - Erase all the entries from the xarray Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index 5fe9c545e884..f554bbb4afa7 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -590,6 +590,14 @@ static int __init page_alloc_hogger_debugfs_init(void) =20 static void __exit page_alloc_hogger_debugfs_exit(void) { + struct page_alloc *pa; + unsigned long idx; + + xa_for_each(&allocs_xa, idx, pa) { + __free_pages(pa->page, pa->req_alloc->order); + xa_erase(&allocs_xa, idx); + } + debugfs_remove_recursive(mmdir); kmem_cache_destroy(req_alloc_cache); kmem_cache_destroy(page_alloc_cache); --=20 2.55.0.229.g6434b31f56-goog