Re: [PATCH 2/6] perf record: Enable off-cpu analysis with BPF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 31, 2022 at 5:00 PM Ian Rogers <irogers@xxxxxxxxxx> wrote:
>
> On Wed, May 18, 2022 at 3:47 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
[SNIP]
> > +
> > +/*
> > + * Old kernel used to call it task_struct->state and now it's '__state'.
> > + * Use BPF CO-RE "ignored suffix rule" to deal with it like below:
> > + *
> > + * https://nakryiko.com/posts/bpf-core-reference-guide/#handling-incompatible-field-and-type-changes
> > + */
> > +static inline int get_task_state(struct task_struct *t)
> > +{
> > +       if (bpf_core_field_exists(t->__state))
> > +               return BPF_CORE_READ(t, __state);
> > +
>
> When building against a pre-5.14 kernel I'm running into a build issue here:
>
> tools/perf/util/bpf_skel/off_cpu.bpf.c:96:31: error: no member named '__
> state' in 'struct task_struct'; did you mean 'state'?
>        if (bpf_core_field_exists(t->__state))
>                                     ^~~~~~~
>                                     state
>
> This isn't covered by Andrii's BPF CO-RE reference guide. I have an
> #iffy workaround below,but this will be brittle if the 5.14+ kernel
> code is backported. Suggestions welcomed :-)

Thanks for the fix.  I think we should not guess the field name
in the current task struct and check both versions separately.
I'm afraid the version check won't work with some backported
kernels.  But do we care?

Thanks,
Namhyung



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux