From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3624C433F5 for ; Mon, 3 Oct 2022 19:21:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229462AbiJCTVI (ORCPT ); Mon, 3 Oct 2022 15:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbiJCTVG (ORCPT ); Mon, 3 Oct 2022 15:21:06 -0400 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAB4236869; Mon, 3 Oct 2022 12:21:05 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1664824864; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/yRC3Hkc9Z0h2NdPQjTAEhCGDMQ/X2ETmgZ80q74nG8=; b=jfyH+cpjjSbDDS4oHbkZQdB17nEumLrcPT6OacVW7WQVGk5zfgw9Qsse+fTHUV6TC4b2rS qReiub1bK+fjsUsenFGQUMNOVaP9M0H0v05NaiILyLENYf9RjF/8z985cZACEtg9n4BzyP XleHP++iG6QDCBRaZC0uUH2/9eX88eg= Date: Mon, 3 Oct 2022 12:20:57 -0700 MIME-Version: 1.0 Subject: Re: [PATCH v2 1/2] bpf: Add kfuncs for storing struct task_struct * as a kptr Content-Language: en-US To: David Vernet , ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org Cc: kernel-team@fb.com, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, yhs@fb.com, song@kernel.org, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, tj@kernel.org, memxor@gmail.com References: <20221001144716.3403120-1-void@manifault.com> <20221001144716.3403120-2-void@manifault.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: <20221001144716.3403120-2-void@manifault.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ?