From mboxrd@z Thu Jan 1 00:00:00 1970 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 332C23AB47E for ; Thu, 6 Aug 2026 01:11:52 +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=1785978713; cv=none; b=fXIwIOMYh4WXg9SABfL/HyGnQ6fJyZmLrYjfmprh9JJr0zlo/Cl7ysCXQkF9IEBj6bG29BhDvkkhoKymBcUhs+JNIjB2S8bOG7PWyZBYMHySj81wP2O0lq94g5iM6GHIvIgrQ3M+gIJNxsrtWMD2i1Z9rShtBa75MdRuSNsq3yc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785978713; c=relaxed/simple; bh=DrsM1A0c0oXFvXGMr4YkYD74KwdjvSxrMPaIgTNExyw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=KkBzGtiDvsAY8wiG3IHy4YPagZbx48jUbkS56oEY6LLUO3FuYTU8hQCS0qNBw7oRVDM1o5FxUbzJL5AzowcH0mG1gzHkgw8YF1NDMnPPSi51s1N/kAKoWuA6z/ZXfCN/g15BwhUHZp2kD0XfT38XL+KSBl3QkIaVG7KEnNH8dIQ= 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=NI6kUYmI; 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="NI6kUYmI" Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-c89704da8c7so2440585a12.0 for ; Wed, 05 Aug 2026 18:11:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785978711; x=1786583511; 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=MHXuMtbWju/rmVGPj2ANhVgDVgcL2e8ZMo4e+wRd2rA=; b=NI6kUYmIgoOa/PViMVSTuiP0BBuSGjsOmbrqY3Ylrqo3IkxromLn16CPsn3wgOozXj he4wmPpeuzah9b26sLqXtE6jxVolZLXrobIVjCYDhbj2cYK5J92v5sILxj0HtmGjDikv DhDYUpDU/EVnwhiZbcBoH91JuaTTGGoSU8DzUxz23a2bwNAjG/waWOckdut1o0f13XZW vh6Ydfb/wrT+pf4hQvLApyZAsgm4OZuTMUrThj8Or3zYfhz8pU0Cn6TWeX2UKSK7ewxD hk33QoXJNsQiW+E4jGIO0JS+0Cn/qd4bkem49oSc0cu7IA9KKU30KdeZDpl7qxekeaKW VcZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785978711; x=1786583511; 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=MHXuMtbWju/rmVGPj2ANhVgDVgcL2e8ZMo4e+wRd2rA=; b=PUQ/grlPxA7VgVTNsypzl7FHcbgE4fo0Y11IiHghdvb6vgXq1TqEjk4szJGfpH2F5w pV8MuaFnnOBcpFz8nEpc6EuU+TmuSO3tsXPs/8gLe4E32DC04uNgv/QJdO6r+xOU04yg v8sUJL+ozsaZPuE+4pdoLkb15WrlLtWOQb+CdB0IX8WY2c9ogfi74BWPveQFXDjekORS g0YRz8l9VxtAQyi9tnQPxwHPktQOHilVe+joCyWxeG6E7hbeJmOdOt39bwfre4rmni// 8I6ylNFttksz89m0bh4TnQg8CjmbJBuflWpFheu1YJ27W7Xf928HREZA6o2cuQHQWEop JrxA== X-Forwarded-Encrypted: i=1; AHgh+RoIq0XQtwFHASTanIK8XXGjiq/5MCG09m7e94+GEWvQ36C0l4fDlHjGXiu2f9jYv1ldCBx6AuWkqrV2cKM=@vger.kernel.org X-Gm-Message-State: AOJu0YxqOFtT/5yU8KUeqJAuiXES4tirHmjMRMiRVmHSRNGiImOZJw3L zhAvTNCgfunAQRqrxYuvfr8vDpxErQeb5SkO2G6Nc1ckstbpyUzPblRmLrxCt70RTAueXyOpKsO CUr4qlzHTUg== X-Received: from dyaw6-n2.prod.google.com ([2002:a05:693c:4146:20b0:30f:c4be:bef4]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:164a:b0:3c3:a08d:5b44 with SMTP id adf61e73a8af0-3cb85ef9234mr13893240637.23.1785978711382; Wed, 05 Aug 2026 18:11:51 -0700 (PDT) Date: Wed, 5 Aug 2026 18:09:04 -0700 In-Reply-To: <20260806011048.517229-1-jyescas@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260806011048.517229-1-jyescas@google.com> X-Mailer: git-send-email 2.55.0.629.g250fe7f194-goog Message-ID: <20260806011048.517229-4-jyescas@google.com> Subject: [RFC PATCH v2 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, ljs@kernel.org, fvdl@google.com, tkjos@google.com, minchan@google.com, dskiba@google.com, open list , "open list:MEMORY MANAGEMENT - CORE" Content-Type: text/plain; charset="UTF-8" This change defines and initializes the caches for the structs req_alloc and page_alloc. Signed-off-by: Juan Yescas --- Changes in v2: - Use static for the kmem_cache variables. - Use \n for the pr_err messages. mm/page_alloc_hogger.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index caeb2e5e8579..175f479c487b 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -85,9 +85,12 @@ #include #include +#include +#include #include #include #include +#include static struct dentry *mmdir; @@ -119,20 +122,55 @@ struct page_alloc { struct dentry *alloc_dentry; }; +static struct kmem_cache *req_alloc_cache; +static struct kmem_cache *page_alloc_cache; + static int __init page_alloc_hogger_debugfs_init(void) { + int ret; + + req_alloc_cache = 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\n"); + ret = -ENOMEM; + goto error_exit; + } + + page_alloc_cache = 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\n"); + ret = -ENOMEM; + goto clean_req_alloc_cache; + } + mmdir = debugfs_create_dir("mm", NULL); if (IS_ERR(mmdir)) { pr_err("Unable to create mm directory\n"); - return PTR_ERR(mmdir); + ret = PTR_ERR(mmdir); + goto clean_page_alloc_cache; } return 0; + +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); } module_init(page_alloc_hogger_debugfs_init); -- 2.55.0.629.g250fe7f194-goog