2011-06-21 02:33:59

by Xiao Guangrong

[permalink] [raw]
Subject: [PATCH v2] jump_label: fix jump_label update

The key of module is out of __stop___jump_table, it causes the events
of modules does not work

Signed-off-by: Xiao Guangrong <[email protected]>
---
kernel/jump_label.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index fa27e75..a8ce450 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -375,15 +375,19 @@ int jump_label_text_reserved(void *start, void *end)

static void jump_label_update(struct jump_label_key *key, int enable)
{
- struct jump_entry *entry = key->entries;
-
- /* if there are no users, entry can be NULL */
- if (entry)
- __jump_label_update(key, entry, __stop___jump_table, enable);
+ struct jump_entry *entry = key->entries, *stop = __stop___jump_table;

#ifdef CONFIG_MODULES
+ struct module *mod = __module_address((jump_label_t)key);
+
__jump_label_mod_update(key, enable);
+
+ if (mod)
+ stop = mod->jump_entries + mod->num_jump_entries;
#endif
+ /* if there are no users, entry can be NULL */
+ if (entry)
+ __jump_label_update(key, entry, stop, enable);
}

#endif
--
1.7.5.4


2011-06-21 09:45:25

by Jiri Olsa

[permalink] [raw]
Subject: Re: [PATCH v2] jump_label: fix jump_label update

On Tue, Jun 21, 2011 at 10:35:55AM +0800, Xiao Guangrong wrote:
> The key of module is out of __stop___jump_table, it causes the events
> of modules does not work
>
> Signed-off-by: Xiao Guangrong <[email protected]>
> ---
> kernel/jump_label.c | 14 +++++++++-----
> 1 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/jump_label.c b/kernel/jump_label.c
> index fa27e75..a8ce450 100644
> --- a/kernel/jump_label.c
> +++ b/kernel/jump_label.c
> @@ -375,15 +375,19 @@ int jump_label_text_reserved(void *start, void *end)
>
> static void jump_label_update(struct jump_label_key *key, int enable)
> {
> - struct jump_entry *entry = key->entries;
> -
> - /* if there are no users, entry can be NULL */
> - if (entry)
> - __jump_label_update(key, entry, __stop___jump_table, enable);
> + struct jump_entry *entry = key->entries, *stop = __stop___jump_table;
>
> #ifdef CONFIG_MODULES
> + struct module *mod = __module_address((jump_label_t)key);
> +
> __jump_label_mod_update(key, enable);
> +
> + if (mod)
> + stop = mod->jump_entries + mod->num_jump_entries;
> #endif
> + /* if there are no users, entry can be NULL */
> + if (entry)
> + __jump_label_update(key, entry, stop, enable);
> }
>
> #endif
> --
> 1.7.5.4

That works for me, but in order to test it I needed to export
jump_label_inc/jump_label_dec functions.

Not sure I'm missing something, but to manage a key that is local
to the module, we need to call jump_label_inc/jump_label_dec
from within the module code, so we need some of the jump_label
functions exported.. it'd be probably:

jump_label_inc/jump_label_dec/jump_label_enabled

wbr,
jirka


I used following module code to test:
---
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/jump_label.h>

static struct jump_label_key key;

static bool enabled;
module_param(enabled, bool, 0644);

static int __init mod_init(void)
{
if (enabled)
jump_label_inc(&key);

if (static_branch(&key))
printk("key enabled\n");
else
printk("key disabled\n");

if (jump_label_enabled(&key))
printk("key enabled1\n");
else
printk("key disabled1\n");

printk("mod loaded\n");
return 0;
}

static void __exit mod_exit(void)
{
printk("mod unloaded\n");
return;
}

module_init(mod_init);
module_exit(mod_exit);
MODULE_LICENSE("GPL");

2011-06-21 15:48:07

by Jason Baron

[permalink] [raw]
Subject: Re: [PATCH v2] jump_label: fix jump_label update

On Tue, Jun 21, 2011 at 10:35:55AM +0800, Xiao Guangrong wrote:
> The key of module is out of __stop___jump_table, it causes the events
> of modules does not work
>
> Signed-off-by: Xiao Guangrong <[email protected]>
> ---
> kernel/jump_label.c | 14 +++++++++-----
> 1 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/jump_label.c b/kernel/jump_label.c
> index fa27e75..a8ce450 100644
> --- a/kernel/jump_label.c
> +++ b/kernel/jump_label.c
> @@ -375,15 +375,19 @@ int jump_label_text_reserved(void *start, void *end)
>
> static void jump_label_update(struct jump_label_key *key, int enable)
> {
> - struct jump_entry *entry = key->entries;
> -
> - /* if there are no users, entry can be NULL */
> - if (entry)
> - __jump_label_update(key, entry, __stop___jump_table, enable);
> + struct jump_entry *entry = key->entries, *stop = __stop___jump_table;
>
> #ifdef CONFIG_MODULES
> + struct module *mod = __module_address((jump_label_t)key);
> +
> __jump_label_mod_update(key, enable);
> +
> + if (mod)
> + stop = mod->jump_entries + mod->num_jump_entries;
> #endif
> + /* if there are no users, entry can be NULL */
> + if (entry)
> + __jump_label_update(key, entry, stop, enable);
> }
>
> #endif
> --
> 1.7.5.4

Looks good. Thanks for the fix!

Acked-by: Jason Baron <[email protected]>

-Jason

2011-06-21 15:48:13

by Jason Baron

[permalink] [raw]
Subject: Re: [PATCH v2] jump_label: fix jump_label update

On Tue, Jun 21, 2011 at 11:44:55AM +0200, Jiri Olsa wrote:
> On Tue, Jun 21, 2011 at 10:35:55AM +0800, Xiao Guangrong wrote:
> > The key of module is out of __stop___jump_table, it causes the events
> > of modules does not work
> >
> > Signed-off-by: Xiao Guangrong <[email protected]>
> > ---
> > kernel/jump_label.c | 14 +++++++++-----
> > 1 files changed, 9 insertions(+), 5 deletions(-)
> >
> > diff --git a/kernel/jump_label.c b/kernel/jump_label.c
> > index fa27e75..a8ce450 100644
> > --- a/kernel/jump_label.c
> > +++ b/kernel/jump_label.c
> > @@ -375,15 +375,19 @@ int jump_label_text_reserved(void *start, void *end)
> >
> > static void jump_label_update(struct jump_label_key *key, int enable)
> > {
> > - struct jump_entry *entry = key->entries;
> > -
> > - /* if there are no users, entry can be NULL */
> > - if (entry)
> > - __jump_label_update(key, entry, __stop___jump_table, enable);
> > + struct jump_entry *entry = key->entries, *stop = __stop___jump_table;
> >
> > #ifdef CONFIG_MODULES
> > + struct module *mod = __module_address((jump_label_t)key);
> > +
> > __jump_label_mod_update(key, enable);
> > +
> > + if (mod)
> > + stop = mod->jump_entries + mod->num_jump_entries;
> > #endif
> > + /* if there are no users, entry can be NULL */
> > + if (entry)
> > + __jump_label_update(key, entry, stop, enable);
> > }
> >
> > #endif
> > --
> > 1.7.5.4
>
> That works for me, but in order to test it I needed to export
> jump_label_inc/jump_label_dec functions.
>
> Not sure I'm missing something, but to manage a key that is local
> to the module, we need to call jump_label_inc/jump_label_dec
> from within the module code, so we need some of the jump_label
> functions exported.. it'd be probably:
>
> jump_label_inc/jump_label_dec/jump_label_enabled
>

You're not missing anything, right now all the enabling/disabling is
done in the core kernel, hence no need for the export. I'd prefer to
keep them non-exported until we had a real use-case that required them
to be exported. But I don't feel that strongly about it.

Thanks,

-Jason

2011-06-23 12:22:45

by Avi Kivity

[permalink] [raw]
Subject: Re: [PATCH v2] jump_label: fix jump_label update

On 06/21/2011 05:35 AM, Xiao Guangrong wrote:
> The key of module is out of __stop___jump_table, it causes the events
> of modules does not work
>

What's the status of this patch? I'm affected by this as well (I'm
guessing the same module is involved). I'm near the end of a bisect,
but there's probably no point given this patch.

--
error compiling committee.c: too many arguments to function

2011-06-23 12:45:32

by Avi Kivity

[permalink] [raw]
Subject: Re: [PATCH v2] jump_label: fix jump_label update

On 06/23/2011 03:22 PM, Avi Kivity wrote:
> On 06/21/2011 05:35 AM, Xiao Guangrong wrote:
>> The key of module is out of __stop___jump_table, it causes the events
>> of modules does not work
>>
>
> What's the status of this patch?

Oh, it's just two days out. Didn't mean to sound impatient.

> I'm affected by this as well (I'm guessing the same module is
> involved). I'm near the end of a bisect, but there's probably no
> point given this patch.
>

I can confirm it fixes my issue.

Tested-by: Avi Kivity <[email protected]>

--
error compiling committee.c: too many arguments to function

2011-06-23 17:44:18

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH v2] jump_label: fix jump_label update

On Thu, 2011-06-23 at 15:45 +0300, Avi Kivity wrote:
> On 06/23/2011 03:22 PM, Avi Kivity wrote:
> > On 06/21/2011 05:35 AM, Xiao Guangrong wrote:
> >> The key of module is out of __stop___jump_table, it causes the events
> >> of modules does not work
> >>
> >
> > What's the status of this patch?
>
> Oh, it's just two days out. Didn't mean to sound impatient.

I've been working on other things than tracing lately.

>
> > I'm affected by this as well (I'm guessing the same module is
> > involved). I'm near the end of a bisect, but there's probably no
> > point given this patch.
> >
>
> I can confirm it fixes my issue.
>
> Tested-by: Avi Kivity <[email protected]>
>

Thanks, I'll queue it up for 3.0 and start my tests on it.

-- Steve