Skip to content

Commit 893c393

Browse files
committed
Merge branch 'likely-unlikely-for-bpf_helpers-and-a-small-comment-fix'
Anton Protopopov says: ==================== likely/unlikely for bpf_helpers and a small comment fix These two commits fix a comment describing bpf_attr in <linux/bpf.h> and add likely/unlikely macros to <bph/bpf_helpers.h> to be consumed by selftests and, later, by the static_branch_likely/unlikely macros. v1 -> v2: * squash libbpf and selftests fixes into one patch (Andrii) ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Andrii Nakryiko <[email protected]>
2 parents 75011ad + dafae1a commit 893c393

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

include/uapi/linux/bpf.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ union bpf_attr {
15061506
__s32 map_token_fd;
15071507
};
15081508

1509-
struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */
1509+
struct { /* anonymous struct used by BPF_MAP_*_ELEM and BPF_MAP_FREEZE commands */
15101510
__u32 map_fd;
15111511
__aligned_u64 key;
15121512
union {

tools/include/uapi/linux/bpf.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ union bpf_attr {
15061506
__s32 map_token_fd;
15071507
};
15081508

1509-
struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */
1509+
struct { /* anonymous struct used by BPF_MAP_*_ELEM and BPF_MAP_FREEZE commands */
15101510
__u32 map_fd;
15111511
__aligned_u64 key;
15121512
union {

tools/lib/bpf/bpf_helpers.h

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
#define __array(name, val) typeof(val) *name[]
1616
#define __ulong(name, val) enum { ___bpf_concat(__unique_value, __COUNTER__) = val } name
1717

18+
#ifndef likely
19+
#define likely(x) (__builtin_expect(!!(x), 1))
20+
#endif
21+
22+
#ifndef unlikely
23+
#define unlikely(x) (__builtin_expect(!!(x), 0))
24+
#endif
25+
1826
/*
1927
* Helper macro to place programs, maps, license in
2028
* different sections in elf_bpf file. Section names

tools/testing/selftests/bpf/bpf_arena_spin_lock.h

-3
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ struct arena_qnode {
9595
#define _Q_LOCKED_VAL (1U << _Q_LOCKED_OFFSET)
9696
#define _Q_PENDING_VAL (1U << _Q_PENDING_OFFSET)
9797

98-
#define likely(x) __builtin_expect(!!(x), 1)
99-
#define unlikely(x) __builtin_expect(!!(x), 0)
100-
10198
struct arena_qnode __arena qnodes[_Q_MAX_CPUS][_Q_MAX_NODES];
10299

103100
static inline u32 encode_tail(int cpu, int idx)

tools/testing/selftests/bpf/progs/iters.c

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#include "bpf_misc.h"
88
#include "bpf_compiler.h"
99

10-
#define unlikely(x) __builtin_expect(!!(x), 0)
11-
1210
static volatile int zero = 0;
1311

1412
int my_pid;

0 commit comments

Comments
 (0)