From: Simon Glass <simon.glass@canonical.com> U-Boot does not have memory pressure or reclaim infrastructure. The ext4l filesystem uses shrinker structures which are currently defined in ext4_uboot.h. Create a new linux/shrinker.h header file with stub implementations to better match the Linux kernel structure. Types and functions moved: - struct shrink_control - struct shrinker - shrinker_alloc() - shrinker_register() - shrinker_free() Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 32 +--------------- include/linux/shrinker.h | 83 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 30 deletions(-) create mode 100644 include/linux/shrinker.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 47236e63911..d04a843175b 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -992,36 +992,8 @@ static inline int in_range(unsigned long val, unsigned long start, /* extents_status.c stubs */ -/* shrinker - memory reclaim infrastructure (stub for U-Boot) */ -struct shrink_control { - gfp_t gfp_mask; - int nid; - unsigned long nr_to_scan; - unsigned long nr_scanned; -}; - -struct shrinker { - unsigned long (*count_objects)(struct shrinker *, struct shrink_control *); - unsigned long (*scan_objects)(struct shrinker *, struct shrink_control *); - void *private_data; -}; - -static inline struct shrinker *shrinker_alloc(unsigned int flags, - const char *fmt, ...) -{ - /* Return static dummy - U-Boot doesn't need memory reclamation */ - static struct shrinker dummy_shrinker; - - return &dummy_shrinker; -} - -static inline void shrinker_register(struct shrinker *s) -{ -} - -static inline void shrinker_free(struct shrinker *s) -{ -} +/* shrinker - use linux/shrinker.h */ +#include <linux/shrinker.h> /* ktime functions - use linux/ktime.h */ #include <linux/ktime.h> diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h new file mode 100644 index 00000000000..b95df9d6dc9 --- /dev/null +++ b/include/linux/shrinker.h @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Shrinker interface stub for U-Boot + * + * U-Boot doesn't have memory pressure or reclaim, so these are stubs. + */ +#ifndef _LINUX_SHRINKER_H +#define _LINUX_SHRINKER_H + +#include <linux/types.h> + +/** + * struct shrink_control - control structure for shrinker callbacks + * @gfp_mask: allocation flags + * @nid: NUMA node being shrunk + * @nr_to_scan: number of objects to scan + * @nr_scanned: number of objects scanned + * + * Stub for U-Boot - memory reclaim is not needed. + */ +struct shrink_control { + gfp_t gfp_mask; + int nid; + unsigned long nr_to_scan; + unsigned long nr_scanned; +}; + +struct shrinker; + +/** + * struct shrinker - memory reclaim callback structure + * @count_objects: callback to count freeable objects + * @scan_objects: callback to scan and free objects + * @private_data: private data for the shrinker + * + * Stub for U-Boot - memory reclaim is not needed. + */ +struct shrinker { + unsigned long (*count_objects)(struct shrinker *, + struct shrink_control *); + unsigned long (*scan_objects)(struct shrinker *, + struct shrink_control *); + void *private_data; +}; + +/** + * shrinker_alloc() - allocate a shrinker structure + * @flags: shrinker flags + * @fmt: format string for name (unused) + * + * U-Boot stub - returns a static dummy shrinker. + * + * Return: pointer to dummy shrinker + */ +static inline struct shrinker *shrinker_alloc(unsigned int flags, + const char *fmt, ...) +{ + static struct shrinker dummy_shrinker; + + return &dummy_shrinker; +} + +/** + * shrinker_register() - register a shrinker + * @s: shrinker to register + * + * U-Boot stub - no-op. + */ +static inline void shrinker_register(struct shrinker *s) +{ +} + +/** + * shrinker_free() - free a shrinker + * @s: shrinker to free + * + * U-Boot stub - no-op. + */ +static inline void shrinker_free(struct shrinker *s) +{ +} + +#endif /* _LINUX_SHRINKER_H */ -- 2.43.0