Skip to content

Commit

Permalink
selftests/bpf: Few fixes for selftests/bpf built in release mode
Browse files Browse the repository at this point in the history
Fix few issues found when building and running test_progs in
release mode.

First, potentially uninitialized idx variable in xskxceiver,
force-initialize to zero to satisfy compiler.

Few instances of defining uprobe trigger functions break in release mode
unless marked as noinline, due to being static. Add noinline to make
sure everything works.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Hao Luo <haoluo@google.com>
Link: https://lore.kernel.org/bpf/20220816001929.369487-5-andrii@kernel.org
  • Loading branch information
Andrii Nakryiko authored and Daniel Borkmann committed Aug 17, 2022
1 parent abf84b6 commit df78da2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tools/testing/selftests/bpf/prog_tests/attach_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
volatile unsigned short uprobe_ref_ctr __attribute__((unused)) __attribute((section(".probes")));

/* uprobe attach point */
static void trigger_func(void)
static noinline void trigger_func(void)
{
asm volatile ("");
}

/* attach point for byname uprobe */
static void trigger_func2(void)
static noinline void trigger_func2(void)
{
asm volatile ("");
}

/* attach point for byname sleepable uprobe */
static void trigger_func3(void)
static noinline void trigger_func3(void)
{
asm volatile ("");
}
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "kprobe_multi.skel.h"

/* uprobe attach point */
static void trigger_func(void)
static noinline void trigger_func(void)
{
asm volatile ("");
}
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/prog_tests/task_pt_regs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "test_task_pt_regs.skel.h"

/* uprobe attach point */
static void trigger_func(void)
static noinline void trigger_func(void)
{
asm volatile ("");
}
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/xskxceiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ static int __send_pkts(struct ifobject *ifobject, u32 *pkt_nb, struct pollfd *fd
{
struct xsk_socket_info *xsk = ifobject->xsk;
bool use_poll = ifobject->use_poll;
u32 i, idx, ret, valid_pkts = 0;
u32 i, idx = 0, ret, valid_pkts = 0;

while (xsk_ring_prod__reserve(&xsk->tx, BATCH_SIZE, &idx) < BATCH_SIZE) {
if (use_poll) {
Expand Down

0 comments on commit df78da2

Please sign in to comment.