On Fri, 7 Jun 2019 00:27:52 +0000, Alexei Starovoitov wrote: > the solution we're discussing should solve BPF_ANNOTATE_KV_PAIR too. > That hack must go. I see. > If I understood your objections to Andrii's format is that > you don't like pointer part of key/value while Andrii explained > why we picked the pointer, right? > > So how about: > > struct { > int type; > int max_entries; > struct { > __u32 key; > struct my_value value; > } types[]; > } ... My objection is that k/v fields are never initialized, so they're "metafields", mixed with real fields which hold parameters - like type, max_entries etc. But I thought about this 3 times now, and I see no better solution. FWIW my best shot was relos: extern struct my_key my_key; extern int type_int; struct map_def { int type; int max_entries; void *btf_key_ref; void *btf_val_ref; } = { ... .btf_key_ref = &my_key, .btf_val_ref = &type_int, }; The advantage being that map_def is no longer modified for each instance and k/v combination. And I get my assignment to k/v members :) But really, I give up, I can't come up with anything better :)