<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 28, 2021 at 5:16 PM <<a href="mailto:jim.cromie@gmail.com">jim.cromie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 28, 2021 at 4:57 PM Valdis Klētnieks <<a href="mailto:valdis.kletnieks@vt.edu" target="_blank">valdis.kletnieks@vt.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, 28 Jan 2021 12:11:54 -0700, <a href="mailto:jim.cromie@gmail.com" target="_blank">jim.cromie@gmail.com</a> said:<br>
<br>
> In my hacking, Im finding this useful.<br>
> it adds a version of KBUILD_MODNAME without the quotes<br>
<br>
OK, I'll bite. When and how is this useful?<br>
<br></blockquote><div class="gmail_quote"><br></div></div></div></blockquote><div><br></div><div>Let me add more context here.</div><div><br></div><div>1st, the long saga.</div><div><br></div><div>v1 - here, back in august last year.</div><div><a href="https://lore.kernel.org/kernelnewbies/20200805183023.586590-1-jim.cromie@gmail.com/">https://lore.kernel.org/kernelnewbies/20200805183023.586590-1-jim.cromie@gmail.com/</a></div><div>not really pertinent here.</div><div>gregkh pretty much said send it to lkml</div><div><br></div><div>v2 - RFC to LKML</div><div><a href="https://lore.kernel.org/lkml/20201225201944.3701590-1-jim.cromie@gmail.com/">https://lore.kernel.org/lkml/20201225201944.3701590-1-jim.cromie@gmail.com/</a><br></div><div>this didnt get much attention, no answers to my questions</div><div>the 0000 is still completely accurate, I cannot improve upon it,</div><div>though many questions in the commit messages Ive answered myself.</div><div>(or at least made some choices ;)</div><div><br></div><div>v3 - sits in github now</div><div>almost identical 1-16/19 with v2</div><div><a href="https://github.com/jimc/linux.git">https://github.com/jimc/linux.git</a> dyndbg-next</div><div><br></div><div>I was hoping to pull off a context-free question,</div><div>focusing on just the Makefile.lib patch's suitability.</div><div><br></div><div>I could send the whole series here, or to LKML, or both.</div><div>I can hope a quick perusal will get you to the interesting parts<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div class="gmail_quote"></div>heres my use</div><div class="gmail_quote"><br></div></div></blockquote><div><br></div><div>Im looking to define a module-unique header record,</div><div>and to create storage for it in a separate section.</div><div>Then append that section to the module's __dyndbg section.</div><div><br></div><div></div><div>The pragma is leftover scaffolding from trying to figure out </div><div>that I needed the _sym_ version also, without the quotes.</div><div>I un-commented for demo only.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote">#define DEFINE_DYNAMIC_DEBUG_TABLE_(_sym_,_mod_) \<br></div><div class="gmail_quote"> weak struct _ddebug \<br> __used __aligned(8) \<br> __section(".gnu.linkonce." _mod_ ".dyndbg") \<br> _sym_##_dyndbg_base = { \<br> .site = &_sym_##_dyndbg_site, \<br> .format = _mod_, \<br> .lineno = 0 \<br> }<br><br>#define DEFINE_DYNAMIC_DEBUG_TABLE() \<br> DEFINE_DYNAMIC_DEBUG_TABLE_(KBUILD_MODSYM, KBUILD_MODNAME);<br><div> </div></div></div></blockquote><div><br></div><div>I cannot make the _mod_ ## work at the same time as </div><div>allowing "foo" _mod_ "buzz" catenation, therefore the new _sym_</div><div><br></div><div><br></div><div>This DEFINE is "called" from the bottom of include/linux/dynamic_debug.h</div><div><br></div><div>the combo of weak and ".gnu.linkonce." appear to resolve all</div><div>all the redundant definitions created by each C files' inclusion</div><div>of the header.</div><div>Inspiration came from .gnu.linkonce.this_module</div><div><br></div><div><br></div><div>
<p style="margin:0px;white-space:pre-wrap">--- a/include/asm-generic/vmlinux.lds.h</p>
<p style="margin:0px;white-space:pre-wrap">+++ b/include/asm-generic/vmlinux.lds.h</p>
<p style="margin:0px;white-space:pre-wrap">@@ -329,10 +329,10 @@</p>
<p style="margin:0px;white-space:pre-wrap"> #define DYNAMIC_DEBUG_DATA() \</p>
<p style="margin:0px;white-space:pre-wrap"> . = ALIGN(8); \</p>
<p style="margin:0px;white-space:pre-wrap"> __start___dyndbg_sites = .; \</p>
<p style="margin:0px;white-space:pre-wrap">- KEEP(*(__dyndbg_sites __dyndbg_sites.header)) \</p>
<p style="margin:0px;white-space:pre-wrap">+ KEEP(*(__dyndbg_sites .gnu.linkonce.*.dyndbg_site)) \</p>
<p style="margin:0px;white-space:pre-wrap"> __stop___dyndbg_sites = .; \</p>
<p style="margin:0px;white-space:pre-wrap"> __start___dyndbg = .; \</p>
<p style="margin:0px;white-space:pre-wrap">- KEEP(*(__dyndbg __dyndbg.header)) \</p>
<p style="margin:0px;white-space:pre-wrap">+ KEEP(*(__dyndbg .gnu.linkonce.*.dyndbg)) \</p>
<p style="margin:0px;white-space:pre-wrap"> __stop___dyndbg = .;</p>
<p style="margin:0px;white-space:pre-wrap"> #else</p>
<p style="margin:0px;white-space:pre-wrap"> #define DYNAMIC_DEBUG_DATA()</p></div><div><br></div><div>that puts the header record into the output section, right after the module's</div><div>set of ddebug's (pr_debug callsite descriptors)</div><div><br></div><div>By getting the header into a fixed position relative to a callsite,</div><div>its possible to go from callsite-descriptor to the header </div><div>(after .module_index is initialized with the offset, determined at _init),</div><div>then use a single per-module pointer to the separate vector of "decorator" data.</div><div><br></div><div>Once the 2 vectors of __dyndbg and __dyndbg_site records are indexed by N,</div><div>I can drop the .site pointer from 1 to other, and shrink the footprint back to</div><div>~parity (with + 1 record / module overhead) worst case.</div><div><br></div><div>with 2 vectors fully decoupled (pointer-wise), </div><div>the decorator records can be stuffed into compressed block storage, </div><div>zram, etc, then recovered when a callsite is enabled,</div><div>and saved into a hashtable, indexed by modname+module-index.</div><div>global/module hash per experiment.</div><div><br></div><div>Anyway, I appear to have gotten the header where I want it:</div><div><br></div><div>[ 0.315519] dyndbg: header: head64 0<br>[ 0.326702] dyndbg: header: ebda 0<br>[ 0.342521] dyndbg: header: platform_quirks 0<br>[ 0.373523] dyndbg: site.4: main run_init_process<br>[ 0.406518] dyndbg: site.5: main run_init_process<br>[ 0.437521] dyndbg: site.6: main run_init_process<br>[ 0.468521] dyndbg: site.7: main run_init_process<br>[ 0.500528] dyndbg: site.8: main initcall_blacklisted<br>[ 0.531519] dyndbg: site.9: main initcall_blacklist<br>[ 0.555520] dyndbg: header: main 0<br></div><div><br></div><div>I have extra headers right now, </div><div>head64 ebda platform_quirks above,<br></div><div>for modules that have no pr-debug callsites.</div><div><br></div><div>Thats a problem for later, </div><div>though I posted here about conditional linkage earlier.</div><div><br></div><div>Im afraid it needs an ld linker language enhancement:</div><div>KEEP( IF *(__dyndbg) THEN (.gnu.linkonce.dyndbg) )</div><div><br></div><div>but Ive yet to try a simpler boolean algrebra</div><div>KEEP( *(__dyndbg && .gnu.linkonce.dyndbg))</div><div><br></div><div>if by some miracle that works, I'll report that shortly.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
</blockquote></div></div>