Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libbpf: Ensure functions with always_inline attribute are inline

GCC expects the always_inline attribute to only be set on inline
functions, as such we should make all functions with this attribute
use the __always_inline macro which makes the function inline and
sets the attribute.

Fixes errors like:
/home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/include/bpf/bpf_tracing.h:439:1: error: ‘always_inline’ function might not be inlinable [-Werror=attributes]
439 | ____##name(unsigned long long *ctx, ##args)
| ^~~~

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20220803151403.793024-1-james.hilliard1@gmail.com

authored by

James Hilliard and committed by
Andrii Nakryiko
d25f40ff d55dfe58

+9 -9
+7 -7
tools/lib/bpf/bpf_tracing.h
··· 426 426 */ 427 427 #define BPF_PROG(name, args...) \ 428 428 name(unsigned long long *ctx); \ 429 - static __attribute__((always_inline)) typeof(name(0)) \ 429 + static __always_inline typeof(name(0)) \ 430 430 ____##name(unsigned long long *ctx, ##args); \ 431 431 typeof(name(0)) name(unsigned long long *ctx) \ 432 432 { \ ··· 435 435 return ____##name(___bpf_ctx_cast(args)); \ 436 436 _Pragma("GCC diagnostic pop") \ 437 437 } \ 438 - static __attribute__((always_inline)) typeof(name(0)) \ 438 + static __always_inline typeof(name(0)) \ 439 439 ____##name(unsigned long long *ctx, ##args) 440 440 441 441 struct pt_regs; ··· 460 460 */ 461 461 #define BPF_KPROBE(name, args...) \ 462 462 name(struct pt_regs *ctx); \ 463 - static __attribute__((always_inline)) typeof(name(0)) \ 463 + static __always_inline typeof(name(0)) \ 464 464 ____##name(struct pt_regs *ctx, ##args); \ 465 465 typeof(name(0)) name(struct pt_regs *ctx) \ 466 466 { \ ··· 469 469 return ____##name(___bpf_kprobe_args(args)); \ 470 470 _Pragma("GCC diagnostic pop") \ 471 471 } \ 472 - static __attribute__((always_inline)) typeof(name(0)) \ 472 + static __always_inline typeof(name(0)) \ 473 473 ____##name(struct pt_regs *ctx, ##args) 474 474 475 475 #define ___bpf_kretprobe_args0() ctx ··· 484 484 */ 485 485 #define BPF_KRETPROBE(name, args...) \ 486 486 name(struct pt_regs *ctx); \ 487 - static __attribute__((always_inline)) typeof(name(0)) \ 487 + static __always_inline typeof(name(0)) \ 488 488 ____##name(struct pt_regs *ctx, ##args); \ 489 489 typeof(name(0)) name(struct pt_regs *ctx) \ 490 490 { \ ··· 540 540 #define BPF_KSYSCALL(name, args...) \ 541 541 name(struct pt_regs *ctx); \ 542 542 extern _Bool LINUX_HAS_SYSCALL_WRAPPER __kconfig; \ 543 - static __attribute__((always_inline)) typeof(name(0)) \ 543 + static __always_inline typeof(name(0)) \ 544 544 ____##name(struct pt_regs *ctx, ##args); \ 545 545 typeof(name(0)) name(struct pt_regs *ctx) \ 546 546 { \ ··· 555 555 return ____##name(___bpf_syscall_args(args)); \ 556 556 _Pragma("GCC diagnostic pop") \ 557 557 } \ 558 - static __attribute__((always_inline)) typeof(name(0)) \ 558 + static __always_inline typeof(name(0)) \ 559 559 ____##name(struct pt_regs *ctx, ##args) 560 560 561 561 #define BPF_KPROBE_SYSCALL BPF_KSYSCALL
+2 -2
tools/lib/bpf/usdt.bpf.h
··· 232 232 */ 233 233 #define BPF_USDT(name, args...) \ 234 234 name(struct pt_regs *ctx); \ 235 - static __attribute__((always_inline)) typeof(name(0)) \ 235 + static __always_inline typeof(name(0)) \ 236 236 ____##name(struct pt_regs *ctx, ##args); \ 237 237 typeof(name(0)) name(struct pt_regs *ctx) \ 238 238 { \ ··· 241 241 return ____##name(___bpf_usdt_args(args)); \ 242 242 _Pragma("GCC diagnostic pop") \ 243 243 } \ 244 - static __attribute__((always_inline)) typeof(name(0)) \ 244 + static __always_inline typeof(name(0)) \ 245 245 ____##name(struct pt_regs *ctx, ##args) 246 246 247 247 #endif /* __USDT_BPF_H__ */