Mailing List Archive

[PATCH RFC V4 10/10] jump-label: initialize jump-label subsystem much earlier
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

Initialize jump_labels much earlier, we can use them.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
include/linux/jump_label.h | 14 +++++++++-----
init/main.c | 1 +
kernel/jump_label.c | 5 +----
3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 56594e4..388b0d4 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -16,7 +16,7 @@ struct jump_label_key {

# include <asm/jump_label.h>
# define HAVE_JUMP_LABEL
-#endif
+#endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */

enum jump_label_type {
JUMP_LABEL_DISABLE = 0,
@@ -41,6 +41,7 @@ static __always_inline bool static_branch(struct jump_label_key *key)
extern struct jump_entry __start___jump_table[];
extern struct jump_entry __stop___jump_table[];

+extern void jump_label_init(void);
extern void jump_label_lock(void);
extern void jump_label_unlock(void);
extern void arch_jump_label_transform(struct jump_entry *entry,
@@ -53,7 +54,7 @@ extern void jump_label_dec(struct jump_label_key *key);
extern bool jump_label_enabled(struct jump_label_key *key);
extern void jump_label_apply_nops(struct module *mod);

-#else
+#else /* !HAVE_JUMP_LABEL */

#include <linux/atomic.h>

@@ -63,6 +64,10 @@ struct jump_label_key {
atomic_t enabled;
};

+static __always_inline void jump_label_init(void)
+{
+}
+
static __always_inline bool static_branch(struct jump_label_key *key)
{
if (unlikely(atomic_read(&key->enabled)))
@@ -97,7 +102,6 @@ static inline int jump_label_apply_nops(struct module *mod)
{
return 0;
}
+#endif /* HAVE_JUMP_LABEL */

-#endif
-
-#endif
+#endif /* _LINUX_JUMP_LABEL_H */
diff --git a/init/main.c b/init/main.c
index 2a9b88a..f4094ed 100644
--- a/init/main.c
+++ b/init/main.c
@@ -637,6 +637,7 @@ asmlinkage void __init start_kernel(void)
acpi_early_init(); /* before LAPIC and SMP init */
sfi_init_late();

+ jump_label_init();
ftrace_init();

/* Do the rest non-__init'ed, we're now alive */
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index ff2028f..bbdfe2a 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -133,7 +133,7 @@ static void __jump_label_update(struct jump_label_key *key,
}
}

-static __init int jump_label_init(void)
+void __init jump_label_init(void)
{
struct jump_entry *iter_start = __start___jump_table;
struct jump_entry *iter_stop = __stop___jump_table;
@@ -159,10 +159,7 @@ static __init int jump_label_init(void)
#endif
}
jump_label_unlock();
-
- return 0;
}
-early_initcall(jump_label_init);

#ifdef CONFIG_MODULES

--
1.7.6.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Re: [PATCH RFC V4 10/10] jump-label: initialize jump-label subsystem much earlier [ In reply to ]
On Wed, 2011-10-12 at 17:08 -0700, Jeremy Fitzhardinge wrote:
> From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
>
> Initialize jump_labels much earlier, we can use them.

We can use them, where? how? what?, that sentence just begs for more.

> diff --git a/init/main.c b/init/main.c
> index 2a9b88a..f4094ed 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -637,6 +637,7 @@ asmlinkage void __init start_kernel(void)
> acpi_early_init(); /* before LAPIC and SMP init */
> sfi_init_late();
>
> + jump_label_init();
> ftrace_init();
>
> /* Do the rest non-__init'ed, we're now alive */

Can we push them much earlier still? If possible I'd like them to be
before sched_init() so that I might use them there, if not possible, at
the very least before enabling interrupts would be nice.



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Re: [PATCH RFC V4 10/10] jump-label: initialize jump-label subsystem much earlier [ In reply to ]
On Thu, Oct 13, 2011 at 12:43:48PM +0200, Peter Zijlstra wrote:
> On Wed, 2011-10-12 at 17:08 -0700, Jeremy Fitzhardinge wrote:
> > From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
> >
> > Initialize jump_labels much earlier, we can use them.
>
> We can use them, where? how? what?, that sentence just begs for more.
>
> > diff --git a/init/main.c b/init/main.c
> > index 2a9b88a..f4094ed 100644
> > --- a/init/main.c
> > +++ b/init/main.c
> > @@ -637,6 +637,7 @@ asmlinkage void __init start_kernel(void)
> > acpi_early_init(); /* before LAPIC and SMP init */
> > sfi_init_late();
> >
> > + jump_label_init();
> > ftrace_init();
> >
> > /* Do the rest non-__init'ed, we're now alive */
>
> Can we push them much earlier still? If possible I'd like them to be
> before sched_init() so that I might use them there, if not possible, at
> the very least before enabling interrupts would be nice.
>
>

Yes, earlier still would be good. Also, it still bothers me a bit that
jump_label_inc()/dec() could be called and the branch not updated until
the jump label initialization. I feel like there should be a WARN() for
this case...ie:

jump_label_inc()/dec() {
if (!jump_label_initialized)
WARN("calling branch update before subsystem initialization");
}






_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Re: [PATCH RFC V4 10/10] jump-label: initialize jump-label subsystem much earlier [ In reply to ]
On 10/13/2011 03:43 AM, Peter Zijlstra wrote:
> On Wed, 2011-10-12 at 17:08 -0700, Jeremy Fitzhardinge wrote:
>> From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
>>
>> Initialize jump_labels much earlier, we can use them.
> We can use them, where? how? what?, that sentence just begs for more.

Er, yeah, looks like I committed it without actually finishing the sentence.

J

>> diff --git a/init/main.c b/init/main.c
>> index 2a9b88a..f4094ed 100644
>> --- a/init/main.c
>> +++ b/init/main.c
>> @@ -637,6 +637,7 @@ asmlinkage void __init start_kernel(void)
>> acpi_early_init(); /* before LAPIC and SMP init */
>> sfi_init_late();
>>
>> + jump_label_init();
>> ftrace_init();
>>
>> /* Do the rest non-__init'ed, we're now alive */
> Can we push them much earlier still? If possible I'd like them to be
> before sched_init() so that I might use them there, if not possible, at
> the very least before enabling interrupts would be nice.
>
>


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Re: [PATCH RFC V4 10/10] jump-label: initialize jump-label subsystem much earlier [ In reply to ]
On 10/13/2011 03:43 AM, Peter Zijlstra wrote:
> On Wed, 2011-10-12 at 17:08 -0700, Jeremy Fitzhardinge wrote:
>> From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
>>
>> Initialize jump_labels much earlier, we can use them.
> We can use them, where? how? what?, that sentence just begs for more.

How about this? Proper comment and much earlier init.

J

>From 62720522d512ffce8f4be9140f73fefbdfd2872e Mon Sep 17 00:00:00 2001
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Date: Wed, 12 Oct 2011 16:17:54 -0700
Subject: [PATCH] jump-label: initialize jump-label subsystem much earlier

Initialize jump_labels much, much earlier, so they're available for use
during system setup.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 56594e4..388b0d4 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -16,7 +16,7 @@ struct jump_label_key {

# include <asm/jump_label.h>
# define HAVE_JUMP_LABEL
-#endif
+#endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */

enum jump_label_type {
JUMP_LABEL_DISABLE = 0,
@@ -41,6 +41,7 @@ static __always_inline bool static_branch(struct jump_label_key *key)
extern struct jump_entry __start___jump_table[];
extern struct jump_entry __stop___jump_table[];

+extern void jump_label_init(void);
extern void jump_label_lock(void);
extern void jump_label_unlock(void);
extern void arch_jump_label_transform(struct jump_entry *entry,
@@ -53,7 +54,7 @@ extern void jump_label_dec(struct jump_label_key *key);
extern bool jump_label_enabled(struct jump_label_key *key);
extern void jump_label_apply_nops(struct module *mod);

-#else
+#else /* !HAVE_JUMP_LABEL */

#include <linux/atomic.h>

@@ -63,6 +64,10 @@ struct jump_label_key {
atomic_t enabled;
};

+static __always_inline void jump_label_init(void)
+{
+}
+
static __always_inline bool static_branch(struct jump_label_key *key)
{
if (unlikely(atomic_read(&key->enabled)))
@@ -97,7 +102,6 @@ static inline int jump_label_apply_nops(struct module *mod)
{
return 0;
}
+#endif /* HAVE_JUMP_LABEL */

-#endif
-
-#endif
+#endif /* _LINUX_JUMP_LABEL_H */
diff --git a/init/main.c b/init/main.c
index 2a9b88a..29d8d84 100644
--- a/init/main.c
+++ b/init/main.c
@@ -515,6 +515,9 @@ asmlinkage void __init start_kernel(void)
parse_args("Booting kernel", static_command_line, __start___param,
__stop___param - __start___param,
&unknown_bootoption);
+
+ jump_label_init();
+
/*
* These use large bootmem allocations and must precede
* kmem_cache_init()
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index ff2028f..bbdfe2a 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -133,7 +133,7 @@ static void __jump_label_update(struct jump_label_key *key,
}
}

-static __init int jump_label_init(void)
+void __init jump_label_init(void)
{
struct jump_entry *iter_start = __start___jump_table;
struct jump_entry *iter_stop = __stop___jump_table;
@@ -159,10 +159,7 @@ static __init int jump_label_init(void)
#endif
}
jump_label_unlock();
-
- return 0;
}
-early_initcall(jump_label_init);

#ifdef CONFIG_MODULES




_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Re: [PATCH RFC V4 10/10] jump-label: initialize jump-label subsystem much earlier [ In reply to ]
On Fri, 2011-10-14 at 14:51 -0700, Jeremy Fitzhardinge wrote:
> How about this? Proper comment and much earlier init.

Looks good to me, thanks!

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Re: [PATCH RFC V4 10/10] jump-label: initialize jump-label subsystem much earlier [ In reply to ]
On 10/15/2011 01:42 AM, Peter Zijlstra wrote:
> On Fri, 2011-10-14 at 14:51 -0700, Jeremy Fitzhardinge wrote:
>> How about this? Proper comment and much earlier init.
> Looks good to me, thanks!

Should I take that as an ACK on the series?

J

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Re: [PATCH RFC V4 10/10] jump-label: initialize jump-label subsystem much earlier [ In reply to ]
On Sat, 2011-10-15 at 18:52 -0700, Jeremy Fitzhardinge wrote:
> On 10/15/2011 01:42 AM, Peter Zijlstra wrote:
> > On Fri, 2011-10-14 at 14:51 -0700, Jeremy Fitzhardinge wrote:
> >> How about this? Proper comment and much earlier init.
> > Looks good to me, thanks!
>
> Should I take that as an ACK on the series?

Yes, I don't see any problems with it,

Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Re: [PATCH RFC V4 10/10] jump-label: initialize jump-label subsystem much earlier [ In reply to ]
On 10/18/2011 04:02 AM, Peter Zijlstra wrote:
> On Sat, 2011-10-15 at 18:52 -0700, Jeremy Fitzhardinge wrote:
>> On 10/15/2011 01:42 AM, Peter Zijlstra wrote:
>>> On Fri, 2011-10-14 at 14:51 -0700, Jeremy Fitzhardinge wrote:
>>>> How about this? Proper comment and much earlier init.
>>> Looks good to me, thanks!
>> Should I take that as an ACK on the series?
> Yes, I don't see any problems with it,
>
> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>

How should this go upstream? Should I submit it, or does someone else
want to do it?

Thanks,
J


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel