From patchwork Fri Mar 8 01:08:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 13586419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37C1CC54798 for ; Fri, 8 Mar 2024 01:09:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B30D66B0309; Thu, 7 Mar 2024 20:09:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ADEEF6B030B; Thu, 7 Mar 2024 20:09:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 909FA6B030C; Thu, 7 Mar 2024 20:09:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7BB876B0309 for ; Thu, 7 Mar 2024 20:09:05 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 59233A122B for ; Fri, 8 Mar 2024 01:09:05 +0000 (UTC) X-FDA: 81872087850.25.9E05E2D Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf15.hostedemail.com (Postfix) with ESMTP id 77AB6A0005 for ; Fri, 8 Mar 2024 01:09:03 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SV3tEgWN; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709860143; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8D6++xUxvD64ipEi92YPdyv+HOEeUH/sHJwtJKhwLCY=; b=OgxhCLntskCmX2usGOwHbX6sqm+b0nM9lYEzVhRjVnwiK3HCbfLsk9hVmN4Oh+qjJzDADC Tqsx1skzhPLURyTBoI/IYzkZswS0vcVyrDIhPsx+V4RH5fbBwNxTrF9tfKVzAX2LT0VxlV LLLctuT4Vw6IsKXwseCROFDqEVn5tQQ= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SV3tEgWN; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709860143; a=rsa-sha256; cv=none; b=cRLn9X4qOnhTrwMx32wIE6cgyKUs5XyublWiV+8HSkoyCedO86I+9UnnC9J0dFLs2CBzft 90XelYaUvFloIlwLl+3Qj4S/Mv/1IJ/W9Hh+aeg5PujcWnltX61mVC/R/m5nWweb2OF6k6 IoqPJUYjf7sZnr3VmiH/48xCz1p4z4c= Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1dd2dca2007so1871545ad.2 for ; Thu, 07 Mar 2024 17:09:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709860142; x=1710464942; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8D6++xUxvD64ipEi92YPdyv+HOEeUH/sHJwtJKhwLCY=; b=SV3tEgWNicze35BeWmoQpWsU4UdyBOCm3gcj0n09BwJsyiLOd1MUffJSxu42U7i3NA f+BzaOIRoDzeiQoBX9D+ajSQyqeEljJikvUX7XuXuvfebBkMW2zzIyp+/s6ntaDHlXoE GGJz4OnHAf4Sz7ufO14pH82s4caQsahwlVoOY1tmgLW6iD977dO69sPhxygnFeU/0T0o kmcfKlNwwDzGpQctejZQoOuQgsrXMrQAbshSTX3FxZs58C9YDa5ouUKcwfW1gTdbHIli 1nq4HetdSbvs1fWzjzCjXo8e0cvVc8GNmclKDtsIG7Q4tW1e213RYvPHJ4Y/o9eqDnkr AcKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709860142; x=1710464942; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8D6++xUxvD64ipEi92YPdyv+HOEeUH/sHJwtJKhwLCY=; b=uEl4UnepS+LwwooMZau9MDj3nd3rFbBIIj/0c4LqAbDPc48Hs1nRLoC7nDJNh3a7WU fOQ7SNjM1BNoLqAYjA2VU21iIiD2znsz+KEh3yNBPPlriFh9UT5h5P6KHQRt5j0cHU06 dd9rR7H/DAgQlILY5ZNwc/Yy2eSo42DrC2LGrKvSBQSIp796SpL3GWA/9X/tN4WYCzKB S5vkd5JxfTRtWwrSLKGQqIFFAVnRpTWm6Pl8u9FEocvVoRsSMbPLx/TngqqKVPcq1j2p 5bOoONbe+leV+xffHqeNqYYJoScRIS3WR4oQj5aEEfi+Ny6mZKgaCrr7dQuFCz75raIv rVSA== X-Forwarded-Encrypted: i=1; AJvYcCXlfzlrRFhbrNC4D3IFSJeiQ/XLFJGZ93oHbPRB3/tcj8fPRhbopDC/ccTXgF+x4wULeM7dWFT3GPH94efDzzo3MdA= X-Gm-Message-State: AOJu0YxadxvBt5FvwXZXjt7K0Fk0OknsZAIvZP2OGyXho5LeQC1totkp c6+SnvXTvUJLbE9ax3Rs6+ONyoeJBgxVomGfRZzyJy4ykQi0CQq2 X-Google-Smtp-Source: AGHT+IEb5Ff0MnhqlTusueikYxMdd/Bze2OZWDejIaWF+sfCU+yKkQtF/zprJoiN+xBfdiuoHHXzMA== X-Received: by 2002:a17:902:f786:b0:1dc:ad86:8f41 with SMTP id q6-20020a170902f78600b001dcad868f41mr12030785pln.28.1709860142341; Thu, 07 Mar 2024 17:09:02 -0800 (PST) Received: from localhost.localdomain ([2620:10d:c090:400::5:428c]) by smtp.gmail.com with ESMTPSA id f6-20020a170902ce8600b001db45bae92dsm15276659plg.74.2024.03.07.17.09.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 07 Mar 2024 17:09:02 -0800 (PST) From: Alexei Starovoitov To: bpf@vger.kernel.org Cc: daniel@iogearbox.net, andrii@kernel.org, torvalds@linux-foundation.org, brho@google.com, hannes@cmpxchg.org, akpm@linux-foundation.org, urezki@gmail.com, hch@infradead.org, linux-mm@kvack.org, kernel-team@fb.com Subject: [PATCH v3 bpf-next 13/14] selftests/bpf: Add bpf_arena_list test. Date: Thu, 7 Mar 2024 17:08:11 -0800 Message-Id: <20240308010812.89848-14-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20240308010812.89848-1-alexei.starovoitov@gmail.com> References: <20240308010812.89848-1-alexei.starovoitov@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 77AB6A0005 X-Stat-Signature: rym7wiyndtex44jpkzgqez81ojyoujip X-HE-Tag: 1709860143-213761 X-HE-Meta: U2FsdGVkX19sZBeCXbBp9M8128winwQ/cNiuROSwGlxMW+/OHAEcG+YguqzcUW3Sgzfa6s8sHCWiwvd3MSuuPIpROpzWmm27W7SGO0Ngi8qKdysr4nbi2JVq+ImHheytuWGtZMD487fsxLoSVtREvIM9TrYzANUyUowWU6uYFppq57/bJY0XH6cIFt2gDGSuJRQWyYfSyMux1fBn4LVOEwlHhF/yUdonG4JEiXFVVmYOjMtUsxMc48H8h0DwkrqxQIdGnZQMtFufMF/HazcpX7iuEBSL+TlXqOcLhnoQBka4Xnsu6U475CJBU5Nrzu96B8KnvVAlW5tmsMyxtVxXqznBRNifqvAISywlspWq/oB2FwCX/TdkVEW4/qN2NzOoToG4PGiB7uEmhlQzK2WGbbsH3S2KfuAwPczQiL7cfEJIljrz4lzOc0PEdN+OI/+BE6ZoY8DI3RpOgYe08exky7mRY6pNOeZ+OJ/yAdvzDkZIK20AyeTi3/tzfUqRNVkxGzydsaouZgTfCcxQEbA9XvvMnl3uRw8ET8kvspKz8D6PY2DXKu4fHCeVDODqfazB07OQBBiaAU/9S0V4m/O2s7GAulr2W0jWTOvP7y6ry6AnxAGqm+P7kFQ/MdKS/pumK+ddGd8YsU32tIFMOYYCsd6EzNpjA07ur4q/+psJzjLmSaEy4DnjpmT89E3Mltli1HCGvJ3PkS545Vjenh/wboHpRwmNsIts6vtN3WRP/IhhjP6UGawO/R2ae7IcYOKE/3+6DTt+cIvn2KhHmb1oSwDw4EQuFbhj74NwUY2F06+zOaNks+UE5UK/nR8gZLA4m+Q+jQTEoZbA15MI5oGtCRrKvfGSYFDvKl50V8jrwehvIVEOwJ3f+ORw6BHt0SmIfoF2IdyLmAs7c4yTJcZBi6PSLfXoRu2fVrXIarJHtpDE0IN3TqfMY35A/1AMrv/DTEYoIulCnELLsHAteNq WLeVzucZ kTpOfZSYj9S/MoQhsl6hI8pxKnLOjfhWPGv570keFk2rMDoY6V5j0ixq2lyZ1rWQXGMdDBE/Icv8dgIS2kskN0X6gpJaIPBQzAvAmuJwf+BvmNLucWdKrFsOFCwAm7Kkd+ru6J2Bd4pm/Vjnut3X+7HuADRaMszWuzISrmmNJjmp85HDVsoble7Kr2auEeWN8e8XC+ARFAqkD0of1iiCUIaGjPWd0RZ6g1mWIbfQUz+C5muW+uHTV7mgA4EU3jGQoYJPNRzsp0VGZFHT3Y4O7FSwz/ONUzJxFx77E2CyNhf+Ap7tlHw3cBRUM7WA0J6uM436o8f9HAzviSqc7SRYicbVMPaNBqR5RdurxZwYSZvfp0Ohe+OGwhc5AetJhAKKNrqSjv7Ui78MCz6OyxPwp2doBVs8ucOLPoivdC0LH+b9rrxkb3Ld2aq4oM+OxjiHlrr6Zcc7jOiO8Bq5gCyUSQM27sJHWC4YxAy2xZDiaI1Cd2J6u6ib/Od6vBf5k0U7wrjQbwpITb6mNPJi7X37AiV9m+GQUxM6jyrcTtHi0FVGPhUDtP+B2BKEGw4U1Cp2Moud2i8vRuZKxG3A+3AK94iqXEfHE42zkLb6H X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alexei Starovoitov bpf_arena_alloc.h - implements page_frag allocator as a bpf program. bpf_arena_list.h - doubly linked link list as a bpf program. Compiled as a bpf program and as native C code. Signed-off-by: Alexei Starovoitov --- tools/testing/selftests/bpf/bpf_arena_alloc.h | 67 ++++++++++++++ tools/testing/selftests/bpf/bpf_arena_list.h | 92 +++++++++++++++++++ .../selftests/bpf/prog_tests/arena_list.c | 68 ++++++++++++++ .../testing/selftests/bpf/progs/arena_list.c | 87 ++++++++++++++++++ 4 files changed, 314 insertions(+) create mode 100644 tools/testing/selftests/bpf/bpf_arena_alloc.h create mode 100644 tools/testing/selftests/bpf/bpf_arena_list.h create mode 100644 tools/testing/selftests/bpf/prog_tests/arena_list.c create mode 100644 tools/testing/selftests/bpf/progs/arena_list.c diff --git a/tools/testing/selftests/bpf/bpf_arena_alloc.h b/tools/testing/selftests/bpf/bpf_arena_alloc.h new file mode 100644 index 000000000000..c27678299e0c --- /dev/null +++ b/tools/testing/selftests/bpf/bpf_arena_alloc.h @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ +#pragma once +#include "bpf_arena_common.h" + +#ifndef __round_mask +#define __round_mask(x, y) ((__typeof__(x))((y)-1)) +#endif +#ifndef round_up +#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) +#endif + +#ifdef __BPF__ +#define NR_CPUS (sizeof(struct cpumask) * 8) + +static void __arena * __arena page_frag_cur_page[NR_CPUS]; +static int __arena page_frag_cur_offset[NR_CPUS]; + +/* Simple page_frag allocator */ +static inline void __arena* bpf_alloc(unsigned int size) +{ + __u64 __arena *obj_cnt; + __u32 cpu = bpf_get_smp_processor_id(); + void __arena *page = page_frag_cur_page[cpu]; + int __arena *cur_offset = &page_frag_cur_offset[cpu]; + int offset; + + size = round_up(size, 8); + if (size >= PAGE_SIZE - 8) + return NULL; + if (!page) { +refill: + page = bpf_arena_alloc_pages(&arena, NULL, 1, NUMA_NO_NODE, 0); + if (!page) + return NULL; + cast_kern(page); + page_frag_cur_page[cpu] = page; + *cur_offset = PAGE_SIZE - 8; + obj_cnt = page + PAGE_SIZE - 8; + *obj_cnt = 0; + } else { + cast_kern(page); + obj_cnt = page + PAGE_SIZE - 8; + } + + offset = *cur_offset - size; + if (offset < 0) + goto refill; + + (*obj_cnt)++; + *cur_offset = offset; + return page + offset; +} + +static inline void bpf_free(void __arena *addr) +{ + __u64 __arena *obj_cnt; + + addr = (void __arena *)(((long)addr) & ~(PAGE_SIZE - 1)); + obj_cnt = addr + PAGE_SIZE - 8; + if (--(*obj_cnt) == 0) + bpf_arena_free_pages(&arena, addr, 1); +} +#else +static inline void __arena* bpf_alloc(unsigned int size) { return NULL; } +static inline void bpf_free(void __arena *addr) {} +#endif diff --git a/tools/testing/selftests/bpf/bpf_arena_list.h b/tools/testing/selftests/bpf/bpf_arena_list.h new file mode 100644 index 000000000000..b99b9f408eff --- /dev/null +++ b/tools/testing/selftests/bpf/bpf_arena_list.h @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ +#pragma once +#include "bpf_arena_common.h" + +struct arena_list_node; + +typedef struct arena_list_node __arena arena_list_node_t; + +struct arena_list_node { + arena_list_node_t *next; + arena_list_node_t * __arena *pprev; +}; + +struct arena_list_head { + struct arena_list_node __arena *first; +}; +typedef struct arena_list_head __arena arena_list_head_t; + +#define list_entry(ptr, type, member) arena_container_of(ptr, type, member) + +#define list_entry_safe(ptr, type, member) \ + ({ typeof(*ptr) * ___ptr = (ptr); \ + ___ptr ? ({ cast_kern(___ptr); list_entry(___ptr, type, member); }) : NULL; \ + }) + +#ifndef __BPF__ +static inline void *bpf_iter_num_new(struct bpf_iter_num *it, int i, int j) { return NULL; } +static inline void bpf_iter_num_destroy(struct bpf_iter_num *it) {} +static inline bool bpf_iter_num_next(struct bpf_iter_num *it) { return true; } +#define cond_break ({}) +#endif + +/* Safely walk link list elements. Deletion of elements is allowed. */ +#define list_for_each_entry(pos, head, member) \ + for (void * ___tmp = (pos = list_entry_safe((head)->first, \ + typeof(*(pos)), member), \ + (void *)0); \ + pos && ({ ___tmp = (void *)pos->member.next; 1; }); \ + cond_break, \ + pos = list_entry_safe((void __arena *)___tmp, typeof(*(pos)), member)) + +static inline void list_add_head(arena_list_node_t *n, arena_list_head_t *h) +{ + arena_list_node_t *first = h->first, * __arena *tmp; + + cast_user(first); + cast_kern(n); + WRITE_ONCE(n->next, first); + cast_kern(first); + if (first) { + tmp = &n->next; + cast_user(tmp); + WRITE_ONCE(first->pprev, tmp); + } + cast_user(n); + WRITE_ONCE(h->first, n); + + tmp = &h->first; + cast_user(tmp); + cast_kern(n); + WRITE_ONCE(n->pprev, tmp); +} + +static inline void __list_del(arena_list_node_t *n) +{ + arena_list_node_t *next = n->next, *tmp; + arena_list_node_t * __arena *pprev = n->pprev; + + cast_user(next); + cast_kern(pprev); + tmp = *pprev; + cast_kern(tmp); + WRITE_ONCE(tmp, next); + if (next) { + cast_user(pprev); + cast_kern(next); + WRITE_ONCE(next->pprev, pprev); + } +} + +#define POISON_POINTER_DELTA 0 + +#define LIST_POISON1 ((void __arena *) 0x100 + POISON_POINTER_DELTA) +#define LIST_POISON2 ((void __arena *) 0x122 + POISON_POINTER_DELTA) + +static inline void list_del(arena_list_node_t *n) +{ + __list_del(n); + n->next = LIST_POISON1; + n->pprev = LIST_POISON2; +} diff --git a/tools/testing/selftests/bpf/prog_tests/arena_list.c b/tools/testing/selftests/bpf/prog_tests/arena_list.c new file mode 100644 index 000000000000..e61886debab1 --- /dev/null +++ b/tools/testing/selftests/bpf/prog_tests/arena_list.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ +#include +#include +#include + +#define PAGE_SIZE 4096 + +#include "bpf_arena_list.h" +#include "arena_list.skel.h" + +struct elem { + struct arena_list_node node; + __u64 value; +}; + +static int list_sum(struct arena_list_head *head) +{ + struct elem __arena *n; + int sum = 0; + + list_for_each_entry(n, head, node) + sum += n->value; + return sum; +} + +static void test_arena_list_add_del(int cnt) +{ + LIBBPF_OPTS(bpf_test_run_opts, opts); + struct arena_list *skel; + int expected_sum = (u64)cnt * (cnt - 1) / 2; + int ret, sum; + + skel = arena_list__open_and_load(); + if (!ASSERT_OK_PTR(skel, "arena_list__open_and_load")) + return; + + skel->bss->cnt = cnt; + ret = bpf_prog_test_run_opts(bpf_program__fd(skel->progs.arena_list_add), &opts); + ASSERT_OK(ret, "ret_add"); + ASSERT_OK(opts.retval, "retval"); + if (skel->bss->skip) { + printf("%s:SKIP:compiler doesn't support arena_cast\n", __func__); + test__skip(); + goto out; + } + sum = list_sum(skel->bss->list_head); + ASSERT_EQ(sum, expected_sum, "sum of elems"); + ASSERT_EQ(skel->arena->arena_sum, expected_sum, "__arena sum of elems"); + ASSERT_EQ(skel->arena->test_val, cnt + 1, "num of elems"); + + ret = bpf_prog_test_run_opts(bpf_program__fd(skel->progs.arena_list_del), &opts); + ASSERT_OK(ret, "ret_del"); + sum = list_sum(skel->bss->list_head); + ASSERT_EQ(sum, 0, "sum of list elems after del"); + ASSERT_EQ(skel->bss->list_sum, expected_sum, "sum of list elems computed by prog"); + ASSERT_EQ(skel->arena->arena_sum, expected_sum, "__arena sum of elems"); +out: + arena_list__destroy(skel); +} + +void test_arena_list(void) +{ + if (test__start_subtest("arena_list_1")) + test_arena_list_add_del(1); + if (test__start_subtest("arena_list_1000")) + test_arena_list_add_del(1000); +} diff --git a/tools/testing/selftests/bpf/progs/arena_list.c b/tools/testing/selftests/bpf/progs/arena_list.c new file mode 100644 index 000000000000..cd35b8448435 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/arena_list.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ +#include +#include +#include +#include +#include "bpf_experimental.h" + +struct { + __uint(type, BPF_MAP_TYPE_ARENA); + __uint(map_flags, BPF_F_MMAPABLE); + __uint(max_entries, 100); /* number of pages */ +#ifdef __TARGET_ARCH_arm64 + __ulong(map_extra, 0x1ull << 32); /* start of mmap() region */ +#else + __ulong(map_extra, 0x1ull << 44); /* start of mmap() region */ +#endif +} arena SEC(".maps"); + +#include "bpf_arena_alloc.h" +#include "bpf_arena_list.h" + +struct elem { + struct arena_list_node node; + __u64 value; +}; + +struct arena_list_head __arena *list_head; +int list_sum; +int cnt; +bool skip = false; + +#ifdef __BPF_FEATURE_ARENA_CAST +long __arena arena_sum; +int __arena test_val = 1; +struct arena_list_head __arena global_head; +#else +long arena_sum SEC(".arena.1"); +int test_val SEC(".arena.1"); +#endif + +int zero; + +SEC("syscall") +int arena_list_add(void *ctx) +{ +#ifdef __BPF_FEATURE_ARENA_CAST + __u64 i; + + list_head = &global_head; + + for (i = zero; i < cnt; cond_break, i++) { + struct elem __arena *n = bpf_alloc(sizeof(*n)); + + test_val++; + n->value = i; + arena_sum += i; + list_add_head(&n->node, list_head); + } +#else + skip = true; +#endif + return 0; +} + +SEC("syscall") +int arena_list_del(void *ctx) +{ +#ifdef __BPF_FEATURE_ARENA_CAST + struct elem __arena *n; + int sum = 0; + + arena_sum = 0; + list_for_each_entry(n, list_head, node) { + sum += n->value; + arena_sum += n->value; + list_del(&n->node); + bpf_free(n); + } + list_sum = sum; +#else + skip = true; +#endif + return 0; +} + +char _license[] SEC("license") = "GPL";