On Tue, Nov 9, 2021 at 9:21 PM Yonghong Song <yhs@xxxxxx> wrote: > > Signed-off-by: Yonghong Song <yhs@xxxxxx> > --- > tools/testing/selftests/bpf/prog_tests/btf.c | 46 ++++++++++++++++++-- > 1 file changed, 42 insertions(+), 4 deletions(-) > > diff --git a/tools/testing/selftests/bpf/prog_tests/btf.c b/tools/testing/selftests/bpf/prog_tests/btf.c > index ebd0ead5f4bc..91b19c41729f 100644 > --- a/tools/testing/selftests/bpf/prog_tests/btf.c > +++ b/tools/testing/selftests/bpf/prog_tests/btf.c > @@ -6889,15 +6889,16 @@ const struct btf_dedup_test dedup_tests[] = { > BTF_RESTRICT_ENC(8), /* [11] restrict */ > BTF_FUNC_PROTO_ENC(1, 2), /* [12] func_proto */ > BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 1), > - BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 8), > + BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 18), > BTF_FUNC_ENC(NAME_TBD, 12), /* [13] func */ > BTF_TYPE_FLOAT_ENC(NAME_TBD, 2), /* [14] float */ > BTF_DECL_TAG_ENC(NAME_TBD, 13, -1), /* [15] decl_tag */ > BTF_DECL_TAG_ENC(NAME_TBD, 13, 1), /* [16] decl_tag */ > BTF_DECL_TAG_ENC(NAME_TBD, 7, -1), /* [17] decl_tag */ > + BTF_TYPE_TAG_ENC(NAME_TBD, 8), /* [18] type_tag */ > BTF_END_RAW, > }, > - BTF_STR_SEC("\0A\0B\0C\0D\0E\0F\0G\0H\0I\0J\0K\0L\0M\0N\0O\0P\0Q"), > + BTF_STR_SEC("\0A\0B\0C\0D\0E\0F\0G\0H\0I\0J\0K\0L\0M\0N\0O\0P\0Q\0R"), > }, > .expect = { > .raw_types = { > @@ -6918,15 +6919,16 @@ const struct btf_dedup_test dedup_tests[] = { > BTF_RESTRICT_ENC(8), /* [11] restrict */ > BTF_FUNC_PROTO_ENC(1, 2), /* [12] func_proto */ > BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 1), > - BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 8), > + BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 18), > BTF_FUNC_ENC(NAME_TBD, 12), /* [13] func */ > BTF_TYPE_FLOAT_ENC(NAME_TBD, 2), /* [14] float */ > BTF_DECL_TAG_ENC(NAME_TBD, 13, -1), /* [15] decl_tag */ > BTF_DECL_TAG_ENC(NAME_TBD, 13, 1), /* [16] decl_tag */ > BTF_DECL_TAG_ENC(NAME_TBD, 7, -1), /* [17] decl_tag */ > + BTF_TYPE_TAG_ENC(NAME_TBD, 8), /* [18] type_tag */ > BTF_END_RAW, > }, > - BTF_STR_SEC("\0A\0B\0C\0D\0E\0F\0G\0H\0I\0J\0K\0L\0M\0N\0O\0P\0Q"), > + BTF_STR_SEC("\0A\0B\0C\0D\0E\0F\0G\0H\0I\0J\0K\0L\0M\0N\0O\0P\0Q\0R"), > }, > .opts = { > .dont_resolve_fwds = false, > @@ -7254,6 +7256,42 @@ const struct btf_dedup_test dedup_tests[] = { > .dont_resolve_fwds = false, > }, > }, > +{ > + .descr = "dedup: btf_tag_type", > + .input = { > + .raw_types = { > + /* int */ > + BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */ > + /* tag: tag1, tag2 */ > + BTF_TYPE_TAG_ENC(NAME_NTH(1), 1), /* [2] */ > + BTF_TYPE_TAG_ENC(NAME_NTH(2), 2), /* [3] */ > + BTF_PTR_ENC(3), /* [4] */ > + /* tag: tag1, tag2 */ > + BTF_TYPE_TAG_ENC(NAME_NTH(1), 1), /* [5] */ > + BTF_TYPE_TAG_ENC(NAME_NTH(2), 5), /* [6] */ > + BTF_PTR_ENC(6), /* [7] */ > + /* tag: tag1 */ > + BTF_TYPE_TAG_ENC(NAME_NTH(1), 1), /* [8] */ > + BTF_PTR_ENC(8), /* [9] */ > + BTF_END_RAW, > + }, > + BTF_STR_SEC("\0tag1\0tag2"), > + }, Can you please add a test for two more situations: First, like this: tag1 -> tag2 -> int tag1 -> int tag1's shouldn't be deduped Second, like this tag1 -> tag2 -> int tag2 -> tag1 -> int Nothing gets deduped. Actually, also third situation: tag1 -> int tag1 -> long Nothing gets deduped. That will document expected behavior. Thanks. > + .expect = { > + .raw_types = { > + BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */ > + BTF_TYPE_TAG_ENC(NAME_NTH(1), 1), /* [2] */ > + BTF_TYPE_TAG_ENC(NAME_NTH(2), 2), /* [3] */ > + BTF_PTR_ENC(3), /* [4] */ > + BTF_PTR_ENC(2), /* [5] */ > + BTF_END_RAW, > + }, > + BTF_STR_SEC("\0tag1\0tag2"), > + }, > + .opts = { > + .dont_resolve_fwds = false, > + }, > +}, > > }; > > -- > 2.30.2 >