From: Jim Cromie <jim.cromie@gmail.com>
To: jbaron@akamai.com, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org
Cc: Jim Cromie <jim.cromie@gmail.com>
Subject: [RFC PATCH v2 19/19] dyndbg: try DEFINE_DYNAMIC_DEBUG_TABLE
Date: Fri, 25 Dec 2020 13:19:44 -0700 [thread overview]
Message-ID: <20201225201944.3701590-20-jim.cromie@gmail.com> (raw)
In-Reply-To: <20201225201944.3701590-1-jim.cromie@gmail.com>
Test DEFINE_DYNAMIC_DEBUG_TABLE, in i915.ko, by adding an invocation
into i915_drv.c, the 1st object built in the Makefile. This does
manually what can perhaps be done transparently in headers (hopefully).
DEFINE_DYNAMIC_DEBUG_TABLE is based on DEFINE_DYNAMIC_DEBUG_METADATA;
just like its model, it creates a pair of structs: _ddebug &
_ddebug_callsite, and inits them with format="0000", lineno=0.
This:
- identifies it clearly in control output
- appears to place it 1st in the section(s)
it works here, at least for modprobed module
1st-to-build might be the real reason for the sort.
drivers/gpu/drm/i915/i915_drv.c:0 [i915](null) =_ "0000"
drivers/gpu/drm/i915/gvt/gvt.c:437 [i915]intel_gvt_register_hypervisor =_ "gvt: core: Running with hypervisor %s
drivers/gpu/drm/i915/gvt/gvt.c:378 [i915]intel_gvt_init_device =_ "gvt: core: gvt device initialization is done\0
other big diff between DEFINE_DYNAMIC_DEBUG_TABLE/_METADATA:
- not static decls.
removing static made the line appear in control output (below).
(cuz it might be reffd elsewhere, so its linked).
we want this.
it also needs to be visible where DEFINE_DYNAMIC_DEBUG_METADATA is
used, so it can be used to initialize .module_index, ie in many other
objects where pr_debugs are coded.
A peek inside i915_drv.o looks about right; i915_site is expected at least.
Relocation section '.rela__dyndbg' at offset 0x6f48 contains 2 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000010 014c00000001 R_X86_64_64 0000000000000000 i915_site + 0
000000000018 001a00000001 R_X86_64_64 0000000000000000 .rodata.str1.1 + 548
Relocation section '.rela__dyndbg_callsites' at offset 0x6f90 contains 2 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000000 001a00000001 R_X86_64_64 0000000000000000 .rodata.str1.1 + d8
000000000008 000a00000001 R_X86_64_64 0000000000000000 .rodata.str1.8 + 110
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
drivers/gpu/drm/i915/i915_drv.c | 3 +++
include/linux/dynamic_debug.h | 47 ++++++++++++++++++++++-----------
2 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index acc32066cec3..f2fae2a476db 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -88,6 +88,9 @@
static struct drm_driver driver;
+DEFINE_DYNAMIC_DEBUG_TABLE(i915);
+// DEFINE_DYNAMIC_DEBUG_TABLE(THIS_MODULE); // one alternative form
+
static int i915_get_bridge_dev(struct drm_i915_private *dev_priv)
{
int domain = pci_domain_nr(dev_priv->drm.pdev->bus);
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 0f4e703c97ee..2f3c0f35cea0 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -102,6 +102,36 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
const struct ib_device *ibdev,
const char *fmt, ...);
+/** DEFINE_DYNAMIC_DEBUG_TABLE(module)
+ *
+ * This is an analogue to DEFINE_DYNAMIC_DEBUG_METADATA()
+
+ * It's just a "callsite" whose primary purpose is to create or
+ * reserve the 0th element pair in our sub-vectors of __dyndbg[] &
+ * __dyndbg_callsites[]. The format & lineno are set to sort 1st,
+ * though I suspect our good order is more about linkage. Either way,
+ * the TABLE is appearing 1st in control's i915 output.
+
+ * We want to use it to initialize .module_index, but I was unable to
+ * ref &module##_base by any construct I thought to try;
+ * KBUILD_MODNAME in particular didnt work.
+
+ */
+
+#define DEFINE_DYNAMIC_DEBUG_TABLE(module) \
+ struct _ddebug_callsite __aligned(8) \
+ __section("__dyndbg_callsites") module##_site = { \
+ .modname = KBUILD_MODNAME, \
+ .filename = __FILE__, \
+ .function = NULL, \
+ }; \
+ struct _ddebug __aligned(8) \
+ __section("__dyndbg") module##_base = { \
+ .site = &module##_site, \
+ .format = "0000", \
+ .lineno = 0, /* sort on mod, line */ \
+ }
+
#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \
static struct _ddebug_callsite __aligned(8) \
__section("__dyndbg_callsites") name##_site = { \
@@ -115,23 +145,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
.format = (fmt), \
.lineno = __LINE__, \
.flags = _DPRINTK_FLAGS_DEFAULT, \
- _DPRINTK_KEY_INIT \
+ _DPRINTK_KEY_INIT, \
+ .module_index = 0 /* want offset from _base */ \
}
-/** DEFINE_DYNAMIC_DEBUG_TABLE(module)
-
- * It's just a "callsite" we expect not to use, except as a 0th
- * element we can use to initialize each ddebug.module_index.
- *
- * Later, this will be adapted to initialize a pair of alternate
- * structures; analogous to structs _ddebug & _ddebug_callsite, and
- * implemented as structs unionized with them. This pair of
- * alt-structs could supplant most or all of the function and purpose
- * of the linked list of ddebug_tables built by ddebug_add_module.
- */
-#define DEFINE_DYNAMIC_DEBUG_TABLE(module) \
- DEFINE_DYNAMIC_DEBUG_METADATA(module, "00-1st-in-subsection")
-
#ifdef CONFIG_JUMP_LABEL
#ifdef DEBUG
--
2.29.2
next prev parent reply other threads:[~2020-12-25 20:22 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-25 20:19 [RFC PATCH v2 00/19] dynamic debug diet plan Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 01/19] dyndbg: fix use before null check Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 02/19] dyndbg: split struct _ddebug, move display fields to new _ddebug_callsite Jim Cromie
2020-12-31 2:34 ` [dyndbg] e83b4a5011: leaking-addresses.proc.__dyndbg_callsites kernel test robot
2020-12-25 20:19 ` [RFC PATCH v2 03/19] dyndbg: refactor part of ddebug_change to ddebug_match_site Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 04/19] dyndbg: accept null site in ddebug_match_site Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 05/19] dyndbg: hoist ->site out of ddebug_match_site Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 06/19] dyndbg: accept null site in ddebug_change Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 07/19] dyndbg: accept null site in dynamic_emit_prefix Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 08/19] dyndbg: accept null site in ddebug_proc_show Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 09/19] dyndbg: optimize ddebug_emit_prefix Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 10/19] dyndbg: avoid calling dyndbg_emit_prefix when it has no work Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 11/19] dyndbg: refactor ddebug_alter_site out of ddebug_change Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 12/19] dyndbg: allow deleting site info via control interface Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 13/19] dyndbg: verify __dyndbg & __dyndbg_callsite invariant Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 14/19] dyndbg+module: expose ddebug_callsites to modules Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 15/19] dyndbg: add ddebug_site_get/put api with pass-thru impl Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 16/19] dyndbg: ddebug_site_get/put api commentary Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 17/19] dyndbg: rearrange struct ddebug_callsites Jim Cromie
2020-12-25 20:19 ` [RFC PATCH v2 18/19] dyndbg: add module_index to struct _ddebug Jim Cromie
2020-12-25 20:19 ` Jim Cromie [this message]
2020-12-29 18:56 ` [RFC PATCH v2 00/19] dynamic debug diet plan Joe Perches
2021-01-06 17:50 ` 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=20201225201944.3701590-20-jim.cromie@gmail.com \
--to=jim.cromie@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jbaron@akamai.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®