From: Song Chen <chensong_2000@126.com>
To: Leon Hwang <leon.hwang@linux.dev>,
Yonghong Song <yonghong.song@linux.dev>,
martin.lau@linux.dev, ast@kernel.org,
alexei.starovoitov@gmail.com, daniel@iogearbox.net,
andrii@kernel.org, eddyz87@gmail.com, song@kernel.org,
john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me,
haoluo@google.com, jolsa@kernel.org, kaitao.cheng@linux.dev
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] btf: reject to register duplicated kfunc
Date: Wed, 3 Jun 2026 17:15:52 +0800 [thread overview]
Message-ID: <1d2d1926-87fe-4437-ab67-4321749fbc83@126.com> (raw)
In-Reply-To: <6f7bfa86-7f9c-4ac3-baff-88b541e6a48a@linux.dev>
Hi,
在 2026/6/3 10:18, Leon Hwang 写道:
> On 3/6/26 01:13, Yonghong Song wrote:
>>
>>
>> On 6/2/26 4:07 AM, Song Chen wrote:
> [...]
>>> +
>>> +#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
>>> + mutex_lock(&btf_module_mutex);
>>> + list_for_each_entry_safe(btf_mod, tmp, &btf_modules, list) {
>>> + if (btf_mod->btf == btf)
>>> + continue;
>>> + id = btf_find_by_name_kind(btf_mod->btf, func_name, kind);
>>> + if (id >= 0) {
>>> + pr_err("kfunc %s (id: %d) is already present in module
>>> %s.\n",
>>> + func_name, id, btf_mod->module->name);
>>> + mutex_unlock(&btf_module_mutex);
>>> + return -EINVAL;
>>
>> Let us avoid the above mutex_unlock and 'return -EINVAL', just do
>> err = -EINVAL;
>> break;
>>
>
> Better to use guard(mutex)(&btf_module_mutex)?
>
This is the first time i used guard and it's awesome. I have tested in
my code and will send a new patch later, many thanks.
> Thanks,
> Leon
>
>>> [...]
Song
next prev parent reply other threads:[~2026-06-03 9:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 11:07 Song Chen
2026-06-02 11:34 ` Kaitao Cheng
2026-06-02 17:13 ` Yonghong Song
2026-06-03 2:18 ` Leon Hwang
2026-06-03 9:15 ` Song Chen [this message]
2026-06-03 9:11 ` Song Chen
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=1d2d1926-87fe-4437-ab67-4321749fbc83@126.com \
--to=chensong_2000@126.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kaitao.cheng@linux.dev \
--cc=kpsingh@kernel.org \
--cc=leon.hwang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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
all inboxes | Powered by JetHome®