xref: /kernel/linux/linux-5.10/tools/testing/selftests/bpf/progs/loop5.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-5.10/tools/testing/selftests/bpf/progs/
18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci// Copyright (c) 2019 Facebook
38c2ecf20Sopenharmony_ci#include <linux/bpf.h>
48c2ecf20Sopenharmony_ci#include <bpf/bpf_helpers.h>
58c2ecf20Sopenharmony_ci#define barrier() __asm__ __volatile__("": : :"memory")
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_cichar _license[] SEC("license") = "GPL";
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ciSEC("socket")
108c2ecf20Sopenharmony_ciint while_true(volatile struct __sk_buff* skb)
118c2ecf20Sopenharmony_ci{
128c2ecf20Sopenharmony_ci	int i = 0;
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci	while (1) {
158c2ecf20Sopenharmony_ci		if (skb->len)
168c2ecf20Sopenharmony_ci			i += 3;
178c2ecf20Sopenharmony_ci		else
188c2ecf20Sopenharmony_ci			i += 7;
198c2ecf20Sopenharmony_ci		if (i == 9)
208c2ecf20Sopenharmony_ci			break;
218c2ecf20Sopenharmony_ci		barrier();
228c2ecf20Sopenharmony_ci		if (i == 10)
238c2ecf20Sopenharmony_ci			break;
248c2ecf20Sopenharmony_ci		barrier();
258c2ecf20Sopenharmony_ci		if (i == 13)
268c2ecf20Sopenharmony_ci			break;
278c2ecf20Sopenharmony_ci		barrier();
288c2ecf20Sopenharmony_ci		if (i == 14)
298c2ecf20Sopenharmony_ci			break;
308c2ecf20Sopenharmony_ci	}
318c2ecf20Sopenharmony_ci	return i;
328c2ecf20Sopenharmony_ci}
33

Indexes created Thu Nov 07 10:32:03 CST 2024