kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: jim.cromie@gmail.com
To: "Valdis Klētnieks" <valdis.kletnieks@vt.edu>
Cc: kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: Re: '-D' 'KBUILD_MODSYM=main - like KBUILD_MODNAME, without the quotes ?
Date: Fri, 29 Jan 2021 01:32:02 -0700	[thread overview]
Message-ID: <CAJfuBxzvJwnaMxk7WLdT=WNVJ+w=58ne8CHiofKh8zYtndOKgA@mail.gmail.com> (raw)
In-Reply-To: <CAJfuBxwShnr0opU-F+g7MztkLYLhr8EQJN8ZJZ5u1LUuVwpPDw@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 4906 bytes --]

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

>
>
> On Thu, Jan 28, 2021 at 4:57 PM Valdis Klētnieks <valdis.kletnieks@vt.edu>
> wrote:
>
>> On Thu, 28 Jan 2021 12:11:54 -0700, jim.cromie@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.

>

[-- Attachment #1.2: Type: text/html, Size: 8309 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  parent reply	other threads:[~2021-01-29  8:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-28 19:11 '-D' 'KBUILD_MODSYM=main - like KBUILD_MODNAME, without the quotes ? jim.cromie
2021-01-28 23:57 ` Valdis Klētnieks
2021-01-29  0:16   ` jim.cromie
2021-01-29  2:04     ` Valdis Klētnieks
2021-01-29  8:32     ` jim.cromie [this message]
2021-01-29  9:07       ` jim.cromie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJfuBxzvJwnaMxk7WLdT=WNVJ+w=58ne8CHiofKh8zYtndOKgA@mail.gmail.com' \
    --to=jim.cromie@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    --cc=valdis.kletnieks@vt.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).