From: Jason Baron <jbaron@redhat.com>
To: rostedt@goodmis.org
Cc: peterz@infradead.org, hpa@zytor.com,
mathieu.desnoyers@polymtl.ca, mingo@elte.hu, tglx@linutronix.de,
andi@firstfloor.org, roland@redhat.com, rth@redhat.com,
masami.hiramatsu.pt@hitachi.com, fweisbec@gmail.com,
avi@redhat.com, davem@davemloft.net, sam@ravnborg.org,
ddaney@caviumnetworks.com, michael@ellerman.id.au,
ralf@linux-mips.org, jang@linux.vnet.ibm.com,
schwidefsky@de.ibm.com, linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] dynamic debug: add jump label support
Date: Wed, 16 Mar 2011 15:58:23 -0400 [thread overview]
Message-ID: <5b0030e4e7c2b0cfbea666ce2cf0ef95651af5a5.1300299760.git.jbaron@redhat.com> (raw)
In-Reply-To: <cover.1300299760.git.jbaron@redhat.com>
Since jump labels make use of atomic_read(), and dynamic_debug.h
gets included by kernel.h, the inclusion of atomic.h in
dynamic_debug.h (to get atomic_read()), would cause a circular
dependency since atomic.h requires kernel.h. Thus, for dynamic
debug I am explicitly including jump_label.h when jump labels are
configured, and making use of a regular reads (non-atomic), when
jump labels are disabled.
Signed-off-by: Jason Baron <jbaron@redhat.com>
---
include/linux/dynamic_debug.h | 46 ++++++++++++++++++++++++++++++++++------
lib/dynamic_debug.c | 4 +-
2 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 8906d52..455cb3e 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -1,6 +1,26 @@
#ifndef _DYNAMIC_DEBUG_H
#define _DYNAMIC_DEBUG_H
+/*
+ * When jump labels are disabled, they make use of atomic_read(). Since
+ * dynamic_debug.h gets included by kernel.h, the inclusion of jump_label.h by
+ * dynamic_debug.h and thus atomic.h (to get atomic_read()), would cause a
+ * circular dependency since atomic.h requires kernel.h. Thus, for dynamic debug
+ * we are explicitly including jump_label.h when jump labels are configured, and
+ * making use of a regular reads (non-atomic), when jump labels are disabled.
+ */
+#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
+#include <linux/jump_label.h>
+#endif
+
+#ifdef HAVE_JUMP_LABEL
+ #define dd_enable(dp) do { jump_label_inc(&dp->enabled); } while (0)
+ #define dd_disable(dp) do { jump_label_dec(&dp->enabled); } while (0)
+#else
+ #define dd_enable(dp) do { dp->enabled = 1; } while (0)
+ #define dd_disable(dp) do { dp->enabled = 0; } while (0)
+#endif
+
/* dynamic_printk_enabled, and dynamic_printk_enabled2 are bitmasks in which
* bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They
* use independent hash functions, to reduce the chance of false positives.
@@ -31,7 +51,11 @@ struct _ddebug {
#define _DPRINTK_FLAGS_PRINT (1<<0) /* printk() a message using the format */
#define _DPRINTK_FLAGS_DEFAULT 0
unsigned int flags:8;
- char enabled;
+#ifdef HAVE_JUMP_LABEL
+ struct jump_label_key enabled;
+#else
+ int enabled;
+#endif
} __attribute__((aligned(8)));
@@ -41,14 +65,22 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
#if defined(CONFIG_DYNAMIC_DEBUG)
extern int ddebug_remove_module(const char *mod_name);
+#ifdef HAVE_JUMP_LABEL
+# define DDEBUG_INIT JUMP_LABEL_INIT
+# define DDEBUG_BRANCH(enabled) static_branch(&enabled)
+#else
+# define DDEBUG_INIT 0
+# define DDEBUG_BRANCH(enabled) unlikely(enabled)
+#endif
+
#define dynamic_pr_debug(fmt, ...) do { \
static struct _ddebug descriptor \
__used \
__attribute__((section("__verbose"), aligned(8))) = \
{ KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \
- _DPRINTK_FLAGS_DEFAULT }; \
- if (unlikely(descriptor.enabled)) \
- printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
+ _DPRINTK_FLAGS_DEFAULT, DDEBUG_INIT }; \
+ if (DDEBUG_BRANCH(descriptor.enabled)) \
+ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
} while (0)
@@ -57,9 +89,9 @@ extern int ddebug_remove_module(const char *mod_name);
__used \
__attribute__((section("__verbose"), aligned(8))) = \
{ KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \
- _DPRINTK_FLAGS_DEFAULT }; \
- if (unlikely(descriptor.enabled)) \
- dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \
+ _DPRINTK_FLAGS_DEFAULT, DDEBUG_INIT }; \
+ if (DDEBUG_BRANCH(descriptor.enabled)) \
+ dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \
} while (0)
#else
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index b335acb..5973c53 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -142,9 +142,9 @@ static void ddebug_change(const struct ddebug_query *query,
dt->num_enabled++;
dp->flags = newflags;
if (newflags)
- dp->enabled = 1;
+ dd_enable(dp);
else
- dp->enabled = 0;
+ dd_disable(dp);
if (verbose)
printk(KERN_INFO
"ddebug: changed %s:%d [%s]%s %s\n",
--
1.7.1
next prev parent reply other threads:[~2011-03-16 19:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-16 19:58 [PATCH v2 0/4] jump label: update for .39 v2 Jason Baron
2011-03-16 19:58 ` [PATCH 1/4] jump label: introduce static_branch() interface Jason Baron
2011-03-16 20:06 ` Need ack from sparc maintainer (was: [PATCH 1/4] jump label: introduce static_branch() interface) Steven Rostedt
2011-03-16 20:13 ` Need ack from sparc maintainer David Miller
2011-03-16 20:22 ` Steven Rostedt
2011-03-16 21:29 ` [PATCH 1/4] jump label: introduce static_branch() interface Jason Baron
2011-04-27 15:23 ` [tip:perf/core] jump label: Introduce " tip-bot for Jason Baron
2011-03-16 19:58 ` Jason Baron [this message]
2011-03-16 19:58 ` [PATCH 3/4] jump label: add _ASM_ALIGN for x86 and x86_64 Jason Baron
2011-04-27 15:23 ` [tip:perf/core] jump label: Add " tip-bot for Jason Baron
2011-03-16 19:58 ` [PATCH 4/4] jump label: add s390 support Jason Baron
2011-04-27 15:24 ` [tip:perf/core] jump label: Add " tip-bot for Jan Glauber
2011-03-16 20:36 ` [PATCH v2 0/4] jump label: update for .39 v2 Steven Rostedt
2011-03-16 21:31 ` Jason Baron
2011-03-16 22:08 ` Mathieu Desnoyers
2011-03-17 16:41 [PATCH 0/4] [GIT PULL] jump label: Cleanups for 2.6.39 Steven Rostedt
2011-03-17 16:41 ` [PATCH 2/4] dynamic debug: Add jump label support Steven Rostedt
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=5b0030e4e7c2b0cfbea666ce2cf0ef95651af5a5.1300299760.git.jbaron@redhat.com \
--to=jbaron@redhat.com \
--cc=andi@firstfloor.org \
--cc=avi@redhat.com \
--cc=davem@davemloft.net \
--cc=ddaney@caviumnetworks.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=jang@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=michael@ellerman.id.au \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=ralf@linux-mips.org \
--cc=roland@redhat.com \
--cc=rostedt@goodmis.org \
--cc=rth@redhat.com \
--cc=sam@ravnborg.org \
--cc=schwidefsky@de.ibm.com \
--cc=tglx@linutronix.de \
/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®