From patchwork Fri Jan 2 00:50:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1174 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=1767315122; bh=SjLJTnnLKx1Glp3ioMpZxFLmVmBaOxdYtiAMp6gMBg8=; 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=Q4l9IW8ml62EXNMiSL43sY0d0qStRJQP7Pfo+lZiW2uHinmIBjMRgLFck8h/j83J6 rtF3vfSozrE+nPIZTD5ipcF8BOIiRg33RVIOT5p8QZho8A9se6zcZkxRXz1jajju44 yIy7+yBt28/9KP57KPKTjcAA6ZIoL5SXBba82z0IJ6d3aRdX+iEuI2+Cx7E1flze0j l7f01cCRB3EcT0T9EDjNDaBEPuaxJ/i9uGIhkNeTQYdVDn/VVtw7zHAZDo5qO2iJbN iKbwg6rCo6ytCj+UKhg1MHFH4jNNmm+EvJJ+EazpAYCX3T+b4PAWiw3b6WliyRv9jT omHGkNN2GXszw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1EB6F68313 for ; Thu, 1 Jan 2026 17:52:02 -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 hyDhXKEYRu4E for ; Thu, 1 Jan 2026 17:52:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315122; bh=SjLJTnnLKx1Glp3ioMpZxFLmVmBaOxdYtiAMp6gMBg8=; 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=Q4l9IW8ml62EXNMiSL43sY0d0qStRJQP7Pfo+lZiW2uHinmIBjMRgLFck8h/j83J6 rtF3vfSozrE+nPIZTD5ipcF8BOIiRg33RVIOT5p8QZho8A9se6zcZkxRXz1jajju44 yIy7+yBt28/9KP57KPKTjcAA6ZIoL5SXBba82z0IJ6d3aRdX+iEuI2+Cx7E1flze0j l7f01cCRB3EcT0T9EDjNDaBEPuaxJ/i9uGIhkNeTQYdVDn/VVtw7zHAZDo5qO2iJbN iKbwg6rCo6ytCj+UKhg1MHFH4jNNmm+EvJJ+EazpAYCX3T+b4PAWiw3b6WliyRv9jT omHGkNN2GXszw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0C28F68F56 for ; Thu, 1 Jan 2026 17:52:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315120; bh=CsAgQUSq0yWg1MS+i4ila8gVVAWBe0XPQm4m2CsXCpM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pDFC3lJ7jg/l0v+eQqLSWXe7YBv631Wk3wcECZ6JKJqn/pB+lTel1kg1LB8LuzExn CILgrl/+qacdigezK8cRKJIAV/SsekUtJq0m1/NrnglwIFtSGYZ0Opgb53+PO9qxyn KhgPcCHEsJ4nZk+RWsyVD1DOB6gopGhp0yYSGUt3J8BCAEhYP0vrQSdTm0LyOLAcYk FAbtwPs/hivq1OWL1jOaa999rdm/Dx1CeBtl4gcE6hefS526GYAA9UFOtA6fKfaBL0 skadtWnL4pF/T0i8QElRJvAOTc6qsSxpAWRNI+vpmmkk03Q/tgPiAoTqd1P02iNDp9 NxskFZ0ToVNXQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F03A168FFD; Thu, 1 Jan 2026 17:52: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 ene9YdGqm1hI; Thu, 1 Jan 2026 17:52:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315115; bh=OuBppOfD/GNFY1vPyClOqbYj2pu2mCqFRIjrT2HhGAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z3QG067uT+kuXIXDhNJI6O5OCQBBJAzCFyFl644HCuCr2lMlNhWzmF7a4UVmFD3xv 3v3ZLxN0H+FzcA+eyTZe07h6XEqO9ZTnMZwy76k/R46UXI37aL6zGE2SY+Pzy899mK FrL9prnFFDt9MxCw0M7Ef5sDJj6v5SYzOJr+bA4p0a+80hGEL9A3fcCHhYiBvQfV3q r/BuL6dWBhdjfJz4MCA5mbl//7d3rQOh/N7ndtZk++bqc9RcMYmT61pSQYrnrV/ZSn WRQd8pnkvHywZpJ7CyABIlDSCc1WJIHwb4uA6yGhG0/4bQiHaobe7m3cO/tiHzeIbe IM+aRrTGhoNrg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D7C4868313; Thu, 1 Jan 2026 17:51:54 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:40 -0700 Message-ID: <20260102005112.552256-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: GQISEFPEWN5VR2NTL4DNOWJN7NY4NIX7 X-Message-ID-Hash: GQISEFPEWN5VR2NTL4DNOWJN7NY4NIX7 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 v2 10/30] 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 --- (no changes since v1) 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); -}