[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250214173017.07b0b250@gandalf.local.home>
Date: Fri, 14 Feb 2025 17:30:17 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: "Masami Hiramatsu (Google)" <mhiramat@...nel.org>, Luis Chamberlain
<mcgrof@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org, Mark
Rutland <mark.rutland@....com>, Mathieu Desnoyers
<mathieu.desnoyers@...icios.com>, Andrew Morton
<akpm@...ux-foundation.org>, Petr Pavlu <petr.pavlu@...e.com>, Sami
Tolvanen <samitolvanen@...gle.com>, Daniel Gomez <da.gomez@...sung.com>,
linux-modules@...r.kernel.org
Subject: Re: [PATCH 5/8] module: Add module_for_each_mod() function
On Thu, 6 Feb 2025 10:27:20 -0500
Steven Rostedt <rostedt@...dmis.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?
-- Steve
Powered by blists - more mailing lists