bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Where can I find the map's BTF type key/value specification?
@ 2020-10-10 10:50 Daniel T. Lee
  2020-10-11  0:06 ` Andrii Nakryiko
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel T. Lee @ 2020-10-10 10:50 UTC (permalink / raw)
  To: bpf
  Cc: Andrii Nakryiko, Alexei Starovoitov, Daniel Borkmann,
	Yonghong Song, Andrii Nakryiko, Martin Lau

I'm looking for how BTF type definition '__type(key, int)' is being changed
to '__uint(key_size, sizeof(int))'. (Not exactly "changed" but wonder how
it can be considered the same)

    __uint(type, BPF_MAP_TYPE_ARRAY);
    __type(key, int);          => __uint(key_size, sizeof(int))
    __type(value, u32);    => __uint(value_size, sizeof(u32))
    __uint(max_entries, 2);

Whether the specific map type supports BTF or not can be inferred from
the file in kernel/bpf/*map.c and by checking each MAP type's
bpf_map_ops .map_check_btf pointer is initialized as map_check_no_btf.

But how can I figure out that specific types of map support BTF types for
key/value? And how can I determine how this BTF key/value type is
converted?

I am aware that BTF information is created in the form of a compact
type by using pahole to deduplicate repeated types, strings information
from DWARF information. However, looking at the *btf or pahole file
in dwarves repository, it seemed that it was not responsible for the
conversion of the BTF key/value.

The remaining guess is that LLVM's BPF target compiler is responsible
for this, or it's probably somewhere in the kernel, but I'm not sure
where it is.

--
Best,
Daniel T. Lee

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-13  5:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-10 10:50 Where can I find the map's BTF type key/value specification? Daniel T. Lee
2020-10-11  0:06 ` Andrii Nakryiko
2020-10-13  5:13   ` Daniel T. Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).