Re: [PATCH bpf-next v4 24/24] selftests/bpf: Add BPF linked list API tests

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

 



On 11/3/22 3:10 PM, Kumar Kartikeya Dwivedi wrote:
> Include various tests covering the success and failure cases. Also, run
> the success cases at runtime to verify correctness of linked list
> manipulation routines, in addition to ensuring successful verification.
> 
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx>
> ---

[...]

> diff --git a/tools/testing/selftests/bpf/progs/linked_list.c b/tools/testing/selftests/bpf/progs/linked_list.c
> new file mode 100644
> index 000000000000..eed0b2c1eb4a
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/linked_list.c
> @@ -0,0 +1,330 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <vmlinux.h>
> +#include <bpf/bpf_tracing.h>
> +#include <bpf/bpf_helpers.h>
> +#include <bpf/bpf_core_read.h>
> +#include "bpf_experimental.h"
> +
> +#ifndef ARRAY_SIZE
> +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
> +#endif
> +
> +struct bar {
> +	struct bpf_list_node node;
> +	int data;
> +};
> +
> +struct foo {
> +	struct bpf_list_node node;
> +	struct bpf_list_head head __contains(bar, node);
> +	struct bpf_spin_lock lock;
> +	int data;
> +};
> +
> +struct map_value {
> +	struct bpf_list_head head __contains(foo, node);
> +	struct bpf_spin_lock lock;
> +	int data;
> +};
> +
> +struct array_map {
> +	__uint(type, BPF_MAP_TYPE_ARRAY);
> +	__type(key, int);
> +	__type(value, struct map_value);
> +	__uint(max_entries, 1);
> +} array_map SEC(".maps");
> +
> +#define private(name) SEC(".data." #name) __hidden __attribute__((aligned(8)))

This __attribute__((aligned(8))) causes my clang to fail to build this selftest.
It fails with:

  fatal error: error in backend: unable to write nop sequence of 4 bytes

Tracked it down to llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp:

  bool BPFAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
                                   const MCSubtargetInfo *STI) const {
    if ((Count % 8) != 0)
      return false;

Presumably since ".data.A" section is PROGBITS the compiler tries to write
4 bytes of nop before / between the variables, but fails.

I'm using a clang built off of a very recent LLVM commit [0]. David Vernet
was able to successfully build the selftests with a clang built from
late August's tree, so maybe it's my clang version or some other toolchain
issue. Which clang did you use to build this?

[0]: github.com/llvm/llvm-project/commit/2a827e4a988b614bc6f70abe00308ceeb50dcd0a



[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