On Wed, Mar 17, 2021 at 5:10 AM <chenhen...@outlook.com> wrote: > > I'v read this blog post > > https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html > > And want to apply this technique to my program: > > extern u32 LINUX_KERNEL_VERSION __kconfig; extern u32 CONFIG_HZ __kconfig; > u64 utime_ns; if (LINUX_KERNEL_VERSION >= KERNEL_VERSION(4, 11, 0)) utime_ns > = BPF_CORE_READ(task, utime); else /* convert jiffies to nanoseconds */ > utime_ns = BPF_CORE_READ(task, utime) * (1000000000UL / CONFIG_HZ); >
It will soon be part of bpf_helpers.h, but meanwhile just copy/paste it into your code. See https://patchwork.kernel.org/project/netdevbpf/patch/20210317200510.1354627-2-and...@kernel.org/ > -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#1975): https://lists.iovisor.org/g/iovisor-dev/message/1975 Mute This Topic: https://lists.iovisor.org/mt/81401199/21656 Group Owner: iovisor-dev+ow...@lists.iovisor.org Unsubscribe: https://lists.iovisor.org/g/iovisor-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-