diff mbox series

[bpf-next,1/2] trace: bpf: Allow bpf to attach to bare tracepoints

Message ID 20210111182027.1448538-2-qais.yousef@arm.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series Allow attaching to bare tracepoints | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 8 maintainers not CCed: kafai@fb.com kpsingh@kernel.org yhs@fb.com songliubraving@fb.com john.fastabend@gmail.com corbet@lwn.net linux-doc@vger.kernel.org mingo@redhat.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit fail Errors and warnings before: 1156 this patch: 1003
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 42 lines checked
netdev/build_allmodconfig_warn fail Errors and warnings before: 1058 this patch: 906
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Qais Yousef Jan. 11, 2021, 6:20 p.m. UTC
Some subsystems only have bare tracepoints (a tracepoint with no
associated trace event) to avoid the problem of trace events being an
ABI that can't be changed.

From bpf presepective, bare tracepoints are what it calls
RAW_TRACEPOINT().

Since bpf assumed there's 1:1 mapping, it relied on hooking to
DEFINE_EVENT() macro to create bpf mapping of the tracepoints. Since
bare tracepoints use DECLARE_TRACE() to create the tracepoint, bpf had
no knowledge about their existence.

By teaching bpf_probe.h to parse DECLARE_TRACE() in a similar fashion to
DEFINE_EVENT(), bpf can find and attach to the new raw tracepoints.

Enabling that comes with the contract that changes to raw tracepoints
don't constitute a regression if they break existing bpf programs.
We need the ability to continue to morph and modify these raw
tracepoints without worrying about any ABI.

Update Documentation/bpf/bpf_design_QA.rst to document this contract.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
---
 Documentation/bpf/bpf_design_QA.rst |  6 ++++++
 include/trace/bpf_probe.h           | 12 ++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

Comments

Yonghong Song Jan. 12, 2021, 8:19 p.m. UTC | #1
On 1/11/21 10:20 AM, Qais Yousef wrote:
> Some subsystems only have bare tracepoints (a tracepoint with no
> associated trace event) to avoid the problem of trace events being an
> ABI that can't be changed.
> 
>  From bpf presepective, bare tracepoints are what it calls
> RAW_TRACEPOINT().
> 
> Since bpf assumed there's 1:1 mapping, it relied on hooking to
> DEFINE_EVENT() macro to create bpf mapping of the tracepoints. Since
> bare tracepoints use DECLARE_TRACE() to create the tracepoint, bpf had
> no knowledge about their existence.
> 
> By teaching bpf_probe.h to parse DECLARE_TRACE() in a similar fashion to
> DEFINE_EVENT(), bpf can find and attach to the new raw tracepoints.
> 
> Enabling that comes with the contract that changes to raw tracepoints
> don't constitute a regression if they break existing bpf programs.
> We need the ability to continue to morph and modify these raw
> tracepoints without worrying about any ABI.
> 
> Update Documentation/bpf/bpf_design_QA.rst to document this contract.
> 
> Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> ---
>   Documentation/bpf/bpf_design_QA.rst |  6 ++++++
>   include/trace/bpf_probe.h           | 12 ++++++++++--
>   2 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/bpf/bpf_design_QA.rst b/Documentation/bpf/bpf_design_QA.rst
> index 2df7b067ab93..0e15f9b05c9d 100644
> --- a/Documentation/bpf/bpf_design_QA.rst
> +++ b/Documentation/bpf/bpf_design_QA.rst
> @@ -208,6 +208,12 @@ data structures and compile with kernel internal headers. Both of these
>   kernel internals are subject to change and can break with newer kernels
>   such that the program needs to be adapted accordingly.
>   
> +Q: Are tracepoints part of the stable ABI?
> +------------------------------------------
> +A: NO. Tracepoints are tied to internal implementation details hence they are
> +subject to change and can break with newer kernels. BPF programs need to change
> +accordingly when this happens.
> +
>   Q: How much stack space a BPF program uses?
>   -------------------------------------------
>   A: Currently all program types are limited to 512 bytes of stack
> diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h
> index cd74bffed5c6..cf1496b162b1 100644
> --- a/include/trace/bpf_probe.h
> +++ b/include/trace/bpf_probe.h
> @@ -55,8 +55,7 @@
>   /* tracepoints with more than 12 arguments will hit build error */
>   #define CAST_TO_U64(...) CONCATENATE(__CAST, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__)
>   
> -#undef DECLARE_EVENT_CLASS
> -#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
> +#define __BPF_DECLARE_TRACE(call, proto, args)				\
>   static notrace void							\
>   __bpf_trace_##call(void *__data, proto)					\
>   {									\
> @@ -64,6 +63,10 @@ __bpf_trace_##call(void *__data, proto)					\
>   	CONCATENATE(bpf_trace_run, COUNT_ARGS(args))(prog, CAST_TO_U64(args));	\
>   }
>   
> +#undef DECLARE_EVENT_CLASS
> +#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
> +	__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))
> +
>   /*
>    * This part is compiled out, it is only here as a build time check
>    * to make sure that if the tracepoint handling changes, the
> @@ -111,6 +114,11 @@ __DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args), size)
>   #define DEFINE_EVENT_PRINT(template, name, proto, args, print)	\
>   	DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
>   
> +#undef DECLARE_TRACE
> +#define DECLARE_TRACE(call, proto, args)				\
> +	(__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))		\
> +	 __DEFINE_EVENT(call, call, PARAMS(proto), PARAMS(args), 0))

I applied the patch to my local bpf-next repo, and got the following
compilation error:

In file included from 
/data/users/yhs/work/net-next/include/trace/define_trace.h:104, 

                  from 
/data/users/yhs/work/net-next/include/trace/events/sched.h:740, 

                  from 
/data/users/yhs/work/net-next/kernel/sched/core.c:10: 

/data/users/yhs/work/net-next/include/trace/bpf_probe.h:59:1: error: 
expected identifier or ‘(’ before ‘static’
  static notrace void       \ 

  ^~~~~~ 

/data/users/yhs/work/net-next/include/trace/bpf_probe.h:119:3: note: in 
expansion of macro ‘__BPF_DECLARE_TRACE’
   (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \ 

    ^~~~~~~~~~~~~~~~~~~ 

/data/users/yhs/work/net-next/include/trace/events/sched.h:693:1: note: 
in expansion of macro ‘DECLARE_TRACE’
  DECLARE_TRACE(pelt_cfs_tp, 

  ^~~~~~~~~~~~~ 

/data/users/yhs/work/net-next/include/trace/bpf_probe.h:59:1: error: 
expected identifier or ‘(’ before ‘static’
  static notrace void       \ 

  ^~~~~~ 

/data/users/yhs/work/net-next/include/trace/bpf_probe.h:119:3: note: in 
expansion of macro ‘__BPF_DECLARE_TRACE’
   (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \ 

    ^~~~~~~~~~~~~~~~~~~ 

/data/users/yhs/work/net-next/include/trace/events/sched.h:697:1: note: 
in expansion of macro ‘DECLARE_TRACE’
  DECLARE_TRACE(pelt_rt_tp, 

  ^~~~~~~~~~~~~
/data/users/yhs/work/net-next/include/trace/bpf_probe.h:59:1: error: 
expected identifier or ‘(’ before ‘static’
  static notrace void       \

I dumped preprecessor result but after macro expansion, the code
becomes really complex and I have not figured out why it failed.
Do you know what is the possible reason?

> +
>   #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
>   
>   #undef DEFINE_EVENT_WRITABLE
>
Qais Yousef Jan. 13, 2021, 10:16 a.m. UTC | #2
On 01/12/21 12:19, Yonghong Song wrote:
> I applied the patch to my local bpf-next repo, and got the following
> compilation error:

[...]

> 
> I dumped preprecessor result but after macro expansion, the code
> becomes really complex and I have not figured out why it failed.
> Do you know what is the possible reason?

Yeah I did a last minute fix to address a checkpatch.pl error and my
verification of the change wasn't good enough obviously.

If you're keen to try out I can send you a patch with the fix. I should send v2
by the weekend too.

Thanks for having a look.

Cheers

--
Qais Yousef
Yonghong Song Jan. 13, 2021, 4:06 p.m. UTC | #3
On 1/13/21 2:16 AM, Qais Yousef wrote:
> On 01/12/21 12:19, Yonghong Song wrote:
>> I applied the patch to my local bpf-next repo, and got the following
>> compilation error:
> 
> [...]
> 
>>
>> I dumped preprecessor result but after macro expansion, the code
>> becomes really complex and I have not figured out why it failed.
>> Do you know what is the possible reason?
> 
> Yeah I did a last minute fix to address a checkpatch.pl error and my
> verification of the change wasn't good enough obviously.
> 
> If you're keen to try out I can send you a patch with the fix. I should send v2
> by the weekend too.

Thanks. I can wait and will check v2 once it is available.

> 
> Thanks for having a look.
> 
> Cheers
> 
> --
> Qais Yousef
>
kernel test robot Jan. 14, 2021, 2:59 a.m. UTC | #4
Hi Qais,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]

url:    https://github.com/0day-ci/linux/commits/Qais-Yousef/Allow-attaching-to-bare-tracepoints/20210112-022350
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: x86_64-rhel-7.6-kselftests (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/8f02e2ee2ac949ce6b4fd3cfd323f2e513a2cac6
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Qais-Yousef/Allow-attaching-to-bare-tracepoints/20210112-022350
        git checkout 8f02e2ee2ac949ce6b4fd3cfd323f2e513a2cac6
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/trace/define_trace.h:104,
                    from include/trace/events/sched.h:740,
                    from kernel/sched/core.c:10:
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:693:1: note: in expansion of macro 'DECLARE_TRACE'
     693 | DECLARE_TRACE(pelt_cfs_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:697:1: note: in expansion of macro 'DECLARE_TRACE'
     697 | DECLARE_TRACE(pelt_rt_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:701:1: note: in expansion of macro 'DECLARE_TRACE'
     701 | DECLARE_TRACE(pelt_dl_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:705:1: note: in expansion of macro 'DECLARE_TRACE'
     705 | DECLARE_TRACE(pelt_thermal_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:709:1: note: in expansion of macro 'DECLARE_TRACE'
     709 | DECLARE_TRACE(pelt_irq_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:713:1: note: in expansion of macro 'DECLARE_TRACE'
     713 | DECLARE_TRACE(pelt_se_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:717:1: note: in expansion of macro 'DECLARE_TRACE'
     717 | DECLARE_TRACE(sched_cpu_capacity_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:721:1: note: in expansion of macro 'DECLARE_TRACE'
     721 | DECLARE_TRACE(sched_overutilized_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:725:1: note: in expansion of macro 'DECLARE_TRACE'
     725 | DECLARE_TRACE(sched_util_est_cfs_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:729:1: note: in expansion of macro 'DECLARE_TRACE'
     729 | DECLARE_TRACE(sched_util_est_se_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:733:1: note: in expansion of macro 'DECLARE_TRACE'
     733 | DECLARE_TRACE(sched_update_nr_running_tp,
         | ^~~~~~~~~~~~~
   kernel/sched/core.c:2828:6: warning: no previous prototype for 'sched_set_stop_task' [-Wmissing-prototypes]
    2828 | void sched_set_stop_task(int cpu, struct task_struct *stop)
         |      ^~~~~~~~~~~~~~~~~~~
   kernel/sched/core.c: In function 'schedule_tail':
   kernel/sched/core.c:4238:13: warning: variable 'rq' set but not used [-Wunused-but-set-variable]
    4238 |  struct rq *rq;
         |             ^~


vim +59 include/trace/bpf_probe.h

c4f6699dfcb8558d Alexei Starovoitov 2018-03-28  57  
8f02e2ee2ac949ce Qais Yousef        2021-01-11  58  #define __BPF_DECLARE_TRACE(call, proto, args)				\
c4f6699dfcb8558d Alexei Starovoitov 2018-03-28 @59  static notrace void							\
c4f6699dfcb8558d Alexei Starovoitov 2018-03-28  60  __bpf_trace_##call(void *__data, proto)					\
c4f6699dfcb8558d Alexei Starovoitov 2018-03-28  61  {									\
c4f6699dfcb8558d Alexei Starovoitov 2018-03-28  62  	struct bpf_prog *prog = __data;					\
c4f6699dfcb8558d Alexei Starovoitov 2018-03-28  63  	CONCATENATE(bpf_trace_run, COUNT_ARGS(args))(prog, CAST_TO_U64(args));	\
c4f6699dfcb8558d Alexei Starovoitov 2018-03-28  64  }
c4f6699dfcb8558d Alexei Starovoitov 2018-03-28  65  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot Jan. 14, 2021, 3:46 a.m. UTC | #5
Hi Qais,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]

url:    https://github.com/0day-ci/linux/commits/Qais-Yousef/Allow-attaching-to-bare-tracepoints/20210112-022350
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: x86_64-rhel-8.3 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/8f02e2ee2ac949ce6b4fd3cfd323f2e513a2cac6
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Qais-Yousef/Allow-attaching-to-bare-tracepoints/20210112-022350
        git checkout 8f02e2ee2ac949ce6b4fd3cfd323f2e513a2cac6
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/trace/define_trace.h:104,
                    from include/trace/events/sched.h:740,
                    from kernel/sched/core.c:10:
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:693:1: note: in expansion of macro 'DECLARE_TRACE'
     693 | DECLARE_TRACE(pelt_cfs_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:697:1: note: in expansion of macro 'DECLARE_TRACE'
     697 | DECLARE_TRACE(pelt_rt_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:701:1: note: in expansion of macro 'DECLARE_TRACE'
     701 | DECLARE_TRACE(pelt_dl_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:705:1: note: in expansion of macro 'DECLARE_TRACE'
     705 | DECLARE_TRACE(pelt_thermal_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:709:1: note: in expansion of macro 'DECLARE_TRACE'
     709 | DECLARE_TRACE(pelt_irq_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:713:1: note: in expansion of macro 'DECLARE_TRACE'
     713 | DECLARE_TRACE(pelt_se_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:717:1: note: in expansion of macro 'DECLARE_TRACE'
     717 | DECLARE_TRACE(sched_cpu_capacity_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:721:1: note: in expansion of macro 'DECLARE_TRACE'
     721 | DECLARE_TRACE(sched_overutilized_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:725:1: note: in expansion of macro 'DECLARE_TRACE'
     725 | DECLARE_TRACE(sched_util_est_cfs_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:729:1: note: in expansion of macro 'DECLARE_TRACE'
     729 | DECLARE_TRACE(sched_util_est_se_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:733:1: note: in expansion of macro 'DECLARE_TRACE'
     733 | DECLARE_TRACE(sched_update_nr_running_tp,
         | ^~~~~~~~~~~~~
   kernel/sched/core.c:2828:6: warning: no previous prototype for 'sched_set_stop_task' [-Wmissing-prototypes]
    2828 | void sched_set_stop_task(int cpu, struct task_struct *stop)
         |      ^~~~~~~~~~~~~~~~~~~
   kernel/sched/core.c: In function 'schedule_tail':
   kernel/sched/core.c:4238:13: warning: variable 'rq' set but not used [-Wunused-but-set-variable]
    4238 |  struct rq *rq;
         |             ^~


vim +59 include/trace/bpf_probe.h

c4f6699dfcb855 Alexei Starovoitov 2018-03-28  57  
8f02e2ee2ac949 Qais Yousef        2021-01-11  58  #define __BPF_DECLARE_TRACE(call, proto, args)				\
c4f6699dfcb855 Alexei Starovoitov 2018-03-28 @59  static notrace void							\
c4f6699dfcb855 Alexei Starovoitov 2018-03-28  60  __bpf_trace_##call(void *__data, proto)					\
c4f6699dfcb855 Alexei Starovoitov 2018-03-28  61  {									\
c4f6699dfcb855 Alexei Starovoitov 2018-03-28  62  	struct bpf_prog *prog = __data;					\
c4f6699dfcb855 Alexei Starovoitov 2018-03-28  63  	CONCATENATE(bpf_trace_run, COUNT_ARGS(args))(prog, CAST_TO_U64(args));	\
c4f6699dfcb855 Alexei Starovoitov 2018-03-28  64  }
c4f6699dfcb855 Alexei Starovoitov 2018-03-28  65  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/Documentation/bpf/bpf_design_QA.rst b/Documentation/bpf/bpf_design_QA.rst
index 2df7b067ab93..0e15f9b05c9d 100644
--- a/Documentation/bpf/bpf_design_QA.rst
+++ b/Documentation/bpf/bpf_design_QA.rst
@@ -208,6 +208,12 @@  data structures and compile with kernel internal headers. Both of these
 kernel internals are subject to change and can break with newer kernels
 such that the program needs to be adapted accordingly.
 
+Q: Are tracepoints part of the stable ABI?
+------------------------------------------
+A: NO. Tracepoints are tied to internal implementation details hence they are
+subject to change and can break with newer kernels. BPF programs need to change
+accordingly when this happens.
+
 Q: How much stack space a BPF program uses?
 -------------------------------------------
 A: Currently all program types are limited to 512 bytes of stack
diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h
index cd74bffed5c6..cf1496b162b1 100644
--- a/include/trace/bpf_probe.h
+++ b/include/trace/bpf_probe.h
@@ -55,8 +55,7 @@ 
 /* tracepoints with more than 12 arguments will hit build error */
 #define CAST_TO_U64(...) CONCATENATE(__CAST, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__)
 
-#undef DECLARE_EVENT_CLASS
-#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
+#define __BPF_DECLARE_TRACE(call, proto, args)				\
 static notrace void							\
 __bpf_trace_##call(void *__data, proto)					\
 {									\
@@ -64,6 +63,10 @@  __bpf_trace_##call(void *__data, proto)					\
 	CONCATENATE(bpf_trace_run, COUNT_ARGS(args))(prog, CAST_TO_U64(args));	\
 }
 
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
+	__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))
+
 /*
  * This part is compiled out, it is only here as a build time check
  * to make sure that if the tracepoint handling changes, the
@@ -111,6 +114,11 @@  __DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args), size)
 #define DEFINE_EVENT_PRINT(template, name, proto, args, print)	\
 	DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
 
+#undef DECLARE_TRACE
+#define DECLARE_TRACE(call, proto, args)				\
+	(__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))		\
+	 __DEFINE_EVENT(call, call, PARAMS(proto), PARAMS(args), 0))
+
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
 #undef DEFINE_EVENT_WRITABLE