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