* [PATCH v3 5/8] module: Add module_for_each_mod() function [not found] <20250304012516.282694507@goodmis.org> @ 2025-03-04 1:25 ` Steven Rostedt 2025-03-04 14:57 ` Steven Rostedt 0 siblings, 1 reply; 4+ messages in thread From: Steven Rostedt @ 2025-03-04 1:25 UTC (permalink / raw) To: linux-kernel, linux-trace-kernel Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton, Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez, linux-modules From: Steven Rostedt <rostedt@goodmis.org> The tracing system needs a way to save all the currently loaded modules and their addresses into persistent memory so that it can evaluate the addresses on a reboot from a crash. When the persistent memory trace starts, it will load the module addresses and names into the persistent memory. To do so, it will call the module_for_each_mod() function and pass it a function and data structure to get called on each loaded module. Then it can record the memory. This only implements that function. Cc: Luis Chamberlain <mcgrof@kernel.org> Cc: Petr Pavlu <petr.pavlu@suse.com> Cc: Sami Tolvanen <samitolvanen@google.com> Cc: Daniel Gomez <da.gomez@samsung.com> Cc: linux-modules@vger.kernel.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- Changes since v2: https://lore.kernel.org/20250215034404.902259250@goodmis.org - Use RCU guard instead of disabling preemption include/linux/module.h | 6 ++++++ kernel/module/main.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/module.h b/include/linux/module.h index 30e5b19bafa9..9a71dd2cb11f 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -782,6 +782,8 @@ static inline void *module_writable_address(struct module *mod, void *loc) return __module_writable_address(mod, loc); } +void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data); + #else /* !CONFIG_MODULES... */ static inline struct module *__module_address(unsigned long addr) @@ -894,6 +896,10 @@ static inline void *module_writable_address(struct module *mod, void *loc) { return loc; } + +static inline void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data) +{ +} #endif /* CONFIG_MODULES */ #ifdef CONFIG_SYSFS diff --git a/kernel/module/main.c b/kernel/module/main.c index 1fb9ad289a6f..927a2e0ffd5f 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -3809,6 +3809,19 @@ bool is_module_text_address(unsigned long addr) return ret; } +void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data) +{ + struct module *mod; + + guard(rcu)(); + list_for_each_entry_rcu(mod, &modules, list) { + if (mod->state == MODULE_STATE_UNFORMED) + continue; + if (func(mod, data)) + break; + } +} + /** * __module_text_address() - get the module whose code contains an address. * @addr: the address. -- 2.47.2 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 5/8] module: Add module_for_each_mod() function 2025-03-04 1:25 ` [PATCH v3 5/8] module: Add module_for_each_mod() function Steven Rostedt @ 2025-03-04 14:57 ` Steven Rostedt 2025-03-05 8:47 ` Petr Pavlu 0 siblings, 1 reply; 4+ messages in thread From: Steven Rostedt @ 2025-03-04 14:57 UTC (permalink / raw) To: Luis Chamberlain Cc: linux-kernel, linux-trace-kernel, Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton, Petr Pavlu, Sami Tolvanen, Daniel Gomez, linux-modules Luis, Can I get an Acked-by from you? This follows the changes you have in linux-next. Thanks, -- Steve On Mon, 03 Mar 2025 20:25:21 -0500 Steven Rostedt <rostedt@goodmis.org> wrote: > From: Steven Rostedt <rostedt@goodmis.org> > > The tracing system needs a way to save all the currently loaded modules > and their addresses into persistent memory so that it can evaluate the > addresses on a reboot from a crash. When the persistent memory trace > starts, it will load the module addresses and names into the persistent > memory. To do so, it will call the module_for_each_mod() function and pass > it a function and data structure to get called on each loaded module. Then > it can record the memory. > > This only implements that function. > > Cc: Luis Chamberlain <mcgrof@kernel.org> > Cc: Petr Pavlu <petr.pavlu@suse.com> > Cc: Sami Tolvanen <samitolvanen@google.com> > Cc: Daniel Gomez <da.gomez@samsung.com> > Cc: linux-modules@vger.kernel.org > Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> > --- > Changes since v2: https://lore.kernel.org/20250215034404.902259250@goodmis.org > > - Use RCU guard instead of disabling preemption > > include/linux/module.h | 6 ++++++ > kernel/module/main.c | 13 +++++++++++++ > 2 files changed, 19 insertions(+) > > diff --git a/include/linux/module.h b/include/linux/module.h > index 30e5b19bafa9..9a71dd2cb11f 100644 > --- a/include/linux/module.h > +++ b/include/linux/module.h > @@ -782,6 +782,8 @@ static inline void *module_writable_address(struct module *mod, void *loc) > return __module_writable_address(mod, loc); > } > > +void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data); > + > #else /* !CONFIG_MODULES... */ > > static inline struct module *__module_address(unsigned long addr) > @@ -894,6 +896,10 @@ static inline void *module_writable_address(struct module *mod, void *loc) > { > return loc; > } > + > +static inline void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data) > +{ > +} > #endif /* CONFIG_MODULES */ > > #ifdef CONFIG_SYSFS > diff --git a/kernel/module/main.c b/kernel/module/main.c > index 1fb9ad289a6f..927a2e0ffd5f 100644 > --- a/kernel/module/main.c > +++ b/kernel/module/main.c > @@ -3809,6 +3809,19 @@ bool is_module_text_address(unsigned long addr) > return ret; > } > > +void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data) > +{ > + struct module *mod; > + > + guard(rcu)(); > + list_for_each_entry_rcu(mod, &modules, list) { > + if (mod->state == MODULE_STATE_UNFORMED) > + continue; > + if (func(mod, data)) > + break; > + } > +} > + > /** > * __module_text_address() - get the module whose code contains an address. > * @addr: the address. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 5/8] module: Add module_for_each_mod() function 2025-03-04 14:57 ` Steven Rostedt @ 2025-03-05 8:47 ` Petr Pavlu 2025-03-05 15:21 ` Steven Rostedt 0 siblings, 1 reply; 4+ messages in thread From: Petr Pavlu @ 2025-03-05 8:47 UTC (permalink / raw) To: Steven Rostedt, Luis Chamberlain Cc: linux-kernel, linux-trace-kernel, Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton, Sami Tolvanen, Daniel Gomez, linux-modules On 3/4/25 15:57, Steven Rostedt wrote: > > Luis, > > Can I get an Acked-by from you? > > This follows the changes you have in linux-next. Hi Steven, I'm not Luis, but we started rotating the modules maintenance every six months and I'm currently looking after the modules tree. I see Luis seemed ok with the change in the previous discussion and the patch looks reasonable to me. Acked-by: Petr Pavlu <petr.pavlu@suse.com> -- Thanks, Petr > > > > > On Mon, 03 Mar 2025 20:25:21 -0500 > Steven Rostedt <rostedt@goodmis.org> wrote: > >> From: Steven Rostedt <rostedt@goodmis.org> >> >> The tracing system needs a way to save all the currently loaded modules >> and their addresses into persistent memory so that it can evaluate the >> addresses on a reboot from a crash. When the persistent memory trace >> starts, it will load the module addresses and names into the persistent >> memory. To do so, it will call the module_for_each_mod() function and pass >> it a function and data structure to get called on each loaded module. Then >> it can record the memory. >> >> This only implements that function. >> >> Cc: Luis Chamberlain <mcgrof@kernel.org> >> Cc: Petr Pavlu <petr.pavlu@suse.com> >> Cc: Sami Tolvanen <samitolvanen@google.com> >> Cc: Daniel Gomez <da.gomez@samsung.com> >> Cc: linux-modules@vger.kernel.org >> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> >> --- >> Changes since v2: https://lore.kernel.org/20250215034404.902259250@goodmis.org >> >> - Use RCU guard instead of disabling preemption >> >> include/linux/module.h | 6 ++++++ >> kernel/module/main.c | 13 +++++++++++++ >> 2 files changed, 19 insertions(+) >> >> diff --git a/include/linux/module.h b/include/linux/module.h >> index 30e5b19bafa9..9a71dd2cb11f 100644 >> --- a/include/linux/module.h >> +++ b/include/linux/module.h >> @@ -782,6 +782,8 @@ static inline void *module_writable_address(struct module *mod, void *loc) >> return __module_writable_address(mod, loc); >> } >> >> +void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data); >> + >> #else /* !CONFIG_MODULES... */ >> >> static inline struct module *__module_address(unsigned long addr) >> @@ -894,6 +896,10 @@ static inline void *module_writable_address(struct module *mod, void *loc) >> { >> return loc; >> } >> + >> +static inline void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data) >> +{ >> +} >> #endif /* CONFIG_MODULES */ >> >> #ifdef CONFIG_SYSFS >> diff --git a/kernel/module/main.c b/kernel/module/main.c >> index 1fb9ad289a6f..927a2e0ffd5f 100644 >> --- a/kernel/module/main.c >> +++ b/kernel/module/main.c >> @@ -3809,6 +3809,19 @@ bool is_module_text_address(unsigned long addr) >> return ret; >> } >> >> +void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data) >> +{ >> + struct module *mod; >> + >> + guard(rcu)(); >> + list_for_each_entry_rcu(mod, &modules, list) { >> + if (mod->state == MODULE_STATE_UNFORMED) >> + continue; >> + if (func(mod, data)) >> + break; >> + } >> +} >> + >> /** >> * __module_text_address() - get the module whose code contains an address. >> * @addr: the address. > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 5/8] module: Add module_for_each_mod() function 2025-03-05 8:47 ` Petr Pavlu @ 2025-03-05 15:21 ` Steven Rostedt 0 siblings, 0 replies; 4+ messages in thread From: Steven Rostedt @ 2025-03-05 15:21 UTC (permalink / raw) To: Petr Pavlu Cc: Luis Chamberlain, linux-kernel, linux-trace-kernel, Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton, Sami Tolvanen, Daniel Gomez, linux-modules On Wed, 5 Mar 2025 09:47:49 +0100 Petr Pavlu <petr.pavlu@suse.com> wrote: > On 3/4/25 15:57, Steven Rostedt wrote: > > > > Luis, > > > > Can I get an Acked-by from you? > > > > This follows the changes you have in linux-next. > > Hi Steven, > > I'm not Luis, but we started rotating the modules maintenance every six > months and I'm currently looking after the modules tree. I see Luis > seemed ok with the change in the previous discussion and the patch looks > reasonable to me. Ah, you may want to update the MAINTAINERS file. Right now it has: M: Luis Chamberlain <mcgrof@kernel.org> R: Petr Pavlu <petr.pavlu@suse.com> R: Sami Tolvanen <samitolvanen@google.com> R: Daniel Gomez <da.gomez@samsung.com> Which puts Luis as maintainer and you as a reviewer. If you rotate maintainerships, you should update that to have an M: next to all that are in that rotation. > > Acked-by: Petr Pavlu <petr.pavlu@suse.com> > Appreciate it. -- Steve ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-05 15:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250304012516.282694507@goodmis.org>
2025-03-04 1:25 ` [PATCH v3 5/8] module: Add module_for_each_mod() function Steven Rostedt
2025-03-04 14:57 ` Steven Rostedt
2025-03-05 8:47 ` Petr Pavlu
2025-03-05 15:21 ` Steven Rostedt
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).