xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Luis R. Rodriguez" <mcgrof@kernel.org>
To: hpa@zytor.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de
Cc: benh@kernel.crashing.org, ming.lei@canonical.com,
	masami.hiramatsu.pt@hitachi.com, linux-arch@vger.kernel.org,
	xen-devel@lists.xensource.com, linux@arm.linux.org.uk,
	x86@kernel.org, anil.s.keshavamurthy@intel.com, arnd@arndb.de,
	rusty@rustcorp.com.au, jbaron@akamai.com,
	boris.ostrovsky@oracle.com, andriy.shevchenko@linux.intel.com,
	mcb30@ipxe.org, jgross@suse.com, ananth@in.ibm.com,
	gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	luto@amacapital.net, "Luis R. Rodriguez" <mcgrof@kernel.org>,
	david.vrabel@citrix.com, dwmw2@infradead.org,
	davem@davemloft.net
Subject: [RFC v2 6/7] dynamic_debug: port to use linker tables
Date: Fri, 19 Feb 2016 05:45:58 -0800	[thread overview]
Message-ID: <1455889559-9428-7-git-send-email-mcgrof@kernel.org> (raw)
In-Reply-To: <1455889559-9428-1-git-send-email-mcgrof@kernel.org>

This removes the custom vmlinux.lds.h hacks and uses
the generalized solution for .data (SECTION_DATA)
entries.

This is much more potential for further fine tuning here
though in the future. For instance, linker tables enable
an extra postfix for order level annotations, this could
easily be used as the KBUILD_MODNAME and with a bit of
linker table changes we may be able to get a direct O(1)
count of the entries for that KBUILD_MODNAME: it would
just be a count on the number of entries for the given
order level. This should help make dynamic_debug_init()
cleaner and also reduce the amount of time it takes at
boot time. Instead of iterating over each print until we
have all for a KBUILD_MODNAME, we'd instead directly
operate on each KBUILD_MODNAME directly.

Tested dynamic debug with dyndbg query ana debugfs control
and it works as expected.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 include/asm-generic/vmlinux.lds.h |  5 -----
 include/linux/dynamic_debug.h     |  6 ++++--
 kernel/module.c                   |  2 +-
 lib/dynamic_debug.c               | 13 ++++++-------
 4 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 11e1adcbcb24..c5fcac902cbe 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -209,11 +209,6 @@
 	*(.data.unlikely)						\
 	STRUCT_ALIGN();							\
 	*(__tracepoints)						\
-	/* implement dynamic printk debug */				\
-	. = ALIGN(8);							\
-	VMLINUX_SYMBOL(__start___verbose) = .;                          \
-	*(__verbose)                                                    \
-	VMLINUX_SYMBOL(__stop___verbose) = .;				\
 	LIKELY_PROFILE()		       				\
 	BRANCH_PROFILE()						\
 	TRACE_PRINTKS()							\
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 4f1bbc68cd1b..6cd14a22b795 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -1,6 +1,8 @@
 #ifndef _DYNAMIC_DEBUG_H
 #define _DYNAMIC_DEBUG_H
 
+#include <linux/tables.h>
+
 /*
  * An instance of this structure is created in a special
  * ELF section at every dynamic debug callsite.  At runtime,
@@ -40,6 +42,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
 				const char *modname);
 
 #if defined(CONFIG_DYNAMIC_DEBUG)
+DECLARE_LINKTABLE_DATA(struct _ddebug, __verbose);
 extern int ddebug_remove_module(const char *mod_name);
 extern __printf(2, 3)
 void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...);
@@ -61,8 +64,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor,
 			  const char *fmt, ...);
 
 #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt)		\
-	static struct _ddebug  __aligned(8)			\
-	__attribute__((section("__verbose"))) name = {		\
+	static LINKTABLE_DATA(__verbose, all) name = {		\
 		.modname = KBUILD_MODNAME,			\
 		.function = __func__,				\
 		.filename = __FILE__,				\
diff --git a/kernel/module.c b/kernel/module.c
index 42249ee8e462..22d768abb1ec 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2962,7 +2962,7 @@ static int find_module_sections(struct module *mod, struct load_info *info)
 	if (section_addr(info, "__obsparm"))
 		pr_warn("%s: Ignoring obsolete parameters\n", mod->name);
 
-	info->debug = section_objs(info, "__verbose",
+	info->debug = section_objs(info, SECTION_TBL(SECTION_DATA, __verbose,),
 				   sizeof(*info->debug), &info->num_debug);
 
 	return 0;
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index fe42b6ec3f0c..ae7b9b4ac022 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -37,8 +37,7 @@
 #include <linux/device.h>
 #include <linux/netdevice.h>
 
-extern struct _ddebug __start___verbose[];
-extern struct _ddebug __stop___verbose[];
+DEFINE_LINKTABLE_DATA(struct _ddebug, __verbose);
 
 struct ddebug_table {
 	struct list_head link;
@@ -971,14 +970,14 @@ static int __init dynamic_debug_init(void)
 	int n = 0, entries = 0, modct = 0;
 	int verbose_bytes = 0;
 
-	if (__start___verbose == __stop___verbose) {
-		pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n");
+	if (LINKTABLE_EMPTY(__verbose)) {
+		pr_warn("dynamic debug linker table empty on CONFIG_DYNAMIC_DEBUG build\n");
 		return 1;
 	}
-	iter = __start___verbose;
+	iter = LINKTABLE_START(__verbose);
 	modname = iter->modname;
 	iter_start = iter;
-	for (; iter < __stop___verbose; iter++) {
+	LINKTABLE_FOR_EACH(iter, __verbose) {
 		entries++;
 		verbose_bytes += strlen(iter->modname) + strlen(iter->function)
 			+ strlen(iter->filename) + strlen(iter->format);
@@ -1001,7 +1000,7 @@ static int __init dynamic_debug_init(void)
 	ddebug_init_success = 1;
 	vpr_info("%d modules, %d entries and %d bytes in ddebug tables, %d bytes in (readonly) verbose section\n",
 		 modct, entries, (int)(modct * sizeof(struct ddebug_table)),
-		 verbose_bytes + (int)(__stop___verbose - __start___verbose));
+		 verbose_bytes + (int)(LINKTABLE_SIZE(__verbose)));
 
 	/* apply ddebug_query boot param, dont unload tables on err */
 	if (ddebug_setup_string[0] != '\0') {
-- 
2.7.0

  parent reply	other threads:[~2016-02-19 13:45 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-19 13:45 [RFC v2 0/7] linux: add linker tables Luis R. Rodriguez
2016-02-19 13:45 ` [RFC v2 1/7] sections.h: add sections header to collect all section info Luis R. Rodriguez
2016-02-19 16:23   ` Greg KH
2016-02-19 20:06     ` Luis R. Rodriguez
2016-02-19 21:25       ` Greg KH
2016-02-19 21:59         ` Luis R. Rodriguez
2016-02-19 13:45 ` [RFC v2 2/7] tables.h: add linker table support Luis R. Rodriguez
2016-02-19 20:25   ` H. Peter Anvin
2016-02-19 21:48     ` Luis R. Rodriguez
2016-02-23 23:08       ` Luis R. Rodriguez
2016-02-23 23:22         ` H. Peter Anvin
2016-02-23 23:36           ` Luis R. Rodriguez
2016-02-24  0:06             ` H. Peter Anvin
2016-02-24  0:54               ` Luis R. Rodriguez
2016-02-19 20:33   ` H. Peter Anvin
2016-02-19 21:12     ` Luis R. Rodriguez
2016-02-19 13:45 ` [RFC v2 3/7] firmware: port built-in section to linker table Luis R. Rodriguez
2016-02-29 10:12   ` David Woodhouse
2016-02-29 18:56     ` Luis R. Rodriguez
2016-05-02 18:34       ` Kees Cook
2016-05-02 18:41         ` Greg KH
2016-05-03 17:08           ` Luis R. Rodriguez
2016-05-03 17:07         ` Luis R. Rodriguez
2016-05-03 17:10           ` Luis R. Rodriguez
2016-05-03 17:11             ` Luis R. Rodriguez
2016-05-03 17:21             ` Kees Cook
2016-05-03 18:12             ` Greg KH
2016-03-01 16:10     ` James Bottomley
2016-03-01 17:54       ` Luis R. Rodriguez
2016-04-29 19:24         ` Luis R. Rodriguez
2016-02-19 13:45 ` [RFC v2 4/7] asm/sections: add a generic push_section_tbl() Luis R. Rodriguez
2016-02-19 20:26   ` H. Peter Anvin
2016-02-19 21:06     ` Luis R. Rodriguez
2016-02-22  2:55       ` H. Peter Anvin
2016-02-26 14:56         ` Heiko Carstens
2016-05-20 19:53           ` Luis R. Rodriguez
2016-02-19 13:45 ` [RFC v2 5/7] jump_label: port __jump_table to linker tables Luis R. Rodriguez
2016-02-19 13:45 ` Luis R. Rodriguez [this message]
2016-02-19 13:45 ` [RFC v2 7/7] kprobes: port to linker table Luis R. Rodriguez
2016-02-19 14:15   ` Russell King - ARM Linux
2016-02-19 14:55     ` Luis R. Rodriguez
2016-02-22  1:34   ` 平松雅巳 / HIRAMATU,MASAMI
2016-02-23  0:52     ` [Xen-devel] " Luis R. Rodriguez
2016-07-21 23:53       ` Luis R. Rodriguez
2016-02-19 20:16 ` [RFC v2 0/7] linux: add linker tables H. Peter Anvin
2016-02-19 21:19   ` Luis R. Rodriguez

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=1455889559-9428-7-git-send-email-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=ananth@in.ibm.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=arnd@arndb.de \
    --cc=benh@kernel.crashing.org \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=davem@davemloft.net \
    --cc=david.vrabel@citrix.com \
    --cc=dwmw2@infradead.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=jbaron@akamai.com \
    --cc=jgross@suse.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=luto@amacapital.net \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mcb30@ipxe.org \
    --cc=ming.lei@canonical.com \
    --cc=mingo@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xensource.com \
    /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).