'-D' 'KBUILD_MODSYM=main - like KBUILD_MODNAME, without the quotes ?

jim.cromie at gmail.com jim.cromie at gmail.com
Fri Jan 29 03:32:02 EST 2021


On Thu, Jan 28, 2021 at 5:16 PM <jim.cromie at gmail.com> wrote:

>
>
> On Thu, Jan 28, 2021 at 4:57 PM Valdis Klētnieks <valdis.kletnieks at vt.edu>
> wrote:
>
>> On Thu, 28 Jan 2021 12:11:54 -0700, jim.cromie at gmail.com said:
>>
>> > In my hacking, Im finding this useful.
>> > it adds a version of KBUILD_MODNAME without the quotes
>>
>> OK, I'll bite.  When and how is this useful?
>>
>>
>
Let me add more context here.

1st, the long saga.

v1 - here, back in august last year.
https://lore.kernel.org/kernelnewbies/20200805183023.586590-1-jim.cromie@gmail.com/
not really pertinent here.
gregkh pretty much said send it to lkml

v2 - RFC to LKML
https://lore.kernel.org/lkml/20201225201944.3701590-1-jim.cromie@gmail.com/
this didnt get much attention, no answers to my questions
the 0000 is still completely accurate, I cannot improve upon it,
though many questions in the commit messages Ive answered myself.
(or at least made some choices ;)

v3 - sits in github now
almost identical 1-16/19 with v2
https://github.com/jimc/linux.git dyndbg-next

I was hoping to pull off a context-free question,
focusing on just the Makefile.lib patch's suitability.

I could send the whole series here, or to LKML, or both.
I can hope a quick perusal will get you to the interesting parts


> heres my use
>
>
Im looking to define a module-unique header record,
and to create storage for it in a separate section.
Then append that section to the module's __dyndbg section.

The pragma is leftover scaffolding from trying to figure out
that I needed the _sym_ version also, without the quotes.
I un-commented for demo only.

#define DEFINE_DYNAMIC_DEBUG_TABLE_(_sym_,_mod_)       \
> weak struct _ddebug \
> __used __aligned(8) \
> __section(".gnu.linkonce." _mod_ ".dyndbg") \
> _sym_##_dyndbg_base = { \
> .site = &_sym_##_dyndbg_site, \
> .format = _mod_, \
> .lineno = 0 \
> }
>
> #define DEFINE_DYNAMIC_DEBUG_TABLE() \
> DEFINE_DYNAMIC_DEBUG_TABLE_(KBUILD_MODSYM, KBUILD_MODNAME);
>
>

I cannot make the _mod_ ## work at the same time as
allowing "foo" _mod_ "buzz" catenation, therefore the new _sym_


This DEFINE is "called" from the bottom of include/linux/dynamic_debug.h

the combo of weak and ".gnu.linkonce." appear to resolve all
all the redundant definitions created by each C files' inclusion
of the header.
Inspiration came from .gnu.linkonce.this_module


--- a/include/asm-generic/vmlinux.lds.h

+++ b/include/asm-generic/vmlinux.lds.h

@@ -329,10 +329,10 @@

#define DYNAMIC_DEBUG_DATA() \

. = ALIGN(8); \

__start___dyndbg_sites = .; \

- KEEP(*(__dyndbg_sites __dyndbg_sites.header)) \

+ KEEP(*(__dyndbg_sites .gnu.linkonce.*.dyndbg_site)) \

__stop___dyndbg_sites = .; \

__start___dyndbg = .; \

- KEEP(*(__dyndbg __dyndbg.header)) \

+ KEEP(*(__dyndbg .gnu.linkonce.*.dyndbg)) \

__stop___dyndbg = .;

#else

#define DYNAMIC_DEBUG_DATA()

that puts the header record into the output section, right after the
module's
set of ddebug's (pr_debug callsite descriptors)

By getting the header into a fixed position relative to a callsite,
its possible to go from callsite-descriptor to the header
(after .module_index is initialized with the offset, determined at _init),
then use a single per-module pointer to the separate vector of "decorator"
data.

Once the 2 vectors of __dyndbg and __dyndbg_site records are indexed by N,
I can drop the .site pointer from 1 to other, and shrink the footprint back
to
~parity (with + 1 record / module overhead) worst case.

with 2 vectors fully decoupled (pointer-wise),
the decorator records can be stuffed into compressed block storage,
zram, etc, then recovered when a callsite is enabled,
and saved into a hashtable, indexed by modname+module-index.
global/module hash per experiment.

Anyway, I appear to have gotten the header where I want it:

[    0.315519] dyndbg: header: head64 0
[    0.326702] dyndbg: header: ebda 0
[    0.342521] dyndbg: header: platform_quirks 0
[    0.373523] dyndbg: site.4: main run_init_process
[    0.406518] dyndbg: site.5: main run_init_process
[    0.437521] dyndbg: site.6: main run_init_process
[    0.468521] dyndbg: site.7: main run_init_process
[    0.500528] dyndbg: site.8: main initcall_blacklisted
[    0.531519] dyndbg: site.9: main initcall_blacklist
[    0.555520] dyndbg: header: main 0

I have extra headers right now,
head64 ebda platform_quirks above,
for modules that have no pr-debug callsites.

Thats a problem for later,
though I posted here about conditional linkage earlier.

Im afraid it needs an ld linker language enhancement:
KEEP( IF *(__dyndbg) THEN (.gnu.linkonce.dyndbg) )

but Ive yet to try a simpler boolean algrebra
KEEP( *(__dyndbg && .gnu.linkonce.dyndbg))

if by some miracle that works, I'll report that shortly.

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20210129/28e29c33/attachment-0001.html>


More information about the Kernelnewbies mailing list