Revert "lib: Add CONFIG_LIB_KMEM_CACHE for full kmem_cache support"
The memory leaks were in fact not coming from the kmem cache, so let's
drop this unnecessary feature.
This reverts commit e63fc511c3.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
@@ -84,30 +84,15 @@ 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_free(struct kmem_cache *cachep, void *obj)
|
||||
{
|
||||
free(obj);
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -117,4 +102,14 @@ static inline void *kmem_cache_zalloc(struct kmem_cache *obj, gfp_t flags)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void kmem_cache_free(struct kmem_cache *cachep, void *obj)
|
||||
{
|
||||
free(obj);
|
||||
}
|
||||
|
||||
static inline void kmem_cache_destroy(struct kmem_cache *cachep)
|
||||
{
|
||||
free(cachep);
|
||||
}
|
||||
|
||||
#endif /* _LINUX_SLAB_H */
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* kmem_cache implementation for U-Boot
|
||||
*
|
||||
* Copyright 2025 Canonical Ltd
|
||||
* Written by Simon Glass <simon.glass@canonical.com>
|
||||
*/
|
||||
|
||||
#include <malloc.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
void kmem_cache_free(struct kmem_cache *cachep, void *obj)
|
||||
{
|
||||
free(obj);
|
||||
}
|
||||
|
||||
void kmem_cache_destroy(struct kmem_cache *cachep)
|
||||
{
|
||||
free(cachep);
|
||||
}
|
||||
Reference in New Issue
Block a user