Commit fab45be1 authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Alexei Starovoitov
Browse files

selftests/bpf: Add subprogs to pyperf, strobemeta, and l4lb_noinline tests



Add use of non-inlined subprogs to few bigger selftests to excercise libbpf's
bpf2bpf handling logic. Also split l4lb_all selftest into two sub-tests.

Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200903203542.15944-13-andriin@fb.com
parent d86687ae
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ void test_bpf_verif_scale(void)
		{ "test_verif_scale3.o", BPF_PROG_TYPE_SCHED_CLS },

		{ "pyperf_global.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
		{ "pyperf_subprogs.o", BPF_PROG_TYPE_RAW_TRACEPOINT },

		/* full unroll by llvm */
		{ "pyperf50.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
@@ -86,6 +87,9 @@ void test_bpf_verif_scale(void)
		{ "strobemeta_nounroll1.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
		{ "strobemeta_nounroll2.o", BPF_PROG_TYPE_RAW_TRACEPOINT },

		/* non-inlined subprogs */
		{ "strobemeta_subprogs.o", BPF_PROG_TYPE_RAW_TRACEPOINT },

		{ "test_sysctl_loop1.o", BPF_PROG_TYPE_CGROUP_SYSCTL },
		{ "test_sysctl_loop2.o", BPF_PROG_TYPE_CGROUP_SYSCTL },

+4 −5
Original line number Diff line number Diff line
@@ -80,9 +80,8 @@ static void test_l4lb(const char *file)

void test_l4lb_all(void)
{
	const char *file1 = "./test_l4lb.o";
	const char *file2 = "./test_l4lb_noinline.o";

	test_l4lb(file1);
	test_l4lb(file2);
	if (test__start_subtest("l4lb_inline"))
		test_l4lb("test_l4lb.o");
	if (test__start_subtest("l4lb_noinline"))
		test_l4lb("test_l4lb_noinline.o");
}
+9 −2
Original line number Diff line number Diff line
@@ -67,7 +67,12 @@ typedef struct {
	void* co_name; // PyCodeObject.co_name
} FrameData;

static __always_inline void *get_thread_state(void *tls_base, PidData *pidData)
#ifdef SUBPROGS
__noinline
#else
__always_inline
#endif
static void *get_thread_state(void *tls_base, PidData *pidData)
{
	void* thread_state;
	int key;
@@ -155,7 +160,9 @@ struct {
} stackmap SEC(".maps");

#ifdef GLOBAL_FUNC
__attribute__((noinline))
__noinline
#elif defined(SUBPROGS)
static __noinline
#else
static __always_inline
#endif
+5 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2020 Facebook */
#define STACK_MAX_LEN 50
#define SUBPROGS
#include "pyperf.h"
+22 −8
Original line number Diff line number Diff line
@@ -266,8 +266,12 @@ struct tls_index {
	uint64_t offset;
};

static __always_inline void *calc_location(struct strobe_value_loc *loc,
					   void *tls_base)
#ifdef SUBPROGS
__noinline
#else
__always_inline
#endif
static void *calc_location(struct strobe_value_loc *loc, void *tls_base)
{
	/*
	 * tls_mode value is:
@@ -327,7 +331,12 @@ static __always_inline void *calc_location(struct strobe_value_loc *loc,
		: NULL;
}

static __always_inline void read_int_var(struct strobemeta_cfg *cfg,
#ifdef SUBPROGS
__noinline
#else
__always_inline
#endif
static void read_int_var(struct strobemeta_cfg *cfg,
			 size_t idx, void *tls_base,
			 struct strobe_value_generic *value,
			 struct strobemeta_payload *data)
@@ -440,7 +449,12 @@ static __always_inline void *read_map_var(struct strobemeta_cfg *cfg,
 * read_strobe_meta returns NULL, if no metadata was read; otherwise returns
 * pointer to *right after* payload ends
 */
static __always_inline void *read_strobe_meta(struct task_struct *task,
#ifdef SUBPROGS
__noinline
#else
__always_inline
#endif
static void *read_strobe_meta(struct task_struct *task,
			      struct strobemeta_payload *data)
{
	pid_t pid = bpf_get_current_pid_tgid() >> 32;
Loading