* Re: [PATCH 04/13] module: use RCU to synchronize find_module
[not found] ` <20210128181421.2279-5-hch@lst.de>
@ 2021-01-28 20:50 ` Thiago Jung Bauermann
[not found] ` <alpine.LSU.2.21.2101291626080.22237@pobox.suse.cz>
1 sibling, 0 replies; 7+ messages in thread
From: Thiago Jung Bauermann @ 2021-01-28 20:50 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Petr Mladek, Jiri Kosina, Andrew Donnellan, linux-kbuild,
David Airlie, Masahiro Yamada, Josh Poimboeuf, linux-kernel,
live-patching, Michal Marek, Joe Lawrence, dri-devel,
Thomas Zimmermann, Jessica Yu, Frederic Barrat, Miroslav Benes,
linuxppc-dev
Hi Christoph,
Christoph Hellwig <hch@lst.de> writes:
> diff --git a/kernel/module.c b/kernel/module.c
> index 981302f616b411..6772fb2680eb3e 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -668,7 +668,6 @@ static struct module *find_module_all(const char *name, size_t len,
>
> struct module *find_module(const char *name)
> {
> - module_assert_mutex();
Does it make sense to replace the assert above with the warn below (untested)?
RCU_LOCKDEP_WARN(rcu_read_lock_sched_held());
> return find_module_all(name, strlen(name), false);
> }
--
Thiago Jung Bauermann
IBM Linux Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 04/13] module: use RCU to synchronize find_module
[not found] ` <alpine.LSU.2.21.2101291626080.22237@pobox.suse.cz>
@ 2021-02-01 12:10 ` Jessica Yu
2021-02-01 13:16 ` Miroslav Benes
0 siblings, 1 reply; 7+ messages in thread
From: Jessica Yu @ 2021-02-01 12:10 UTC (permalink / raw)
To: Miroslav Benes
Cc: Petr Mladek, Joe Lawrence, Andrew Donnellan, linux-kbuild,
David Airlie, Masahiro Yamada, Jiri Kosina, linux-kernel,
live-patching, Michal Marek, dri-devel, Thomas Zimmermann,
Josh Poimboeuf, Frederic Barrat, linuxppc-dev, Christoph Hellwig
+++ Miroslav Benes [29/01/21 16:29 +0100]:
>On Thu, 28 Jan 2021, Christoph Hellwig wrote:
>
>> Allow for a RCU-sched critical section around find_module, following
>> the lower level find_module_all helper, and switch the two callers
>> outside of module.c to use such a RCU-sched critical section instead
>> of module_mutex.
>
>That's a nice idea.
>
>> @@ -57,7 +58,7 @@ static void klp_find_object_module(struct klp_object *obj)
>> if (!klp_is_module(obj))
>> return;
>>
>> - mutex_lock(&module_mutex);
>> + rcu_read_lock_sched();
>> /*
>> * We do not want to block removal of patched modules and therefore
>> * we do not take a reference here. The patches are removed by
>> @@ -74,7 +75,7 @@ static void klp_find_object_module(struct klp_object *obj)
>> if (mod && mod->klp_alive)
>
>RCU always baffles me a bit, so I'll ask. Don't we need
>rcu_dereference_sched() here? "mod" comes from a RCU-protected list, so I
>wonder.
Same here :-) I had to double check the RCU documentation. For our
modules list case I believe the rcu list API should take care of that
for us. Worth noting is this snippet from Documentation/RCU/whatisRCU.txt:
rcu_dereference() is typically used indirectly, via the _rcu
list-manipulation primitives, such as list_for_each_entry_rcu()
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 04/13] module: use RCU to synchronize find_module
2021-02-01 12:10 ` Jessica Yu
@ 2021-02-01 13:16 ` Miroslav Benes
0 siblings, 0 replies; 7+ messages in thread
From: Miroslav Benes @ 2021-02-01 13:16 UTC (permalink / raw)
To: Jessica Yu
Cc: Petr Mladek, Joe Lawrence, Andrew Donnellan, linux-kbuild,
David Airlie, Masahiro Yamada, Jiri Kosina, linux-kernel,
live-patching, Michal Marek, dri-devel, Thomas Zimmermann,
Josh Poimboeuf, Frederic Barrat, linuxppc-dev, Christoph Hellwig
On Mon, 1 Feb 2021, Jessica Yu wrote:
> +++ Miroslav Benes [29/01/21 16:29 +0100]:
> >On Thu, 28 Jan 2021, Christoph Hellwig wrote:
> >
> >> Allow for a RCU-sched critical section around find_module, following
> >> the lower level find_module_all helper, and switch the two callers
> >> outside of module.c to use such a RCU-sched critical section instead
> >> of module_mutex.
> >
> >That's a nice idea.
> >
> >> @@ -57,7 +58,7 @@ static void klp_find_object_module(struct klp_object
> >> *obj)
> >> if (!klp_is_module(obj))
> >> return;
> >>
> >> - mutex_lock(&module_mutex);
> >> + rcu_read_lock_sched();
> >> /*
> >> * We do not want to block removal of patched modules and therefore
> >> * we do not take a reference here. The patches are removed by
> >> @@ -74,7 +75,7 @@ static void klp_find_object_module(struct klp_object
> >> *obj)
> >> if (mod && mod->klp_alive)
> >
> >RCU always baffles me a bit, so I'll ask. Don't we need
> >rcu_dereference_sched() here? "mod" comes from a RCU-protected list, so I
> >wonder.
>
> Same here :-) I had to double check the RCU documentation. For our
> modules list case I believe the rcu list API should take care of that
> for us. Worth noting is this snippet from Documentation/RCU/whatisRCU.txt:
>
> rcu_dereference() is typically used indirectly, via the _rcu
> list-manipulation primitives, such as list_for_each_entry_rcu()
Ok, thanks to both for checking and explanation.
Ack to the patch then.
Miroslav
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 05/13] kallsyms: refactor {,module_}kallsyms_on_each_symbol
[not found] ` <20210201114749.GB19696@lst.de>
@ 2021-02-01 13:37 ` Miroslav Benes
[not found] ` <20210201162842.GB7276@lst.de>
0 siblings, 1 reply; 7+ messages in thread
From: Miroslav Benes @ 2021-02-01 13:37 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Petr Mladek, Jiri Kosina, Andrew Donnellan, linux-kbuild,
David Airlie, Masahiro Yamada, Josh Poimboeuf, linux-kernel,
live-patching, Michal Marek, Joe Lawrence, dri-devel,
Thomas Zimmermann, Jessica Yu, Frederic Barrat, linuxppc-dev
On Mon, 1 Feb 2021, Christoph Hellwig wrote:
> On Fri, Jan 29, 2021 at 10:43:36AM +0100, Petr Mladek wrote:
> > > --- a/kernel/livepatch/core.c
> > > +++ b/kernel/livepatch/core.c
> > > @@ -164,12 +164,8 @@ static int klp_find_object_symbol(const char *objname, const char *name,
> > > .pos = sympos,
> > > };
> > >
> > > - mutex_lock(&module_mutex);
> > > - if (objname)
> > > + if (objname || !kallsyms_on_each_symbol(klp_find_callback, &args))
> > > module_kallsyms_on_each_symbol(klp_find_callback, &args);
> > > - else
> > > - kallsyms_on_each_symbol(klp_find_callback, &args);
> > > - mutex_unlock(&module_mutex);
> >
> > This change is not needed. (objname == NULL) means that we are
> > interested only in symbols in "vmlinux".
> >
> > module_kallsyms_on_each_symbol(klp_find_callback, &args)
> > will always fail when objname == NULL.
>
> I just tried to keep the old behavior. I can respin it with your
> recommended change noting the change in behavior, though.
Yes, please. It would be cleaner that way.
Miroslav
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 05/13] kallsyms: refactor {,module_}kallsyms_on_each_symbol
[not found] ` <20210128181421.2279-6-hch@lst.de>
[not found] ` <YBPYyEvesLMrRtZM@alley>
@ 2021-02-01 14:02 ` Miroslav Benes
1 sibling, 0 replies; 7+ messages in thread
From: Miroslav Benes @ 2021-02-01 14:02 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Petr Mladek, Jiri Kosina, Andrew Donnellan, linux-kbuild,
David Airlie, Masahiro Yamada, Josh Poimboeuf, linux-kernel,
live-patching, Michal Marek, Joe Lawrence, dri-devel,
Thomas Zimmermann, Jessica Yu, Frederic Barrat, linuxppc-dev
One more thing...
> @@ -4379,8 +4379,7 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
> unsigned int i;
> int ret;
>
> - module_assert_mutex();
> -
> + mutex_lock(&module_mutex);
> list_for_each_entry(mod, &modules, list) {
> /* We hold module_mutex: no need for rcu_dereference_sched */
> struct mod_kallsyms *kallsyms = mod->kallsyms;
This was the last user of module_assert_mutex(), which can be removed now.
Miroslav
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 05/13] kallsyms: refactor {,module_}kallsyms_on_each_symbol
[not found] ` <20210201162842.GB7276@lst.de>
@ 2021-02-02 10:45 ` Miroslav Benes
0 siblings, 0 replies; 7+ messages in thread
From: Miroslav Benes @ 2021-02-02 10:45 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Petr Mladek, Jiri Kosina, Andrew Donnellan, linux-kbuild,
David Airlie, Masahiro Yamada, Josh Poimboeuf, linux-kernel,
live-patching, Michal Marek, Joe Lawrence, dri-devel,
Thomas Zimmermann, Jessica Yu, Frederic Barrat, linuxppc-dev
On Mon, 1 Feb 2021, Christoph Hellwig wrote:
> On Mon, Feb 01, 2021 at 02:37:12PM +0100, Miroslav Benes wrote:
> > > > This change is not needed. (objname == NULL) means that we are
> > > > interested only in symbols in "vmlinux".
> > > >
> > > > module_kallsyms_on_each_symbol(klp_find_callback, &args)
> > > > will always fail when objname == NULL.
> > >
> > > I just tried to keep the old behavior. I can respin it with your
> > > recommended change noting the change in behavior, though.
> >
> > Yes, please. It would be cleaner that way.
>
> Let me know if this works for you:
>
> ---
> >From 18af41e88d088cfb8680d1669fcae2bc2ede5328 Mon Sep 17 00:00:00 2001
> From: Christoph Hellwig <hch@lst.de>
> Date: Wed, 20 Jan 2021 16:23:16 +0100
> Subject: kallsyms: refactor {,module_}kallsyms_on_each_symbol
>
> Require an explicit call to module_kallsyms_on_each_symbol to look
> for symbols in modules instead of the call from kallsyms_on_each_symbol,
> and acquire module_mutex inside of module_kallsyms_on_each_symbol instead
> of leaving that up to the caller. Note that this slightly changes the
> behavior for the livepatch code in that the symbols from vmlinux are not
> iterated anymore if objname is set, but that actually is the desired
> behavior in this case.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Thanks Christoph
M
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 02/13] drm: remove drm_fb_helper_modinit
[not found] ` <20210128181421.2279-3-hch@lst.de>
@ 2021-02-03 10:34 ` Daniel Vetter
0 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2021-02-03 10:34 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Petr Mladek, Jiri Kosina, Andrew Donnellan, linux-kbuild,
David Airlie, Masahiro Yamada, Josh Poimboeuf, linux-kernel,
live-patching, Michal Marek, Joe Lawrence, dri-devel,
Thomas Zimmermann, Jessica Yu, Frederic Barrat, Miroslav Benes,
linuxppc-dev
On Thu, Jan 28, 2021 at 07:14:10PM +0100, Christoph Hellwig wrote:
> drm_fb_helper_modinit has a lot of boilerplate for what is not very
> simple functionality. Just open code it in the only caller using
> IS_ENABLED and IS_MODULE, and skip the find_module check as a
> request_module is harmless if the module is already loaded (and not
> other caller has this find_module check either).
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Hm I thought I've acked this one already somewhere for merging through
your tree.
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
> drivers/gpu/drm/drm_crtc_helper_internal.h | 10 ---------
> drivers/gpu/drm/drm_fb_helper.c | 21 ------------------
> drivers/gpu/drm/drm_kms_helper_common.c | 25 +++++++++++-----------
> 3 files changed, 12 insertions(+), 44 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_crtc_helper_internal.h b/drivers/gpu/drm/drm_crtc_helper_internal.h
> index 25ce42e799952c..61e09f8a8d0ff0 100644
> --- a/drivers/gpu/drm/drm_crtc_helper_internal.h
> +++ b/drivers/gpu/drm/drm_crtc_helper_internal.h
> @@ -32,16 +32,6 @@
> #include <drm/drm_encoder.h>
> #include <drm/drm_modes.h>
>
> -/* drm_fb_helper.c */
> -#ifdef CONFIG_DRM_FBDEV_EMULATION
> -int drm_fb_helper_modinit(void);
> -#else
> -static inline int drm_fb_helper_modinit(void)
> -{
> - return 0;
> -}
> -#endif
> -
> /* drm_dp_aux_dev.c */
> #ifdef CONFIG_DRM_DP_AUX_CHARDEV
> int drm_dp_aux_dev_init(void);
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 4b81195106875d..0b9f1ae1b7864c 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -2499,24 +2499,3 @@ void drm_fbdev_generic_setup(struct drm_device *dev,
> drm_client_register(&fb_helper->client);
> }
> EXPORT_SYMBOL(drm_fbdev_generic_setup);
> -
> -/* The Kconfig DRM_KMS_HELPER selects FRAMEBUFFER_CONSOLE (if !EXPERT)
> - * but the module doesn't depend on any fb console symbols. At least
> - * attempt to load fbcon to avoid leaving the system without a usable console.
> - */
> -int __init drm_fb_helper_modinit(void)
> -{
> -#if defined(CONFIG_FRAMEBUFFER_CONSOLE_MODULE) && !defined(CONFIG_EXPERT)
> - const char name[] = "fbcon";
> - struct module *fbcon;
> -
> - mutex_lock(&module_mutex);
> - fbcon = find_module(name);
> - mutex_unlock(&module_mutex);
> -
> - if (!fbcon)
> - request_module_nowait(name);
> -#endif
> - return 0;
> -}
> -EXPORT_SYMBOL(drm_fb_helper_modinit);
> diff --git a/drivers/gpu/drm/drm_kms_helper_common.c b/drivers/gpu/drm/drm_kms_helper_common.c
> index 221a8528c9937a..f933da1656eb52 100644
> --- a/drivers/gpu/drm/drm_kms_helper_common.c
> +++ b/drivers/gpu/drm/drm_kms_helper_common.c
> @@ -64,19 +64,18 @@ MODULE_PARM_DESC(edid_firmware,
>
> static int __init drm_kms_helper_init(void)
> {
> - int ret;
> -
> - /* Call init functions from specific kms helpers here */
> - ret = drm_fb_helper_modinit();
> - if (ret < 0)
> - goto out;
> -
> - ret = drm_dp_aux_dev_init();
> - if (ret < 0)
> - goto out;
> -
> -out:
> - return ret;
> + /*
> + * The Kconfig DRM_KMS_HELPER selects FRAMEBUFFER_CONSOLE (if !EXPERT)
> + * but the module doesn't depend on any fb console symbols. At least
> + * attempt to load fbcon to avoid leaving the system without a usable
> + * console.
> + */
> + if (IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) &&
> + IS_MODULE(CONFIG_FRAMEBUFFER_CONSOLE) &&
> + !IS_ENABLED(CONFIG_EXPERT))
> + request_module_nowait("fbcon");
> +
> + return drm_dp_aux_dev_init();
> }
>
> static void __exit drm_kms_helper_exit(void)
> --
> 2.29.2
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-02-03 10:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20210128181421.2279-1-hch@lst.de>
[not found] ` <20210128181421.2279-5-hch@lst.de>
2021-01-28 20:50 ` [PATCH 04/13] module: use RCU to synchronize find_module Thiago Jung Bauermann
[not found] ` <alpine.LSU.2.21.2101291626080.22237@pobox.suse.cz>
2021-02-01 12:10 ` Jessica Yu
2021-02-01 13:16 ` Miroslav Benes
[not found] ` <20210128181421.2279-6-hch@lst.de>
[not found] ` <YBPYyEvesLMrRtZM@alley>
[not found] ` <20210201114749.GB19696@lst.de>
2021-02-01 13:37 ` [PATCH 05/13] kallsyms: refactor {,module_}kallsyms_on_each_symbol Miroslav Benes
[not found] ` <20210201162842.GB7276@lst.de>
2021-02-02 10:45 ` Miroslav Benes
2021-02-01 14:02 ` Miroslav Benes
[not found] ` <20210128181421.2279-3-hch@lst.de>
2021-02-03 10:34 ` [PATCH 02/13] drm: remove drm_fb_helper_modinit Daniel Vetter
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).