Message ID | 20221005053234.29312-5-bgray@linux.ibm.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Out-of-line static calls for powerpc64 ELF V2 | expand |
Le 05/10/2022 à 07:32, Benjamin Gray a écrit : > These tests are out-of-line only, so moving them to the > their own file allows them to be run when an arch does > not implement inline static calls. > > Signed-off-by: Benjamin Gray <bgray@linux.ibm.com> > Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu> > --- > kernel/Makefile | 1 + > kernel/static_call_inline.c | 43 ----------------------------------- > kernel/static_call_selftest.c | 41 +++++++++++++++++++++++++++++++++ > 3 files changed, 42 insertions(+), 43 deletions(-) > create mode 100644 kernel/static_call_selftest.c > > diff --git a/kernel/Makefile b/kernel/Makefile > index 318789c728d3..8ce8beaa3cc0 100644 > --- a/kernel/Makefile > +++ b/kernel/Makefile > @@ -113,6 +113,7 @@ obj-$(CONFIG_KCSAN) += kcsan/ > obj-$(CONFIG_SHADOW_CALL_STACK) += scs.o > obj-$(CONFIG_HAVE_STATIC_CALL) += static_call.o > obj-$(CONFIG_HAVE_STATIC_CALL_INLINE) += static_call_inline.o > +obj-$(CONFIG_STATIC_CALL_SELFTEST) += static_call_selftest.o > obj-$(CONFIG_CFI_CLANG) += cfi.o > > obj-$(CONFIG_PERF_EVENTS) += events/ > diff --git a/kernel/static_call_inline.c b/kernel/static_call_inline.c > index dc5665b62814..64d04d054698 100644 > --- a/kernel/static_call_inline.c > +++ b/kernel/static_call_inline.c > @@ -498,46 +498,3 @@ int __init static_call_init(void) > return 0; > } > early_initcall(static_call_init); > - > -#ifdef CONFIG_STATIC_CALL_SELFTEST > - > -static int func_a(int x) > -{ > - return x+1; > -} > - > -static int func_b(int x) > -{ > - return x+2; > -} > - > -DEFINE_STATIC_CALL(sc_selftest, func_a); > - > -static struct static_call_data { > - int (*func)(int); > - int val; > - int expect; > -} static_call_data [] __initdata = { > - { NULL, 2, 3 }, > - { func_b, 2, 4 }, > - { func_a, 2, 3 } > -}; > - > -static int __init test_static_call_init(void) > -{ > - int i; > - > - for (i = 0; i < ARRAY_SIZE(static_call_data); i++ ) { > - struct static_call_data *scd = &static_call_data[i]; > - > - if (scd->func) > - static_call_update(sc_selftest, scd->func); > - > - WARN_ON(static_call(sc_selftest)(scd->val) != scd->expect); > - } > - > - return 0; > -} > -early_initcall(test_static_call_init); > - > -#endif /* CONFIG_STATIC_CALL_SELFTEST */ > diff --git a/kernel/static_call_selftest.c b/kernel/static_call_selftest.c > new file mode 100644 > index 000000000000..246ad89f64eb > --- /dev/null > +++ b/kernel/static_call_selftest.c > @@ -0,0 +1,41 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include <linux/static_call.h> > + > +static int func_a(int x) > +{ > + return x+1; > +} > + > +static int func_b(int x) > +{ > + return x+2; > +} > + > +DEFINE_STATIC_CALL(sc_selftest, func_a); > + > +static struct static_call_data { > + int (*func)(int); > + int val; > + int expect; > +} static_call_data [] __initdata = { > + { NULL, 2, 3 }, > + { func_b, 2, 4 }, > + { func_a, 2, 3 } > +}; > + > +static int __init test_static_call_init(void) > +{ > + int i; > + > + for (i = 0; i < ARRAY_SIZE(static_call_data); i++ ) { > + struct static_call_data *scd = &static_call_data[i]; > + > + if (scd->func) > + static_call_update(sc_selftest, scd->func); > + > + WARN_ON(static_call(sc_selftest)(scd->val) != scd->expect); > + } > + > + return 0; > +} > +early_initcall(test_static_call_init);
diff --git a/kernel/Makefile b/kernel/Makefile index 318789c728d3..8ce8beaa3cc0 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -113,6 +113,7 @@ obj-$(CONFIG_KCSAN) += kcsan/ obj-$(CONFIG_SHADOW_CALL_STACK) += scs.o obj-$(CONFIG_HAVE_STATIC_CALL) += static_call.o obj-$(CONFIG_HAVE_STATIC_CALL_INLINE) += static_call_inline.o +obj-$(CONFIG_STATIC_CALL_SELFTEST) += static_call_selftest.o obj-$(CONFIG_CFI_CLANG) += cfi.o obj-$(CONFIG_PERF_EVENTS) += events/ diff --git a/kernel/static_call_inline.c b/kernel/static_call_inline.c index dc5665b62814..64d04d054698 100644 --- a/kernel/static_call_inline.c +++ b/kernel/static_call_inline.c @@ -498,46 +498,3 @@ int __init static_call_init(void) return 0; } early_initcall(static_call_init); - -#ifdef CONFIG_STATIC_CALL_SELFTEST - -static int func_a(int x) -{ - return x+1; -} - -static int func_b(int x) -{ - return x+2; -} - -DEFINE_STATIC_CALL(sc_selftest, func_a); - -static struct static_call_data { - int (*func)(int); - int val; - int expect; -} static_call_data [] __initdata = { - { NULL, 2, 3 }, - { func_b, 2, 4 }, - { func_a, 2, 3 } -}; - -static int __init test_static_call_init(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(static_call_data); i++ ) { - struct static_call_data *scd = &static_call_data[i]; - - if (scd->func) - static_call_update(sc_selftest, scd->func); - - WARN_ON(static_call(sc_selftest)(scd->val) != scd->expect); - } - - return 0; -} -early_initcall(test_static_call_init); - -#endif /* CONFIG_STATIC_CALL_SELFTEST */ diff --git a/kernel/static_call_selftest.c b/kernel/static_call_selftest.c new file mode 100644 index 000000000000..246ad89f64eb --- /dev/null +++ b/kernel/static_call_selftest.c @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/static_call.h> + +static int func_a(int x) +{ + return x+1; +} + +static int func_b(int x) +{ + return x+2; +} + +DEFINE_STATIC_CALL(sc_selftest, func_a); + +static struct static_call_data { + int (*func)(int); + int val; + int expect; +} static_call_data [] __initdata = { + { NULL, 2, 3 }, + { func_b, 2, 4 }, + { func_a, 2, 3 } +}; + +static int __init test_static_call_init(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(static_call_data); i++ ) { + struct static_call_data *scd = &static_call_data[i]; + + if (scd->func) + static_call_update(sc_selftest, scd->func); + + WARN_ON(static_call(sc_selftest)(scd->val) != scd->expect); + } + + return 0; +} +early_initcall(test_static_call_init);