From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Jason Baron <jbaron@akamai.com>,
linux-kernel@vger.kernel.org,
Rasmus Villemoes <linux@rasmusvillemoes.dk>
Subject: [PATCH 06/10] dynamic_debug: introduce CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS
Date: Tue, 9 Apr 2019 23:25:13 +0200 [thread overview]
Message-ID: <20190409212517.7321-7-linux@rasmusvillemoes.dk> (raw)
In-Reply-To: <20190409212517.7321-1-linux@rasmusvillemoes.dk>
Based on the same idea for struct bug_entry, an architecture can opt-in
to use relative pointers in struct _ddebug. It only makes sense for 64
bit architectures, where one saves 16 bytes per entry (out of 40 or 56,
depending on CONFIG_JUMP_LABEL). The architecture is responsible for
providing a suitable DEFINE_DYNAMIC_DEBUG_METADATA macro in
<asm/dynamic_debug.h>.
Acked-by: Jason Baron <jbaron@akamai.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
include/linux/dynamic_debug.h | 14 ++++++++++++++
lib/Kconfig.debug | 3 +++
lib/dynamic_debug.c | 20 ++++++++++++++++++++
3 files changed, 37 insertions(+)
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index e2fa2737a485..08175c219d60 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -16,10 +16,17 @@ struct _ddebug {
* These fields are used to drive the user interface
* for selecting and displaying debug callsites.
*/
+#ifdef CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS
+ signed int modname_disp;
+ signed int function_disp;
+ signed int filename_disp;
+ signed int format_disp;
+#else
const char *modname;
const char *function;
const char *filename;
const char *format;
+#endif
/*
* The flags field controls the behaviour at the callsite.
* The bits here are changed dynamically when the user
@@ -70,6 +77,12 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor,
const struct net_device *dev,
const char *fmt, ...);
+#ifdef CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS
+#include <asm/dynamic_debug.h>
+#ifndef DEFINE_DYNAMIC_DEBUG_METADATA
+# error "asm/dynamic_debug.h must provide definition of DEFINE_DYNAMIC_DEBUG_METADATA"
+#endif
+#else
#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \
static struct _ddebug __aligned(8) \
__attribute__((section("__verbose"))) name = { \
@@ -80,6 +93,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor,
.flags_lineno = _DPRINTK_FLAGS_LINENO_INIT, \
_DPRINTK_KEY_INIT \
}
+#endif
#ifdef CONFIG_JUMP_LABEL
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 0d9e81779e37..7cee0895f9c8 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -163,6 +163,9 @@ config DYNAMIC_DEBUG
See Documentation/admin-guide/dynamic-debug-howto.rst for additional
information.
+config DYNAMIC_DEBUG_RELATIVE_POINTERS
+ bool
+
endmenu # "printk and dmesg options"
menu "Compile-time checks and compiler options"
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 482a35a68752..58288560cc35 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -37,6 +37,24 @@
#include <linux/device.h>
#include <linux/netdevice.h>
+#ifdef CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS
+static inline const char *dd_modname(const struct _ddebug *dd)
+{
+ return (const char *)dd + dd->modname_disp;
+}
+static inline const char *dd_function(const struct _ddebug *dd)
+{
+ return (const char *)dd + dd->function_disp;
+}
+static inline const char *dd_filename(const struct _ddebug *dd)
+{
+ return (const char *)dd + dd->filename_disp;
+}
+static inline const char *dd_format(const struct _ddebug *dd)
+{
+ return (const char *)dd + dd->format_disp;
+}
+#else
static inline const char *dd_modname(const struct _ddebug *dd)
{
return dd->modname;
@@ -53,6 +71,8 @@ static inline const char *dd_format(const struct _ddebug *dd)
{
return dd->format;
}
+#endif
+
static inline unsigned dd_lineno(const struct _ddebug *dd)
{
return dd->flags_lineno >> 8;
--
2.20.1
next prev parent reply other threads:[~2019-04-09 21:26 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-09 21:25 [PATCH 00/10] implement DYNAMIC_DEBUG_RELATIVE_POINTERS Rasmus Villemoes
2019-04-09 21:25 ` [PATCH 01/10] linux/device.h: use unique identifier for each struct _ddebug Rasmus Villemoes
2019-04-09 21:25 ` [PATCH 02/10] linux/net.h: " Rasmus Villemoes
2019-04-09 21:25 ` [PATCH 03/10] linux/printk.h: " Rasmus Villemoes
2019-04-09 21:25 ` [PATCH 04/10] dynamic_debug: introduce accessors for string members of " Rasmus Villemoes
2019-04-09 21:25 ` [PATCH 05/10] dynamic_debug: drop use of bitfields in " Rasmus Villemoes
2019-04-09 21:25 ` Rasmus Villemoes [this message]
2019-04-09 21:25 ` [PATCH 07/10] dynamic_debug: add asm-generic implementation for DYNAMIC_DEBUG_RELATIVE_POINTERS Rasmus Villemoes
2019-04-09 21:25 ` [PATCH 08/10] x86-64: select DYNAMIC_DEBUG_RELATIVE_POINTERS Rasmus Villemoes
2019-04-10 7:31 ` Ingo Molnar
2019-04-09 21:25 ` [PATCH 09/10] arm64: " Rasmus Villemoes
2019-04-26 9:39 ` Arnd Bergmann
2019-04-26 10:05 ` Rasmus Villemoes
2019-04-26 13:00 ` Nathan Chancellor
2019-04-26 19:06 ` [PATCH 11/10] arm64: unbreak DYNAMIC_DEBUG=y build with clang Rasmus Villemoes
2019-04-26 19:06 ` [PATCH 12/10] powerpc: " Rasmus Villemoes
2019-04-29 17:34 ` Nick Desaulniers
2019-04-26 19:27 ` [PATCH 11/10] arm64: " Rasmus Villemoes
2019-04-26 21:58 ` Konstantin Ryabitsev
2019-04-26 22:07 ` Konstantin Ryabitsev
2019-04-29 17:32 ` Nick Desaulniers
2019-04-30 18:22 ` Nick Desaulniers
2019-05-02 8:57 ` Rasmus Villemoes
2019-04-09 21:25 ` [PATCH 10/10] powerpc: select DYNAMIC_DEBUG_RELATIVE_POINTERS for PPC64 Rasmus Villemoes
2019-04-23 15:37 ` Christophe Leroy
2019-04-23 19:36 ` Andrew Morton
2019-04-24 6:46 ` Rasmus Villemoes
2019-05-06 6:48 ` [PATCH 00/10] implement DYNAMIC_DEBUG_RELATIVE_POINTERS Rasmus Villemoes
2019-05-06 7:05 ` Ingo Molnar
2019-05-06 7:34 ` Rasmus Villemoes
2019-05-06 7:48 ` Ingo Molnar
2019-05-06 14:48 ` Segher Boessenkool
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=20190409212517.7321-7-linux@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=akpm@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).