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

Configure Feed

Select the types of activity you want to include in your feed.

at master 54 lines 1.2 kB view raw
1// SPDX-License-Identifier: GPL-2.0 2/* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */ 3#include <vmlinux.h> 4#include <bpf/bpf_tracing.h> 5#include <bpf/bpf_helpers.h> 6#include "bpf_misc.h" 7#include "bpf_arena_spin_lock.h" 8 9struct { 10 __uint(type, BPF_MAP_TYPE_ARENA); 11 __uint(map_flags, BPF_F_MMAPABLE); 12 __uint(max_entries, 100); /* number of pages */ 13#ifdef __TARGET_ARCH_arm64 14 __ulong(map_extra, 0x1ull << 32); /* start of mmap() region */ 15#else 16 __ulong(map_extra, 0x1ull << 44); /* start of mmap() region */ 17#endif 18} arena SEC(".maps"); 19 20int cs_count; 21 22#if defined(ENABLE_ATOMICS_TESTS) && defined(__BPF_FEATURE_ADDR_SPACE_CAST) 23arena_spinlock_t __arena lock; 24int test_skip = 1; 25#else 26int test_skip = 2; 27#endif 28 29int counter; 30int limit; 31 32SEC("tc") 33int prog(void *ctx) 34{ 35 int ret = -2; 36 37#if defined(ENABLE_ATOMICS_TESTS) && defined(__BPF_FEATURE_ADDR_SPACE_CAST) 38 unsigned long flags; 39 40 if ((ret = arena_spin_lock_irqsave(&lock, flags))) { 41 if (ret == -EOPNOTSUPP) 42 test_skip = 3; 43 return ret; 44 } 45 if (counter != limit) 46 counter++; 47 bpf_repeat(cs_count); 48 ret = 0; 49 arena_spin_unlock_irqrestore(&lock, flags); 50#endif 51 return ret; 52} 53 54char _license[] SEC("license") = "GPL";