On Fri, Feb 14, 2025 at 05:30:17PM -0500, Steven Rostedt wrote: > On Thu, 6 Feb 2025 10:27:20 -0500 > Steven Rostedt <rost...@goodmis.org> wrote: > > > > BTW, do we really need to disable preempt or is it enough to call > > > rcu_read_lock()? > > > > Bah, as I expected this function to be changed, I didn't spend too much > > time on looking at its implementation. I just cut and pasted how the other > > loops worked. But yes, it should not be disabling preemption. In fact, I > > think the module code itself should not be disabling preemption! > > > > I'll have to go and look into that. > > It really looks like it requires preempt_disable(), as the code in > kernel/module/main.c has in several places: > > preempt_disable(); > > list_for_each_entry_rcu(mod, &modules, list) { > [..] > } > > preempt_enable(); > > Or > > module_assert_mutex_or_preempt(); > > [..] > > list_for_each_entry_rcu(mod, &modules, list, > lockdep_is_held(&module_mutex)) { > > > So it looks like it either requires preempt_disable or holding the > module_mutex. > > As I need to call this with trace_types_lock held, and there's a place > where trace_types_lock is within a module callback, I don't think it's safe > to take that lock in that loop, otherwise we have the ABBA deadlock. > > Luis, > > Is this patch OK, and also is there any plan to move the module code to > using just rcu_read_lock instead of preempt_disable?
The patch is not OK, you're looking at old code, look at modules-next and as Petr suggested look at Sebastian's recently merged work. git remote add korg-modules git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux.git Luis