Re: [RFC PATCH bpf-next 10/14] libbpf: add likely/unlikely macros

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

 



On 25/03/28 01:57PM, Andrii Nakryiko wrote:
> On Tue, Mar 18, 2025 at 7:30 AM Anton Protopopov <aspsk@xxxxxxxxxxxxx> wrote:
> >
> > A few selftests and, more importantly, a consequent changes to the
> > bpf_helpers.h file use likely/unlikely macros. So define them here.
> >
> > Signed-off-by: Anton Protopopov <aspsk@xxxxxxxxxxxxx>
> > ---
> >  tools/lib/bpf/bpf_helpers.h | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h
> > index 686824b8b413..a50773d4616e 100644
> > --- a/tools/lib/bpf/bpf_helpers.h
> > +++ b/tools/lib/bpf/bpf_helpers.h
> > @@ -15,6 +15,14 @@
> >  #define __array(name, val) typeof(val) *name[]
> >  #define __ulong(name, val) enum { ___bpf_concat(__unique_value, __COUNTER__) = val } name
> >
> > +#ifndef likely
> > +#define likely(x)      (__builtin_expect(!!(x), 1))
> > +#endif
> > +
> > +#ifndef unlikely
> > +#define unlikely(x)    (__builtin_expect(!!(x), 0))
> > +#endif
> > +
> 
> this seems useful, maybe send this as a separate patch? I'd roll your
> BPF selftests manipulation into the same patch to avoid unnecessary
> code churn

Yes, let me send it separately (+ a comment fix from the patch 01). 

The reason I've done this in three patches is 1) every separate patch
should build 2) I thought that libbpf patches should be separate from
selftest changes? (= how libbpf changes are pulled to github version of
libvirt?)

> >  /*
> >   * Helper macro to place programs, maps, license in
> >   * different sections in elf_bpf file. Section names
> > --
> > 2.34.1
> >




[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