From patchwork Wed Dec 31 22:29:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1145 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220263; bh=RpPw17NV3vYjfPi/o8622Mf2n0JRjKZFiRJh1EM0H+U=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=PUcuUS8Yq6rCjIwN9iR09VMvkrZIODEb7ujLm7zM/uKCOaI6unZ3q84oM6UWEpyLx SrjgDNuin9kC5ZwI0JjymALQQLtwJjnfHF6Bn6PwPErD1ocbTy2HFv5J+h15/Xf3D4 heRh60v1kH5CWjztplRimQ5mpQctRJeaVuS0wckFeCjinsqhNFB3swU/v11iyvAdiP m4tm4yUP8p2Xdb5bXfXLFnaUac7d45fAdNrjnOCAzxO+AFfM3UBt6lPEegxp3t8fTV 9bKB3MuHmzA5sCkGConKOOXCJ/JhXlx6dNj3Zu44ok6UnXNi64kxhXGt9wBZ82Oq2y h48RVcTiBDlCw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 347FA68FCF for ; Wed, 31 Dec 2025 15:31:03 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id q_JhMUIMgDot for ; Wed, 31 Dec 2025 15:31:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220263; bh=RpPw17NV3vYjfPi/o8622Mf2n0JRjKZFiRJh1EM0H+U=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=PUcuUS8Yq6rCjIwN9iR09VMvkrZIODEb7ujLm7zM/uKCOaI6unZ3q84oM6UWEpyLx SrjgDNuin9kC5ZwI0JjymALQQLtwJjnfHF6Bn6PwPErD1ocbTy2HFv5J+h15/Xf3D4 heRh60v1kH5CWjztplRimQ5mpQctRJeaVuS0wckFeCjinsqhNFB3swU/v11iyvAdiP m4tm4yUP8p2Xdb5bXfXLFnaUac7d45fAdNrjnOCAzxO+AFfM3UBt6lPEegxp3t8fTV 9bKB3MuHmzA5sCkGConKOOXCJ/JhXlx6dNj3Zu44ok6UnXNi64kxhXGt9wBZ82Oq2y h48RVcTiBDlCw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0E76568FC2 for ; Wed, 31 Dec 2025 15:31:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220260; bh=JV3IJ4ccGhErJbmpJPJzoos9OU8dpFtjH/2NJnUIv2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=djA4j7OM9eU2qwgLb8xmCtOIOe3dHATauq24I2V1LB2Sh4p9o6U0Lfth1pM01AlCQ UM+gn8pgIRt7c7xMj08aJ1jZuh6UNEgZb7pioZZt+D1QPACkgW63VvruKuQ1fgsjKK 9ObQVZgSPSZYKCiqwHx8moPsrfFOqf0mo5hsPA4O/4uDbYsfeRkyRFiSTe0VSusKxj isPHduY92CzjXdLXD1hOLn2VLmh4Wlv4124EZQ+iI9vSV4YaZGfZrq+Tk0C3pweD0W kH61ilEdAVFGQCv95bz0aKaFnH/oh6pFvO43jnQdMPO2v9zT+rpAoZp8emtsSZGYZ/ laD3yBJpN8sRA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 52DDE68C5D; Wed, 31 Dec 2025 15:31:00 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id aEd-J_pvRdgh; Wed, 31 Dec 2025 15:31:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220256; bh=gLIYM+OEpj4SvZJef/yw5UDI5cPfjTVM4IZFkzewuig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FROqDo8wyYhO2Z76jqoibQLzIhPb95gVUtF8sJLCuxtkcgsPynpPkornpHk0L1vVV 50TQqghbXahXC5T3Kqd2De+1SVI7pRNNun4+R3NqcOMDB8I8ZBzcquG2YCSxKAXsje p/tlc4ArTQgvJwR3fhZYvbiozM1X2hqqjtFyQXElifm8OPaUtqrnXySrXAb/wAI5SG pGgr1FiUiF5grvYw6PGHB2XpA4/RiWKzkfZ8xL89XJbWFF6BOTarR0s3TYoMbhZV4f g5NSekv1GO7j8UFaOueXXZCRQr4AUZ9XueutCtZmUwVkf6/REabKeRWNF2jpRRGKgB 3yKABvWPFrPBA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D5CBD68F65; Wed, 31 Dec 2025 15:30:55 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 31 Dec 2025 15:29:40 -0700 Message-ID: <20251231223008.3251711-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251231223008.3251711-1-sjg@u-boot.org> References: <20251231223008.3251711-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 42I6NFR76LEGPFKNTGLDJHYWK5D3FEIK X-Message-ID-Hash: 42I6NFR76LEGPFKNTGLDJHYWK5D3FEIK X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 07/26] Revert "lib: Add CONFIG_LIB_KMEM_CACHE for full kmem_cache support" List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The memory leaks were in fact not coming from the kmem cache, so let's drop this unnecessary feature. This reverts commit e63fc511c3dadbc99b53611cea304bc2bb565888. Signed-off-by: Simon Glass --- include/linux/slab.h | 27 +++++++++++---------------- lib/Kconfig | 8 -------- lib/Makefile | 1 - lib/kmem_cache.c | 20 -------------------- 4 files changed, 11 insertions(+), 45 deletions(-) delete mode 100644 lib/kmem_cache.c diff --git a/include/linux/slab.h b/include/linux/slab.h index caaaa3d9e16..2b374641534 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -84,19 +84,24 @@ static inline void *krealloc(const void *p, size_t new_size, gfp_t flags) void *kmemdup(const void *src, size_t len, gfp_t gfp); -/* kmem_cache implementation / stubs */ +/* kmem_cache stubs */ struct kmem_cache { int sz; }; struct kmem_cache *get_mem(int element_sz); -#define kmem_cache_create(a, sz, c, d, e) get_mem(sz) +#define kmem_cache_create(a, sz, c, d, e) ({ (void)(a); (void)(e); get_mem(sz); }) void *kmem_cache_alloc(struct kmem_cache *obj, gfp_t flag); -#if CONFIG_IS_ENABLED(LIB_KMEM_CACHE) -void kmem_cache_free(struct kmem_cache *cachep, void *obj); -void kmem_cache_destroy(struct kmem_cache *cachep); -#else +static inline void *kmem_cache_zalloc(struct kmem_cache *obj, gfp_t flags) +{ + void *ret = kmem_cache_alloc(obj, flags); + + if (ret) + memset(ret, 0, obj->sz); + return ret; +} + static inline void kmem_cache_free(struct kmem_cache *cachep, void *obj) { free(obj); @@ -106,15 +111,5 @@ static inline void kmem_cache_destroy(struct kmem_cache *cachep) { free(cachep); } -#endif - -static inline void *kmem_cache_zalloc(struct kmem_cache *obj, gfp_t flags) -{ - void *ret = kmem_cache_alloc(obj, flags); - - if (ret) - memset(ret, 0, obj->sz); - return ret; -} #endif /* _LINUX_SLAB_H */ diff --git a/lib/Kconfig b/lib/Kconfig index 5ddf8125766..9c7eb27c392 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -396,14 +396,6 @@ config TPL_TINY_MEMSET config RBTREE bool -config LIB_KMEM_CACHE - bool "Enable full kmem_cache implementation" - help - Provide a proper kmem_cache implementation in lib/linux_compat.c - that tracks allocated objects. This is needed by subsystems like - ext4 that require cache management. When disabled, simple inline - stubs are used instead. - config BITREVERSE bool "Bit reverse library from Linux" diff --git a/lib/Makefile b/lib/Makefile index 3890a827d1c..e770c273a8c 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -136,7 +136,6 @@ obj-$(CONFIG_$(PHASE_)OF_LIBFDT) += fdtdec.o fdtdec_common.o fdt_print.o obj-y += hang.o obj-y += linux_compat.o obj-y += linux_string.o -obj-$(CONFIG_$(PHASE_)LIB_KMEM_CACHE) += kmem_cache.o obj-$(CONFIG_$(PHASE_)LMB) += lmb.o obj-y += membuf.o obj-$(CONFIG_REGEX) += slre.o diff --git a/lib/kmem_cache.c b/lib/kmem_cache.c deleted file mode 100644 index bff9329aa53..00000000000 --- a/lib/kmem_cache.c +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * kmem_cache implementation for U-Boot - * - * Copyright 2025 Canonical Ltd - * Written by Simon Glass - */ - -#include -#include - -void kmem_cache_free(struct kmem_cache *cachep, void *obj) -{ - free(obj); -} - -void kmem_cache_destroy(struct kmem_cache *cachep) -{ - free(cachep); -}