Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: Fix build without BPF_SYSCALL, but with BPF_JIT.
@ 2020-08-30 20:43 Alexei Starovoitov
2020-08-30 22:03 ` Paul E. McKenney
0 siblings, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2020-08-30 20:43 UTC (permalink / raw)
To: davem; +Cc: daniel, josef, paulmck, netdev, bpf, kernel-team
From: Alexei Starovoitov <ast@kernel.org>
When CONFIG_BPF_SYSCALL is not set, but CONFIG_BPF_JIT=y
the kernel build fails:
In file included from ../kernel/bpf/trampoline.c:11:
../kernel/bpf/trampoline.c: In function ‘bpf_trampoline_update’:
../kernel/bpf/trampoline.c:220:39: error: ‘call_rcu_tasks_trace’ undeclared
../kernel/bpf/trampoline.c: In function ‘__bpf_prog_enter_sleepable’:
../kernel/bpf/trampoline.c:411:2: error: implicit declaration of function ‘rcu_read_lock_trace’
../kernel/bpf/trampoline.c: In function ‘__bpf_prog_exit_sleepable’:
../kernel/bpf/trampoline.c:416:2: error: implicit declaration of function ‘rcu_read_unlock_trace’
Add these functions to rcupdate_trace.h.
The JIT won't call them and BPF trampoline logic won't be used without BPF_SYSCALL.
Reported-by: kernel test robot <lkp@intel.com>
Fixes: 1e6c62a88215 ("bpf: Introduce sleepable BPF programs")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
include/linux/rcupdate_trace.h | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/linux/rcupdate_trace.h b/include/linux/rcupdate_trace.h
index d9015aac78c6..334840f4f245 100644
--- a/include/linux/rcupdate_trace.h
+++ b/include/linux/rcupdate_trace.h
@@ -82,7 +82,19 @@ static inline void rcu_read_unlock_trace(void)
void call_rcu_tasks_trace(struct rcu_head *rhp, rcu_callback_t func);
void synchronize_rcu_tasks_trace(void);
void rcu_barrier_tasks_trace(void);
-
+#else
+static inline void call_rcu_tasks_trace(struct rcu_head *rhp, rcu_callback_t func)
+{
+ BUG();
+}
+static inline void rcu_read_lock_trace(void)
+{
+ BUG();
+}
+static inline void rcu_read_unlock_trace(void)
+{
+ BUG();
+}
#endif /* #ifdef CONFIG_TASKS_TRACE_RCU */
#endif /* __LINUX_RCUPDATE_TRACE_H */
--
2.23.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] bpf: Fix build without BPF_SYSCALL, but with BPF_JIT.
2020-08-30 20:43 [PATCH bpf-next] bpf: Fix build without BPF_SYSCALL, but with BPF_JIT Alexei Starovoitov
@ 2020-08-30 22:03 ` Paul E. McKenney
2020-08-31 0:53 ` Alexei Starovoitov
0 siblings, 1 reply; 4+ messages in thread
From: Paul E. McKenney @ 2020-08-30 22:03 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: davem, daniel, josef, netdev, bpf, kernel-team
On Sun, Aug 30, 2020 at 01:43:28PM -0700, Alexei Starovoitov wrote:
> From: Alexei Starovoitov <ast@kernel.org>
>
> When CONFIG_BPF_SYSCALL is not set, but CONFIG_BPF_JIT=y
> the kernel build fails:
> In file included from ../kernel/bpf/trampoline.c:11:
> ../kernel/bpf/trampoline.c: In function ‘bpf_trampoline_update’:
> ../kernel/bpf/trampoline.c:220:39: error: ‘call_rcu_tasks_trace’ undeclared
> ../kernel/bpf/trampoline.c: In function ‘__bpf_prog_enter_sleepable’:
> ../kernel/bpf/trampoline.c:411:2: error: implicit declaration of function ‘rcu_read_lock_trace’
> ../kernel/bpf/trampoline.c: In function ‘__bpf_prog_exit_sleepable’:
> ../kernel/bpf/trampoline.c:416:2: error: implicit declaration of function ‘rcu_read_unlock_trace’
>
> Add these functions to rcupdate_trace.h.
> The JIT won't call them and BPF trampoline logic won't be used without BPF_SYSCALL.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: 1e6c62a88215 ("bpf: Introduce sleepable BPF programs")
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
A couple of nits below, but overall:
Acked-by: Paul E. McKenney <paulmck@kernel.org>
> ---
> include/linux/rcupdate_trace.h | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/rcupdate_trace.h b/include/linux/rcupdate_trace.h
> index d9015aac78c6..334840f4f245 100644
> --- a/include/linux/rcupdate_trace.h
> +++ b/include/linux/rcupdate_trace.h
> @@ -82,7 +82,19 @@ static inline void rcu_read_unlock_trace(void)
> void call_rcu_tasks_trace(struct rcu_head *rhp, rcu_callback_t func);
> void synchronize_rcu_tasks_trace(void);
> void rcu_barrier_tasks_trace(void);
> -
> +#else
This formulation is a bit novel for RCU. Could we therefore please add
a comment something like this?
// The BPF JIT forms these addresses even when it doesn't call these
// functions, so provide definitions that result in runtime errors.
> +static inline void call_rcu_tasks_trace(struct rcu_head *rhp, rcu_callback_t func)
> +{
> + BUG();
> +}
> +static inline void rcu_read_lock_trace(void)
> +{
> + BUG();
> +}
> +static inline void rcu_read_unlock_trace(void)
> +{
> + BUG();
> +}
People have been moving towards one-liner for things like these last two:
static inline void rcu_read_lock_trace(void) { BUG(); }
static inline void rcu_read_unlock_trace(void) { BUG(); }
> #endif /* #ifdef CONFIG_TASKS_TRACE_RCU */
>
> #endif /* __LINUX_RCUPDATE_TRACE_H */
> --
> 2.23.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] bpf: Fix build without BPF_SYSCALL, but with BPF_JIT.
2020-08-30 22:03 ` Paul E. McKenney
@ 2020-08-31 0:53 ` Alexei Starovoitov
2020-08-31 4:46 ` Paul E. McKenney
0 siblings, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2020-08-31 0:53 UTC (permalink / raw)
To: Paul E. McKenney; +Cc: davem, daniel, josef, netdev, bpf, kernel-team
On Sun, Aug 30, 2020 at 03:03:13PM -0700, Paul E. McKenney wrote:
> On Sun, Aug 30, 2020 at 01:43:28PM -0700, Alexei Starovoitov wrote:
> > From: Alexei Starovoitov <ast@kernel.org>
> >
> > When CONFIG_BPF_SYSCALL is not set, but CONFIG_BPF_JIT=y
> > the kernel build fails:
> > In file included from ../kernel/bpf/trampoline.c:11:
> > ../kernel/bpf/trampoline.c: In function ‘bpf_trampoline_update’:
> > ../kernel/bpf/trampoline.c:220:39: error: ‘call_rcu_tasks_trace’ undeclared
> > ../kernel/bpf/trampoline.c: In function ‘__bpf_prog_enter_sleepable’:
> > ../kernel/bpf/trampoline.c:411:2: error: implicit declaration of function ‘rcu_read_lock_trace’
> > ../kernel/bpf/trampoline.c: In function ‘__bpf_prog_exit_sleepable’:
> > ../kernel/bpf/trampoline.c:416:2: error: implicit declaration of function ‘rcu_read_unlock_trace’
> >
> > Add these functions to rcupdate_trace.h.
> > The JIT won't call them and BPF trampoline logic won't be used without BPF_SYSCALL.
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Fixes: 1e6c62a88215 ("bpf: Introduce sleepable BPF programs")
> > Signed-off-by: Alexei Starovoitov <ast@kernel.org>
>
> A couple of nits below, but overall:
>
> Acked-by: Paul E. McKenney <paulmck@kernel.org>
>
> > ---
> > include/linux/rcupdate_trace.h | 14 +++++++++++++-
> > 1 file changed, 13 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/linux/rcupdate_trace.h b/include/linux/rcupdate_trace.h
> > index d9015aac78c6..334840f4f245 100644
> > --- a/include/linux/rcupdate_trace.h
> > +++ b/include/linux/rcupdate_trace.h
> > @@ -82,7 +82,19 @@ static inline void rcu_read_unlock_trace(void)
> > void call_rcu_tasks_trace(struct rcu_head *rhp, rcu_callback_t func);
> > void synchronize_rcu_tasks_trace(void);
> > void rcu_barrier_tasks_trace(void);
> > -
> > +#else
>
> This formulation is a bit novel for RCU. Could we therefore please add
> a comment something like this?
>
> // The BPF JIT forms these addresses even when it doesn't call these
> // functions, so provide definitions that result in runtime errors.
ok. will add.
The root of the problem is:
obj-$(CONFIG_BPF_JIT) += trampoline.o
obj-$(CONFIG_BPF_JIT) += dispatcher.o
There is a number of functions that arch/x86/net/bpf_jit_comp.c is
using from these two files, but none of them will be used when
only cBPF is on (which is the case for BPF_SYSCALL=n BPF_JIT=y).
Don't confuse cBPF with eBPF ;)
This patch is imo the lesser of three evils. The other two:
- some serious refactoring of trampoline.c and dipsatcher.c into
multiple files
- add 'depends on BPF_SYSCALL' to 'config BPF_JIT' in net/Kconfig
>
> > +static inline void call_rcu_tasks_trace(struct rcu_head *rhp, rcu_callback_t func)
> > +{
> > + BUG();
> > +}
> > +static inline void rcu_read_lock_trace(void)
> > +{
> > + BUG();
> > +}
> > +static inline void rcu_read_unlock_trace(void)
> > +{
> > + BUG();
> > +}
>
> People have been moving towards one-liner for things like these last two:
>
> static inline void rcu_read_lock_trace(void) { BUG(); }
> static inline void rcu_read_unlock_trace(void) { BUG(); }
sure. will respin.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] bpf: Fix build without BPF_SYSCALL, but with BPF_JIT.
2020-08-31 0:53 ` Alexei Starovoitov
@ 2020-08-31 4:46 ` Paul E. McKenney
0 siblings, 0 replies; 4+ messages in thread
From: Paul E. McKenney @ 2020-08-31 4:46 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: davem, daniel, josef, netdev, bpf, kernel-team
On Sun, Aug 30, 2020 at 05:53:21PM -0700, Alexei Starovoitov wrote:
> On Sun, Aug 30, 2020 at 03:03:13PM -0700, Paul E. McKenney wrote:
> > On Sun, Aug 30, 2020 at 01:43:28PM -0700, Alexei Starovoitov wrote:
> > > From: Alexei Starovoitov <ast@kernel.org>
> > >
> > > When CONFIG_BPF_SYSCALL is not set, but CONFIG_BPF_JIT=y
> > > the kernel build fails:
> > > In file included from ../kernel/bpf/trampoline.c:11:
> > > ../kernel/bpf/trampoline.c: In function ‘bpf_trampoline_update’:
> > > ../kernel/bpf/trampoline.c:220:39: error: ‘call_rcu_tasks_trace’ undeclared
> > > ../kernel/bpf/trampoline.c: In function ‘__bpf_prog_enter_sleepable’:
> > > ../kernel/bpf/trampoline.c:411:2: error: implicit declaration of function ‘rcu_read_lock_trace’
> > > ../kernel/bpf/trampoline.c: In function ‘__bpf_prog_exit_sleepable’:
> > > ../kernel/bpf/trampoline.c:416:2: error: implicit declaration of function ‘rcu_read_unlock_trace’
> > >
> > > Add these functions to rcupdate_trace.h.
> > > The JIT won't call them and BPF trampoline logic won't be used without BPF_SYSCALL.
> > >
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Fixes: 1e6c62a88215 ("bpf: Introduce sleepable BPF programs")
> > > Signed-off-by: Alexei Starovoitov <ast@kernel.org>
> >
> > A couple of nits below, but overall:
> >
> > Acked-by: Paul E. McKenney <paulmck@kernel.org>
> >
> > > ---
> > > include/linux/rcupdate_trace.h | 14 +++++++++++++-
> > > 1 file changed, 13 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/include/linux/rcupdate_trace.h b/include/linux/rcupdate_trace.h
> > > index d9015aac78c6..334840f4f245 100644
> > > --- a/include/linux/rcupdate_trace.h
> > > +++ b/include/linux/rcupdate_trace.h
> > > @@ -82,7 +82,19 @@ static inline void rcu_read_unlock_trace(void)
> > > void call_rcu_tasks_trace(struct rcu_head *rhp, rcu_callback_t func);
> > > void synchronize_rcu_tasks_trace(void);
> > > void rcu_barrier_tasks_trace(void);
> > > -
> > > +#else
> >
> > This formulation is a bit novel for RCU. Could we therefore please add
> > a comment something like this?
> >
> > // The BPF JIT forms these addresses even when it doesn't call these
> > // functions, so provide definitions that result in runtime errors.
>
> ok. will add.
> The root of the problem is:
> obj-$(CONFIG_BPF_JIT) += trampoline.o
> obj-$(CONFIG_BPF_JIT) += dispatcher.o
> There is a number of functions that arch/x86/net/bpf_jit_comp.c is
> using from these two files, but none of them will be used when
> only cBPF is on (which is the case for BPF_SYSCALL=n BPF_JIT=y).
> Don't confuse cBPF with eBPF ;)
Perhaps I should avoid this confusion by having you generate the actual
comment? ;-)
> This patch is imo the lesser of three evils. The other two:
> - some serious refactoring of trampoline.c and dipsatcher.c into
> multiple files
> - add 'depends on BPF_SYSCALL' to 'config BPF_JIT' in net/Kconfig
The first of these two occurred to me, the second not, but yes, this
sort of reasoning eventually convinced me not to complain about the
solution you chose.
> > > +static inline void call_rcu_tasks_trace(struct rcu_head *rhp, rcu_callback_t func)
> > > +{
> > > + BUG();
> > > +}
> > > +static inline void rcu_read_lock_trace(void)
> > > +{
> > > + BUG();
> > > +}
> > > +static inline void rcu_read_unlock_trace(void)
> > > +{
> > > + BUG();
> > > +}
> >
> > People have been moving towards one-liner for things like these last two:
> >
> > static inline void rcu_read_lock_trace(void) { BUG(); }
> > static inline void rcu_read_unlock_trace(void) { BUG(); }
>
> sure. will respin.
Thank you!
Thanx, Paul
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-31 4:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-30 20:43 [PATCH bpf-next] bpf: Fix build without BPF_SYSCALL, but with BPF_JIT Alexei Starovoitov
2020-08-30 22:03 ` Paul E. McKenney
2020-08-31 0:53 ` Alexei Starovoitov
2020-08-31 4:46 ` Paul E. McKenney
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).