From: Simon Glass <simon.glass@canonical.com> U-Boot is single-threaded, so RCU (Read-Copy-Update) synchronisation is not needed. The ext4l filesystem uses several RCU macros which are currently defined in ext4_uboot.h. Create a new linux/rcupdate.h header file with stub implementations to better match the Linux kernel structure. This reduces duplication and makes ext4_uboot.h smaller. Stubs moved: - rcu_read_lock() / rcu_read_unlock() - rcu_dereference() / rcu_dereference_protected() - rcu_assign_pointer() - call_rcu() - synchronize_rcu() - rcu_barrier() - list_for_each_entry_rcu() - list_del_rcu() / list_add_rcu() / list_add_tail_rcu() Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 21 +++------------- include/linux/rcupdate.h | 54 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 18 deletions(-) create mode 100644 include/linux/rcupdate.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 04872c0a34e..47236e63911 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -357,14 +357,8 @@ int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode, /* Block group lock - stub */ #define bgl_lock_ptr(lock, group) NULL -/* RCU stubs */ -#define rcu_read_lock() do { } while (0) -#define rcu_read_unlock() do { } while (0) -#define rcu_dereference(p) (p) -#define rcu_dereference_protected(p, c) (p) -#define rcu_assign_pointer(p, v) ((p) = (v)) -#define call_rcu(head, func) do { func(head); } while (0) -#define synchronize_rcu() do { } while (0) +/* RCU stubs - use linux/rcupdate.h */ +#include <linux/rcupdate.h> /* RCU head for callbacks - defined in linux/compat.h as callback_head */ @@ -384,9 +378,6 @@ int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode, * implementation - do not stub them! */ -/* RCU barrier - stub */ -#define rcu_barrier() do { } while (0) - /* inode/dentry operations */ void iput(struct inode *inode); @@ -2198,13 +2189,7 @@ static inline unsigned long ext4_find_next_bit_le(const void *addr, /* atomic_sub, atomic64_sub, atomic_dec_and_test are in asm-generic/atomic.h */ -/* RCU list operations - use regular list operations in U-Boot */ -#define list_for_each_entry_rcu(pos, head, member, ...) \ - list_for_each_entry(pos, head, member) -#define list_del_rcu(entry) list_del(entry) -#define list_add_rcu(new, head) list_add(new, head) -#define list_add_tail_rcu(new, head) list_add_tail(new, head) -/* Other RCU stubs are defined earlier in this file */ +/* RCU list operations are in linux/rcupdate.h */ /* raw_cpu_ptr - get pointer to per-CPU data for current CPU */ #define raw_cpu_ptr(ptr) (ptr) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h new file mode 100644 index 00000000000..209e0d4ec8c --- /dev/null +++ b/include/linux/rcupdate.h @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Read-Copy Update mechanism stub for U-Boot + * + * U-Boot is single-threaded, so RCU operations are no-ops. + */ +#ifndef __LINUX_RCUPDATE_H +#define __LINUX_RCUPDATE_H + +#include <linux/list.h> + +/* + * RCU read-side critical section markers - no-ops in single-threaded U-Boot + */ +#define rcu_read_lock() do { } while (0) +#define rcu_read_unlock() do { } while (0) + +/* + * RCU pointer access - just return the pointer directly + */ +#define rcu_dereference(p) (p) +#define rcu_dereference_protected(p, c) (p) +#define rcu_dereference_raw(p) (p) + +/* + * RCU pointer assignment - direct assignment in single-threaded environment + */ +#define rcu_assign_pointer(p, v) ((p) = (v)) + +/* + * RCU callbacks - execute immediately in single-threaded U-Boot + */ +#define call_rcu(head, func) do { func(head); } while (0) + +/* + * Synchronize RCU - no-op since there are no concurrent readers + */ +#define synchronize_rcu() do { } while (0) + +/* + * RCU barrier - wait for all RCU callbacks to complete (no-op in U-Boot) + */ +#define rcu_barrier() do { } while (0) + +/* + * RCU list operations - use regular list operations in single-threaded U-Boot + */ +#define list_for_each_entry_rcu(pos, head, member, ...) \ + list_for_each_entry(pos, head, member) +#define list_del_rcu(entry) list_del(entry) +#define list_add_rcu(new, head) list_add(new, head) +#define list_add_tail_rcu(new, head) list_add_tail(new, head) + +#endif /* __LINUX_RCUPDATE_H */ -- 2.43.0