[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b27deaa1-7ab2-a969-3475-4fa78db34f86@linux.dev>
Date: Mon, 3 Oct 2022 12:20:57 -0700
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: David Vernet <void@...ifault.com>, ast@...nel.org,
daniel@...earbox.net, andrii@...nel.org
Cc: kernel-team@...com, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org, yhs@...com, song@...nel.org,
john.fastabend@...il.com, kpsingh@...nel.org, sdf@...gle.com,
haoluo@...gle.com, jolsa@...nel.org, tj@...nel.org,
memxor@...il.com
Subject: Re: [PATCH v2 1/2] bpf: Add kfuncs for storing struct task_struct *
as a kptr
On 10/1/22 7:47 AM, David Vernet wrote:
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index b069517a3da0..36cbe1b8f8b1 100644
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -1700,20 +1700,93 @@ bpf_base_func_proto(enum bpf_func_id func_id)
> }
> }
>
> -BTF_SET8_START(tracing_btf_ids)
> +__diag_push();
> +__diag_ignore_all("-Wmissing-prototypes",
> + "Global functions as their definitions will be in vmlinux BTF");
> +
> +/**
> + * bpf_task_acquire - Acquire a reference to a task. A task acquired by this
> + * kfunc which is not stored in a map as a kptr, must be released by calling
> + * bpf_task_release().
> + * @p: The task on which a reference is being acquired.
> + */
> +__used noinline
> +struct task_struct *bpf_task_acquire(struct task_struct *p)
> +{
> + refcount_inc(&p->rcu_users);
This probably needs to be refcount_inc_not_zero() also for the cases like during
the task free tracepoint ?
Powered by blists - more mailing lists