From: Martin KaFai Lau <martin.lau@linux.dev>
To: Amery Hung <ameryhung@gmail.com>
Cc: bpf@vger.kernel.org, daniel@iogearbox.net, andrii@kernel.org,
alexei.starovoitov@gmail.com, martin.lau@kernel.org,
houtao@huaweicloud.com, sinquersw@gmail.com,
davemarchevsky@fb.com, Amery Hung <amery.hung@bytedance.com>
Subject: Re: [PATCH v3 bpf-next 1/5] bpf: Let callers of btf_parse_kptr() track life cycle of prog btf
Date: Fri, 9 Aug 2024 18:29:05 -0700 [thread overview]
Message-ID: <55b86502-f125-4d59-b356-7fbfb2f6d845@linux.dev> (raw)
In-Reply-To: <2f9c21f8-1108-4f12-a06e-58837b53e7fe@linux.dev>
On 8/9/24 4:06 PM, Martin KaFai Lau wrote:
> On 8/8/24 5:51 PM, Amery Hung wrote:
>> btf_parse_kptr() and btf_record_free() do btf_get() and btf_put()
>> respectively when working on btf_record in program and map if there are
>> kptr fields. If the kptr is from program BTF, since both callers has
>> already tracked the life cycle of program BTF, it is safe to remove the
>> btf_get() and btf_put().
>>
>> This change prevents memory leak of program BTF later when we start
>> searching for kptr fields when building btf_record for program. It can
>> happen when the btf fd is closed. The btf_put() corresponding to the
>> btf_get() in btf_parse_kptr() was supposed to be called by
>> btf_record_free() in btf_free_struct_meta_tab() in btf_free(). However,
>> it will never happen since the invocation of btf_free() depends on the
>> refcount of the btf to become 0 in the first place.
>>
>> Signed-off-by: Amery Hung <amery.hung@bytedance.com>
>
> Acked-by: Martin KaFai Lau <martin.lau@kernel.org>
>
> Need to fix the checkpatch warning though:
>
> WARNING: From:/Signed-off-by: email address mismatch: 'From: Amery Hung
> <ameryhung@gmail.com>' != 'Signed-off-by: Amery Hung <amery.hung@bytedance.com>'
>
There is a veristat failure also:
https://github.com/kernel-patches/bpf/actions/runs/10311824065/job/28546213338
|File |Program |Verdict |States Diff (%)|
|----------------------|--------------------------------|-----------------------|---------------|
|local_kptr_stash.bpf.o|refcount_acquire_without_unstash|success -> failure (!!)|-100.00 % |
|local_kptr_stash.bpf.o|stash_local_with_root |success -> failure (!!)|-100.00 % |
|local_kptr_stash.bpf.o|stash_plain |success -> failure (!!)|-100.00 % |
|local_kptr_stash.bpf.o|stash_rb_nodes |success -> failure (!!)|-100.00 % |
|local_kptr_stash.bpf.o|stash_refcounted_node |success -> failure (!!)|-100.00 % |
|local_kptr_stash.bpf.o|stash_test_ref_kfunc |success -> failure (!!)|-100.00 % |
|local_kptr_stash.bpf.o|unstash_rb_node |success -> failure (!!)|-100.00 % |
next prev parent reply other threads:[~2024-08-10 1:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-09 0:51 [PATCH v3 bpf-next 0/5] Support bpf_kptr_xchg into local kptr Amery Hung
2024-08-09 0:51 ` [PATCH v3 bpf-next 1/5] bpf: Let callers of btf_parse_kptr() track life cycle of prog btf Amery Hung
2024-08-09 23:06 ` Martin KaFai Lau
2024-08-10 1:29 ` Martin KaFai Lau [this message]
2024-08-10 10:14 ` Hou Tao
2024-08-09 0:51 ` [PATCH v3 bpf-next 2/5] bpf: Search for kptrs in prog BTF structs Amery Hung
2024-08-10 10:17 ` Hou Tao
2024-08-09 0:51 ` [PATCH v3 bpf-next 3/5] bpf: Rename ARG_PTR_TO_KPTR -> ARG_KPTR_XCHG_DEST Amery Hung
2024-08-09 0:51 ` [PATCH v3 bpf-next 4/5] bpf: Support bpf_kptr_xchg into local kptr Amery Hung
2024-08-09 0:51 ` [PATCH v3 bpf-next 5/5] selftests/bpf: Test bpf_kptr_xchg stashing " Amery Hung
2024-08-10 10:32 ` Hou Tao
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=55b86502-f125-4d59-b356-7fbfb2f6d845@linux.dev \
--to=martin.lau@linux.dev \
--cc=alexei.starovoitov@gmail.com \
--cc=amery.hung@bytedance.com \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davemarchevsky@fb.com \
--cc=houtao@huaweicloud.com \
--cc=martin.lau@kernel.org \
--cc=sinquersw@gmail.com \
/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