Re: Which file should I include for KERNEL_VERSION macro ?

Andrii Nakryiko

On Wed, Mar 17, 2021 at 5:10 AM <chenhengqi@...> wrote:

I'v read this blog post

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

Join to automatically receive all group messages.