<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 14, 2021, at 5:33 PM, Y Song via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">On Mon, Jun 14, 2021 at 1:25 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:<br class=""><blockquote type="cite" class=""><br class=""><br class=""><br class="">On Mon, Jun 14, 2021 at 12:25 PM Y Song <<a href="mailto:ys114321@gmail.com" class="">ys114321@gmail.com</a>> wrote:<br class=""><blockquote type="cite" class=""><br class="">On Fri, Jun 11, 2021 at 9:59 AM Alexei Starovoitov<br class=""><<a href="mailto:alexei.starovoitov@gmail.com" class="">alexei.starovoitov@gmail.com</a>> wrote:<br class=""><blockquote type="cite" class=""><br class="">On Fri, Jun 11, 2021 at 07:17:32AM -0400, Aaron Ballman wrote:<br class=""><blockquote type="cite" class="">On Thu, Jun 10, 2021 at 8:47 PM Alexei Starovoitov<br class=""><<a href="mailto:alexei.starovoitov@gmail.com" class="">alexei.starovoitov@gmail.com</a>> wrote:<br class=""><blockquote type="cite" class=""><br class="">On Thu, Jun 10, 2021 at 12:42 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:<br class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><br class=""><br class="">Any suggestions/preferences for the spelling, Aaron?<br class=""></blockquote><br class="">I don't know this domain particularly well, so takes these suggestions<br class="">with a giant grain of salt:<br class=""><br class="">If the concept is specific to DWARF and you don't think it'll need to<br class="">extend into other debug formats, you could go with `dwarf_annotate`.<br class="">If it's not really a DWARF thing but is more about B[P|T]F, then<br class="">`btf_annotate`  or `bpf_annotate` could work, but those may be a bit<br class="">mysterious to folks outside of the domain. If it's a generic debug<br class="">info concept, probably `debug_info_annotate` or something.<br class=""></blockquote><br class=""><br class="">Arguably it can/could be a generic debug info or dwarf thing, but for now we don't have any use for it other than to squirrel info along to BTF/BPF so I'm on the fence about which prefix to use exactly<br class=""><br class=""></blockquote><br class="">A bit more bike shedding colors...<br class=""><br class="">The __rcu and __user annations might be used by the clang itself eventually.<br class="">Currently the "sparse" tool is doing this analysis and warns users<br class="">when __rcu pointer is incorrectly accessed in the kernel C code.<br class="">If clang can do that directly that could be a huge selling point<br class="">for folks to switch from gcc to clang for kernel builds.<br class="">The front-end would treat such annotations as arbitrary string, but<br class="">special "building-linux-kernel-pass" would interpret the semantical context.<br class=""></blockquote><br class="">Are __rcu and __user annotations notionally distinct things from bpf<br class="">(and perhaps each other as well)? Distinct enough that it would make<br class="">sense to use a different attribute name for user source for each need?<br class="">I suspect the answer is yes given that the existing annotations have<br class="">their own names which are distinct, but I don't know this domain<br class="">enough to be sure.<br class=""></blockquote><br class="">__rcu and __user don't overlap. __rcu is not a single annotation though.<br class="">It's a combination of annotations in pointers, functions, macros.<br class="">Some functions have:<br class="">__acquires(rcu)<br class="">another function might have:<br class="">__acquires(rcu_bh)<br class="">There are several flavors of the RCU in the kernel.<br class="">So single __attribute__((rcu_annotate("foo"))) won't work even within RCU scope.<br class="">But if we do:<br class="">struct foo {<br class="">  void * __attribute__((tag("ptr.rcu_bh")) ptr;<br class="">};<br class="">int bar(int) __attribute__((tag("acquires.rcu_bh")) { ... }<br class="">int baz(int) __attribute__((tag("releases.rcu_bh")) { ... }<br class="">int qux(int) __attribute__((tag("acquires.rcu_sched")) { ... }<br class="">...<br class="">The clang pass can parse these strings and correlate one tag to another.<br class="">RCU flavors come and go, so clang cannot hard code the names.<br class=""></blockquote><br class="">Maybe we can name it as "bpf_tag" as it is a "tag" for "bpf" use case?<br class=""><br class="">David, in one of your early emails, you mentioned:<br class=""><br class="">===<br class="">Arguably it can/could be a generic debug info or dwarf thing, but for<br class="">now we don't have any use for it other than to squirrel info along to<br class="">BTF/BPF so I'm on the fence about which prefix to use exactly<br class="">===<br class=""><br class="">and suggests since it might be used in the future for non-bpf things,<br class="">maybe the name could be a little more generic then bpf-specific.<br class=""><br class="">Do you have any suggestions on what name to pick?<br class=""></blockquote><br class=""><br class="">Nah, not especially. bpf_tag sounds OK-ish to me if it suits you.<br class=""></blockquote><br class=""></div></div></blockquote><div><br class=""></div><div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">The more generic the better IMO.  And, the less the need to parse string literals the better.  </div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Why not simply `<span style="font-family: Menlo;" class="">__attribute__((debuginfo("arg1", "arg2", ...)))</span>`, e.g.:</div><div style="margin: 0px; font-stretch: normal; line-height: normal; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">```</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-kerning: none" class="">#define BPF_TAG(...) __attribute__((debuginfo("bpf", __VA_ARGS__)))</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-kerning: none" class="">struct foo {</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-kerning: none" class=""> void * BPF_TAG("ptr","rcu","bh") ptr;</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-kerning: none" class="">};</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-kerning: none" class="">#define BPF_RCU_TAG(PFX, ...) BPF(PFX, "rcu", __VA_ARGS__)</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-kerning: none" class="">int bar(int) BPF_RCU_TAG("acquires","bh") { ... }</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-kerning: none" class="">int baz(int) BPF_RCU_TAG("releases","bh") { ... }</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-kerning: none" class="">int qux(int) BPF_RCU_TAG("acquires","sched") { ... }</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">```</div></div><br class=""><blockquote type="cite" class=""><div class=""><div class="">Sounds good. I will use "bpf_tag" as the starting point now.<br class="">Also, it is possible "bpf_tag" may appear multiple times for the same<br class="">function, declaration etc.<br class=""><br class="">For example,<br class="">  #define __bpf_tag(s) __attribute__((bpf_tag(s)))<br class="">  int g __bpf_tag("str1") __bpf_tag("str2");<br class="">Let us say we introduced a LLVM vendor tag DWARF_AT_LLVM_bpf_tag.<br class=""><br class="">How do you want the above to be represented in dwarf?<br class=""><br class="">My current scheme is to put all bpf_tag's in a string, separated by ",".<br class="">This will make things simpler. So the final output will be<br class="">     DWARF_AT_LLVM_bpf_tag  "str1,str2"<br class="">I may need to do a discussion with the kernel folks to use a different<br class="">delimiter than ",", but we still represent all tags with ONE string.<br class=""><br class="">But alternatively, it could be represented as a list of strings like<br class="">   DWARF_AT_LLVM_bpf_tag<br class="">             "str1"<br class="">             "str2"<br class="">is similar to DWARF_AT_location.<br class=""><br class="">The first internal representation<br class="">   DWARF_AT_LLVM_bpf_tag  "str1,str2"<br class="">should be easier for IR/bitcode read/write and dwarf parsing.<br class=""><br class="">What do you think?<br class="">_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></div></div></blockquote></div><br class=""></body></html>