1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */ 3 4 #include "vmlinux.h" 5 #include <bpf/bpf_helpers.h> 6 #include "bpf_misc.h" 7 8 char _license[] SEC("license") = "GPL"; 9 10 int nr_loops; 11 long hits; 12 outer_loop(__u32 index,void * data)13static int outer_loop(__u32 index, void *data) 14 { 15 int i; 16 17 /* 18 * Empty body: the work being measured is the open-coded numeric iterator itself 19 * (bpf_iter_num_new/next/destroy behind bpf_for()). 20 */ 21 bpf_for(i, 0, nr_loops) 22 ; 23 __sync_add_and_fetch(&hits, nr_loops); 24 return 0; 25 } 26 27 SEC("fentry/" SYS_PREFIX "sys_getpgid") benchmark(void * ctx)28int benchmark(void *ctx) 29 { 30 bpf_loop(1000, outer_loop, NULL, 0); 31 return 0; 32 } 33