* [PATCH bpf-next] bpf/btf: Use btf_type_str() whenever possible @ 2022-09-14 2:13 Peilin Ye 2022-09-16 18:37 ` Martin KaFai Lau 2022-09-16 20:28 ` [PATCH bpf-next v2] " Peilin Ye 0 siblings, 2 replies; 5+ messages in thread From: Peilin Ye @ 2022-09-14 2:13 UTC (permalink / raw) To: Martin KaFai Lau Cc: Peilin Ye, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Song Liu, Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf, linux-kernel, Peilin Ye From: Peilin Ye <peilin.ye@bytedance.com> We have btf_type_str(). Use it whenever possible in btf.c, instead of "btf_kind_str[BTF_INFO_KIND(t->info)]". Signed-off-by: Peilin Ye <peilin.ye@bytedance.com> --- kernel/bpf/btf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index cad4657ba2ce..81dc7423d723 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -5403,7 +5403,7 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, if (!btf_type_is_small_int(t)) { bpf_log(log, "ret type %s not allowed for fmod_ret\n", - btf_kind_str[BTF_INFO_KIND(t->info)]); + btf_type_str(t)); return false; } break; @@ -5430,7 +5430,7 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, "func '%s' arg%d '%s' has type %s. Only pointer access is allowed\n", tname, arg, __btf_name_by_offset(btf, t->name_off), - btf_kind_str[BTF_INFO_KIND(t->info)]); + btf_type_str(t)); return false; } @@ -5514,11 +5514,11 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, if (!btf_type_is_struct(t)) { bpf_log(log, "func '%s' arg%d type %s is not a struct\n", - tname, arg, btf_kind_str[BTF_INFO_KIND(t->info)]); + tname, arg, btf_type_str(t)); return false; } bpf_log(log, "func '%s' arg%d has btf_id %d type %s '%s'\n", - tname, arg, info->btf_id, btf_kind_str[BTF_INFO_KIND(t->info)], + tname, arg, info->btf_id, btf_type_str(t), __btf_name_by_offset(btf, t->name_off)); return true; } @@ -5924,7 +5924,7 @@ int btf_distill_func_proto(struct bpf_verifier_log *log, if (ret < 0) { bpf_log(log, "The function %s return type %s is unsupported.\n", - tname, btf_kind_str[BTF_INFO_KIND(t->info)]); + tname, btf_type_str(t)); return -EINVAL; } m->ret_size = ret; @@ -5940,7 +5940,7 @@ int btf_distill_func_proto(struct bpf_verifier_log *log, if (ret < 0) { bpf_log(log, "The function %s arg%d type %s is unsupported.\n", - tname, i, btf_kind_str[BTF_INFO_KIND(t->info)]); + tname, i, btf_type_str(t)); return -EINVAL; } if (ret == 0) { @@ -6593,7 +6593,7 @@ int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog, continue; } bpf_log(log, "Arg#%d type %s in %s() is not supported yet.\n", - i, btf_kind_str[BTF_INFO_KIND(t->info)], tname); + i, btf_type_str(t), tname); return -EINVAL; } return 0; -- 2.20.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH bpf-next] bpf/btf: Use btf_type_str() whenever possible 2022-09-14 2:13 [PATCH bpf-next] bpf/btf: Use btf_type_str() whenever possible Peilin Ye @ 2022-09-16 18:37 ` Martin KaFai Lau 2022-09-16 20:26 ` Peilin Ye 2022-09-16 20:28 ` [PATCH bpf-next v2] " Peilin Ye 1 sibling, 1 reply; 5+ messages in thread From: Martin KaFai Lau @ 2022-09-16 18:37 UTC (permalink / raw) To: Peilin Ye Cc: Peilin Ye, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Song Liu, Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf, linux-kernel On 9/13/22 7:13 PM, Peilin Ye wrote: > From: Peilin Ye <peilin.ye@bytedance.com> > > We have btf_type_str(). Use it whenever possible in btf.c, instead of > "btf_kind_str[BTF_INFO_KIND(t->info)]". > > Signed-off-by: Peilin Ye <peilin.ye@bytedance.com> > --- > kernel/bpf/btf.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c > index cad4657ba2ce..81dc7423d723 100644 This clean up makes sense. The patch cannot be applied though [0], so it is marked as 'Changes Requested'. Also, where is the cad4657ba2ce coming from? It can't be found in the bpf-next tree. Please rebase on the bpf-next and resend. [0]: https://patchwork.kernel.org/project/netdevbpf/patch/20220914021328.17039-1-yepeilin.cs@gmail.com/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH bpf-next] bpf/btf: Use btf_type_str() whenever possible 2022-09-16 18:37 ` Martin KaFai Lau @ 2022-09-16 20:26 ` Peilin Ye 0 siblings, 0 replies; 5+ messages in thread From: Peilin Ye @ 2022-09-16 20:26 UTC (permalink / raw) To: Martin KaFai Lau Cc: Peilin Ye, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Song Liu, Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf, linux-kernel On Fri, Sep 16, 2022 at 11:37:46AM -0700, Martin KaFai Lau wrote: > This clean up makes sense. The patch cannot be applied though [0], so it is > marked as 'Changes Requested'. Also, where is the cad4657ba2ce coming from? > It can't be found in the bpf-next tree. Please rebase on the bpf-next and > resend. Ah, I will fix it in v2 soon. Thanks, Peilin Ye ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH bpf-next v2] bpf/btf: Use btf_type_str() whenever possible 2022-09-14 2:13 [PATCH bpf-next] bpf/btf: Use btf_type_str() whenever possible Peilin Ye 2022-09-16 18:37 ` Martin KaFai Lau @ 2022-09-16 20:28 ` Peilin Ye 2022-09-17 0:30 ` patchwork-bot+netdevbpf 1 sibling, 1 reply; 5+ messages in thread From: Peilin Ye @ 2022-09-16 20:28 UTC (permalink / raw) To: Martin KaFai Lau Cc: Peilin Ye, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Song Liu, Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf, linux-kernel, Peilin Ye From: Peilin Ye <peilin.ye@bytedance.com> We have btf_type_str(). Use it whenever possible in btf.c, instead of "btf_kind_str[BTF_INFO_KIND(t->info)]". Signed-off-by: Peilin Ye <peilin.ye@bytedance.com> --- change since v1: - rebase on bpf-next (Martin KaFai Lau) - also use btf_type_str() in __btf_verifier_log_type() kernel/bpf/btf.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 98be25d13325..b3940c605aac 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -1397,7 +1397,6 @@ __printf(4, 5) static void __btf_verifier_log_type(struct btf_verifier_env *env, const char *fmt, ...) { struct bpf_verifier_log *log = &env->log; - u8 kind = BTF_INFO_KIND(t->info); struct btf *btf = env->btf; va_list args; @@ -1413,7 +1412,7 @@ __printf(4, 5) static void __btf_verifier_log_type(struct btf_verifier_env *env, __btf_verifier_log(log, "[%u] %s %s%s", env->log_type_id, - btf_kind_str[kind], + btf_type_str(t), __btf_name_by_offset(btf, t->name_off), log_details ? " " : ""); @@ -5427,7 +5426,7 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, if (!btf_type_is_small_int(t)) { bpf_log(log, "ret type %s not allowed for fmod_ret\n", - btf_kind_str[BTF_INFO_KIND(t->info)]); + btf_type_str(t)); return false; } break; @@ -5454,7 +5453,7 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, "func '%s' arg%d '%s' has type %s. Only pointer access is allowed\n", tname, arg, __btf_name_by_offset(btf, t->name_off), - btf_kind_str[BTF_INFO_KIND(t->info)]); + btf_type_str(t)); return false; } @@ -5538,11 +5537,11 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, if (!btf_type_is_struct(t)) { bpf_log(log, "func '%s' arg%d type %s is not a struct\n", - tname, arg, btf_kind_str[BTF_INFO_KIND(t->info)]); + tname, arg, btf_type_str(t)); return false; } bpf_log(log, "func '%s' arg%d has btf_id %d type %s '%s'\n", - tname, arg, info->btf_id, btf_kind_str[BTF_INFO_KIND(t->info)], + tname, arg, info->btf_id, btf_type_str(t), __btf_name_by_offset(btf, t->name_off)); return true; } @@ -5950,7 +5949,7 @@ int btf_distill_func_proto(struct bpf_verifier_log *log, if (ret < 0 || __btf_type_is_struct(t)) { bpf_log(log, "The function %s return type %s is unsupported.\n", - tname, btf_kind_str[BTF_INFO_KIND(t->info)]); + tname, btf_type_str(t)); return -EINVAL; } m->ret_size = ret; @@ -5968,7 +5967,7 @@ int btf_distill_func_proto(struct bpf_verifier_log *log, if (ret < 0 || ret > 16) { bpf_log(log, "The function %s arg%d type %s is unsupported.\n", - tname, i, btf_kind_str[BTF_INFO_KIND(t->info)]); + tname, i, btf_type_str(t)); return -EINVAL; } if (ret == 0) { @@ -6727,7 +6726,7 @@ int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog, continue; } bpf_log(log, "Arg#%d type %s in %s() is not supported yet.\n", - i, btf_kind_str[BTF_INFO_KIND(t->info)], tname); + i, btf_type_str(t), tname); return -EINVAL; } return 0; -- 2.20.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH bpf-next v2] bpf/btf: Use btf_type_str() whenever possible 2022-09-16 20:28 ` [PATCH bpf-next v2] " Peilin Ye @ 2022-09-17 0:30 ` patchwork-bot+netdevbpf 0 siblings, 0 replies; 5+ messages in thread From: patchwork-bot+netdevbpf @ 2022-09-17 0:30 UTC (permalink / raw) To: Peilin Ye Cc: martin.lau, peilin.ye, ast, daniel, andrii, song, yhs, john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf, linux-kernel Hello: This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <martin.lau@kernel.org>: On Fri, 16 Sep 2022 13:28:00 -0700 you wrote: > From: Peilin Ye <peilin.ye@bytedance.com> > > We have btf_type_str(). Use it whenever possible in btf.c, instead of > "btf_kind_str[BTF_INFO_KIND(t->info)]". > > Signed-off-by: Peilin Ye <peilin.ye@bytedance.com> > > [...] Here is the summary with links: - [bpf-next,v2] bpf/btf: Use btf_type_str() whenever possible https://git.kernel.org/bpf/bpf-next/c/571f9738bfb3 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-09-17 0:30 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-09-14 2:13 [PATCH bpf-next] bpf/btf: Use btf_type_str() whenever possible Peilin Ye 2022-09-16 18:37 ` Martin KaFai Lau 2022-09-16 20:26 ` Peilin Ye 2022-09-16 20:28 ` [PATCH bpf-next v2] " Peilin Ye 2022-09-17 0:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox