From: Konstantin Ananyev <konstantin.ananyev@huawei.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
"dev@dpdk.org" <dev@dpdk.org>
Subject: RE: [PATCH v2 1/2] bpf: add allocation annotations to functions
Date: Mon, 20 Oct 2025 14:53:06 +0000 [thread overview]
Message-ID: <ccddf99e58ff48a1bf44a6308a6595ea@huawei.com> (raw)
In-Reply-To: <20251019204106.29043-2-stephen@networkplumber.org>
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Sunday, October 19, 2025 9:40 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Konstantin Ananyev
> <konstantin.ananyev@huawei.com>
> Subject: [PATCH v2 1/2] bpf: add allocation annotations to functions
>
> In commit 80da7efbb4c4 ("eal: annotate allocation functions")
> helper macros were added to provide compiler information to
> detect misuse of alloc/free combinations. This covered many
> of the functions in DPDK but missed the case of data allocated
> by BPF load functions.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> lib/bpf/rte_bpf.h | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/lib/bpf/rte_bpf.h b/lib/bpf/rte_bpf.h
> index 80ebb0210f..309d84bc51 100644
> --- a/lib/bpf/rte_bpf.h
> +++ b/lib/bpf/rte_bpf.h
> @@ -18,6 +18,7 @@
>
> #include <rte_common.h>
> #include <rte_mbuf.h>
> +#include <rte_malloc.h>
> #include <bpf_def.h>
>
> #ifdef __cplusplus
> @@ -128,7 +129,8 @@ rte_bpf_destroy(struct rte_bpf *bpf);
> * - ENOMEM - can't reserve enough memory
> */
> struct rte_bpf *
> -rte_bpf_load(const struct rte_bpf_prm *prm);
> +rte_bpf_load(const struct rte_bpf_prm *prm)
> + __rte_malloc __rte_dealloc(rte_bpf_destroy, 1);
>
> /**
> * Create a new eBPF execution context and load BPF code from given ELF
> @@ -152,7 +154,9 @@ rte_bpf_load(const struct rte_bpf_prm *prm);
> */
> struct rte_bpf *
> rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname,
> - const char *sname);
> + const char *sname)
> + __rte_malloc __rte_dealloc(rte_bpf_destroy, 1);
> +
> /**
> * Execute given BPF bytecode.
> *
> @@ -228,7 +232,8 @@ struct bpf_program;
> * - ENOTSUP - operation not supported
> */
> struct rte_bpf_prm *
> -rte_bpf_convert(const struct bpf_program *prog);
> +rte_bpf_convert(const struct bpf_program *prog)
> + __rte_malloc __rte_dealloc_free;
>
> #ifdef __cplusplus
> }
> --
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> 2.51.0
next prev parent reply other threads:[~2025-10-20 14:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-19 16:59 [PATCH 0/2] minor bpf improvements Stephen Hemminger
2025-10-19 16:59 ` [PATCH 1/2] bpf: add allocation annotations to functions Stephen Hemminger
2025-10-19 16:59 ` [PATCH 2/2] bpf: remove dependency on vla Stephen Hemminger
2025-10-19 20:39 ` [PATCH v2 0/2] minor bpf improvements Stephen Hemminger
2025-10-19 20:39 ` [PATCH v2 1/2] bpf: add allocation annotations to functions Stephen Hemminger
2025-10-20 14:53 ` Konstantin Ananyev [this message]
2025-10-19 20:39 ` [PATCH v2 2/2] bpf: remove dependency on vla Stephen Hemminger
2025-10-20 14:55 ` Konstantin Ananyev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ccddf99e58ff48a1bf44a6308a6595ea@huawei.com \
--to=konstantin.ananyev@huawei.com \
--cc=dev@dpdk.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).