netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/22] various dynamic_debug patches
@ 2018-09-19 22:04 Rasmus Villemoes
  2018-09-19 22:04 ` [PATCH 03/22] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited Rasmus Villemoes
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Rasmus Villemoes @ 2018-09-19 22:04 UTC (permalink / raw)
  To: Jason Baron, Andrew Morton
  Cc: linux-kernel, Rasmus Villemoes, Greg Kroah-Hartman, netdev,
	Petr Mladek, Steven Rostedt, linux-btrfs, linux-acpi, x86

This started as an experiment to see how hard it would be to change
the four pointers in struct _ddebug into relative offsets, a la
CONFIG_GENERIC_BUG_RELATIVE_POINTERS, thus saving 16 bytes per
pr_debug site (and thus exactly making up for the extra space used by
the introduction of jump labels in 9049fc74). I stumbled on a few
things that are probably worth fixing regardless of whether the latter
half of this series is deemed worthwhile.

Patch relationships: 1-2, 3-4, 5-6 and 15-16 can be applied
individually, though 2, 4 and 6 probably makes most sense in the
context of the final goal of the series.

7-12 I believe make sense on their own. Patch 13 again only makes
sense if we go all the way, and 14 and 17 depend on 13.

18-21 are more preparatory patches, and finally 22 switch over x86-64
to use CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS. I've tested that the
end result boots under virtme and that the dynamic_debug control file
has the expected contents.

Rasmus Villemoes (22):
  linux/device.h: use DYNAMIC_DEBUG_BRANCH in dev_dbg_ratelimited
  linux/device.h: use unique identifier for each struct _ddebug
  linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited
  linux/net.h: use unique identifier for each struct _ddebug
  linux/printk.h: use DYNAMIC_DEBUG_BRANCH in pr_debug_ratelimited
  linux/printk.h: use unique identifier for each struct _ddebug
  dynamic_debug: consolidate DEFINE_DYNAMIC_DEBUG_METADATA definitions
  dynamic_debug: don't duplicate modname in ddebug_add_module
  dynamic_debug: use pointer comparison in ddebug_remove_module
  dynamic_debug: remove unused EXPORT_SYMBOLs
  dynamic_debug: move pr_err from module.c to ddebug_add_module
  dynamic_debug: add static inline stub for ddebug_add_module
  dynamic_debug: refactor dynamic_pr_debug and friends
  btrfs: implement btrfs_debug* in terms of helper macro
  ACPI: use proper DYNAMIC_DEBUG_BRANCH macro
  ACPI: remove unused __acpi_handle_debug macro
  ACPI: implement acpi_handle_debug in terms of _dynamic_func_call
  dynamic_debug: introduce accessors for string members of struct
    _ddebug
  dynamic_debug: drop use of bitfields in struct _ddebug
  dynamic_debug: introduce CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS
  x86: jump_label: introduce ASM_STATIC_KEY_INIT_{TRUE,FALSE}
  x86_64: use relative pointers with dynamic debug

 arch/x86/Kconfig                     |   1 +
 arch/x86/include/asm/dynamic_debug.h |  35 +++++++++
 arch/x86/include/asm/jump_label.h    |  18 +++++
 fs/btrfs/ctree.h                     |  34 +++------
 include/linux/acpi.h                 |  11 +--
 include/linux/device.h               |   6 +-
 include/linux/dynamic_debug.h        | 126 +++++++++++++++++++--------------
 include/linux/jump_label.h           |   2 +
 include/linux/net.h                  |   6 +-
 include/linux/printk.h               |   6 +-
 kernel/module.c                      |   6 +-
 lib/Kconfig.debug                    |   3 +
 lib/dynamic_debug.c                  | 133 ++++++++++++++++++++++++-----------
 13 files changed, 251 insertions(+), 136 deletions(-)
 create mode 100644 arch/x86/include/asm/dynamic_debug.h

-- 
2.16.4

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 03/22] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited
  2018-09-19 22:04 [PATCH 00/22] various dynamic_debug patches Rasmus Villemoes
@ 2018-09-19 22:04 ` Rasmus Villemoes
  2018-09-19 22:04 ` [PATCH 04/22] linux/net.h: use unique identifier for each struct _ddebug Rasmus Villemoes
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 17+ messages in thread
From: Rasmus Villemoes @ 2018-09-19 22:04 UTC (permalink / raw)
  To: Jason Baron, Andrew Morton; +Cc: linux-kernel, Rasmus Villemoes, netdev

net_dbg_ratelimited tests the dynamic debug descriptor the old-fashioned
way, and doesn't utilize the static key/jump label implementation on
architectures that HAVE_JUMP_LABEL. Use the DYNAMIC_DEBUG_BRANCH which
is defined appropriately.

Cc: netdev@vger.kernel.org
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/net.h b/include/linux/net.h
index e0930678c8bf..651fca72286c 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -263,7 +263,7 @@ do {								\
 #define net_dbg_ratelimited(fmt, ...)					\
 do {									\
 	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
-	if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) &&	\
+	if (DYNAMIC_DEBUG_BRANCH(descriptor) &&				\
 	    net_ratelimit())						\
 		__dynamic_pr_debug(&descriptor, pr_fmt(fmt),		\
 		                   ##__VA_ARGS__);			\
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 04/22] linux/net.h: use unique identifier for each struct _ddebug
  2018-09-19 22:04 [PATCH 00/22] various dynamic_debug patches Rasmus Villemoes
  2018-09-19 22:04 ` [PATCH 03/22] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited Rasmus Villemoes
@ 2018-09-19 22:04 ` Rasmus Villemoes
  2018-09-20  8:05 ` [PATCH 00/22] various dynamic_debug patches Rafael J. Wysocki
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 17+ messages in thread
From: Rasmus Villemoes @ 2018-09-19 22:04 UTC (permalink / raw)
  To: Jason Baron, Andrew Morton; +Cc: linux-kernel, Rasmus Villemoes, netdev

Changes on x86-64 later in this series require that all struct _ddebug
descriptors in a translation unit uses distinct identifiers. Realize
that for net_dbg_ratelimited by generating such an identifier via
__UNIQUE_ID and pass that to an extra level of macros.

No functional change.

Cc: netdev@vger.kernel.org
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/net.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/net.h b/include/linux/net.h
index 651fca72286c..397243a25f56 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -260,7 +260,7 @@ do {								\
 #define net_info_ratelimited(fmt, ...)				\
 	net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__)
 #if defined(CONFIG_DYNAMIC_DEBUG)
-#define net_dbg_ratelimited(fmt, ...)					\
+#define _net_dbg_ratelimited(descriptor, fmt, ...)			\
 do {									\
 	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
 	if (DYNAMIC_DEBUG_BRANCH(descriptor) &&				\
@@ -268,6 +268,8 @@ do {									\
 		__dynamic_pr_debug(&descriptor, pr_fmt(fmt),		\
 		                   ##__VA_ARGS__);			\
 } while (0)
+#define net_dbg_ratelimited(fmt, ...)					\
+	_net_dbg_ratelimited(__UNIQUE_ID(ddebug), fmt, ##__VA_ARGS__)
 #elif defined(DEBUG)
 #define net_dbg_ratelimited(fmt, ...)				\
 	net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 00/22] various dynamic_debug patches
  2018-09-19 22:04 [PATCH 00/22] various dynamic_debug patches Rasmus Villemoes
  2018-09-19 22:04 ` [PATCH 03/22] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited Rasmus Villemoes
  2018-09-19 22:04 ` [PATCH 04/22] linux/net.h: use unique identifier for each struct _ddebug Rasmus Villemoes
@ 2018-09-20  8:05 ` Rafael J. Wysocki
  2018-10-03  9:25   ` Rafael J. Wysocki
  2018-09-22  0:27 ` Jason Baron
  2018-10-09 11:19 ` [PATCH v2 00/23] " Rasmus Villemoes
  4 siblings, 1 reply; 17+ messages in thread
From: Rafael J. Wysocki @ 2018-09-20  8:05 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: Jason Baron, Andrew Morton, linux-kernel, Greg Kroah-Hartman,
	netdev, Petr Mladek, Steven Rostedt, linux-btrfs, linux-acpi,
	x86

On Thursday, September 20, 2018 12:04:22 AM CEST Rasmus Villemoes wrote:
> This started as an experiment to see how hard it would be to change
> the four pointers in struct _ddebug into relative offsets, a la
> CONFIG_GENERIC_BUG_RELATIVE_POINTERS, thus saving 16 bytes per
> pr_debug site (and thus exactly making up for the extra space used by
> the introduction of jump labels in 9049fc74). I stumbled on a few
> things that are probably worth fixing regardless of whether the latter
> half of this series is deemed worthwhile.
> 
> Patch relationships: 1-2, 3-4, 5-6 and 15-16 can be applied
> individually, though 2, 4 and 6 probably makes most sense in the
> context of the final goal of the series.

OK, I can take the [15-16/22] separately.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 00/22] various dynamic_debug patches
  2018-09-19 22:04 [PATCH 00/22] various dynamic_debug patches Rasmus Villemoes
                   ` (2 preceding siblings ...)
  2018-09-20  8:05 ` [PATCH 00/22] various dynamic_debug patches Rafael J. Wysocki
@ 2018-09-22  0:27 ` Jason Baron
  2018-10-09 11:19 ` [PATCH v2 00/23] " Rasmus Villemoes
  4 siblings, 0 replies; 17+ messages in thread
From: Jason Baron @ 2018-09-22  0:27 UTC (permalink / raw)
  To: Rasmus Villemoes, Andrew Morton
  Cc: linux-kernel, Greg Kroah-Hartman, netdev, Petr Mladek,
	Steven Rostedt, linux-btrfs, linux-acpi, x86

On 09/19/2018 06:04 PM, Rasmus Villemoes wrote:
> This started as an experiment to see how hard it would be to change
> the four pointers in struct _ddebug into relative offsets, a la
> CONFIG_GENERIC_BUG_RELATIVE_POINTERS, thus saving 16 bytes per
> pr_debug site (and thus exactly making up for the extra space used by
> the introduction of jump labels in 9049fc74). I stumbled on a few
> things that are probably worth fixing regardless of whether the latter
> half of this series is deemed worthwhile.
> 
> Patch relationships: 1-2, 3-4, 5-6 and 15-16 can be applied
> individually, though 2, 4 and 6 probably makes most sense in the
> context of the final goal of the series.
> 
> 7-12 I believe make sense on their own. Patch 13 again only makes
> sense if we go all the way, and 14 and 17 depend on 13.
> 
> 18-21 are more preparatory patches, and finally 22 switch over x86-64
> to use CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS. I've tested that the
> end result boots under virtme and that the dynamic_debug control file
> has the expected contents.
> 

I would like to to see all these patches included. Feel free to add:
Acked-by: Jason Baron <jbaron@akamai.com>

I've been wanting to add DYNAMIC_DEBUG_BRANCH to the
[dev,net,pr].*ratelimited functions. That should reduce the size of the
text as well.

Thanks,

-Jason

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 00/22] various dynamic_debug patches
  2018-09-20  8:05 ` [PATCH 00/22] various dynamic_debug patches Rafael J. Wysocki
@ 2018-10-03  9:25   ` Rafael J. Wysocki
  0 siblings, 0 replies; 17+ messages in thread
From: Rafael J. Wysocki @ 2018-10-03  9:25 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: Jason Baron, Andrew Morton, linux-kernel, Greg Kroah-Hartman,
	netdev, Petr Mladek, Steven Rostedt, linux-btrfs, linux-acpi,
	x86

On Thursday, September 20, 2018 10:05:00 AM CEST Rafael J. Wysocki wrote:
> On Thursday, September 20, 2018 12:04:22 AM CEST Rasmus Villemoes wrote:
> > This started as an experiment to see how hard it would be to change
> > the four pointers in struct _ddebug into relative offsets, a la
> > CONFIG_GENERIC_BUG_RELATIVE_POINTERS, thus saving 16 bytes per
> > pr_debug site (and thus exactly making up for the extra space used by
> > the introduction of jump labels in 9049fc74). I stumbled on a few
> > things that are probably worth fixing regardless of whether the latter
> > half of this series is deemed worthwhile.
> > 
> > Patch relationships: 1-2, 3-4, 5-6 and 15-16 can be applied
> > individually, though 2, 4 and 6 probably makes most sense in the
> > context of the final goal of the series.
> 
> OK, I can take the [15-16/22] separately.

And they have been applied now.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 00/23] various dynamic_debug patches
  2018-09-19 22:04 [PATCH 00/22] various dynamic_debug patches Rasmus Villemoes
                   ` (3 preceding siblings ...)
  2018-09-22  0:27 ` Jason Baron
@ 2018-10-09 11:19 ` Rasmus Villemoes
  2018-10-09 11:19   ` [PATCH v2 03/23] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited Rasmus Villemoes
                     ` (3 more replies)
  4 siblings, 4 replies; 17+ messages in thread
From: Rasmus Villemoes @ 2018-10-09 11:19 UTC (permalink / raw)
  To: Jason Baron, Andrew Morton
  Cc: linux-kernel, Rasmus Villemoes, Greg Kroah-Hartman, netdev,
	Petr Mladek, Steven Rostedt, linux-btrfs, linux-acpi, x86

v2: Added various acks/reviews. I'll follow up with rewriting the x86
part as asm macros once that work is in mainline.

Patches 15, 16 are in next-20181009; in hindsight I should probably
have asked Rafael not to pick those. Patch 17 textually depend on
those, and patch 19 removes the .flags field, so depends on 15 so that
there are no references to that field. I'm included all patches here
hoping that the merge conflicts are trivial, given that it's just same
patches present in multiple branches.

Andrew, can you pick up these to give them some time in -next?

v1 cover letter:

This started as an experiment to see how hard it would be to change
the four pointers in struct _ddebug into relative offsets, a la
CONFIG_GENERIC_BUG_RELATIVE_POINTERS, thus saving 16 bytes per
pr_debug site (and thus exactly making up for the extra space used by
the introduction of jump labels in 9049fc74). I stumbled on a few
things that are probably worth fixing regardless of whether the latter
half of this series is deemed worthwhile.

Patch relationships: 1-2, 3-4, 5-6 and 15-16 can be applied
individually, though 2, 4 and 6 probably makes most sense in the
context of the final goal of the series.

7-12 I believe make sense on their own. Patch 13 again only makes
sense if we go all the way, and 14 and 17 depend on 13.

18-21 are more preparatory patches, and finally 22 switch over x86-64
to use CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS. I've tested that the
end result boots under virtme and that the dynamic_debug control file
has the expected contents.

Rasmus Villemoes (23):
  linux/device.h: use DYNAMIC_DEBUG_BRANCH in dev_dbg_ratelimited
  linux/device.h: use unique identifier for each struct _ddebug
  linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited
  linux/net.h: use unique identifier for each struct _ddebug
  linux/printk.h: use DYNAMIC_DEBUG_BRANCH in pr_debug_ratelimited
  linux/printk.h: use unique identifier for each struct _ddebug
  dynamic_debug: consolidate DEFINE_DYNAMIC_DEBUG_METADATA definitions
  dynamic_debug: don't duplicate modname in ddebug_add_module
  dynamic_debug: use pointer comparison in ddebug_remove_module
  dynamic_debug: remove unused EXPORT_SYMBOLs
  dynamic_debug: move pr_err from module.c to ddebug_add_module
  dynamic_debug: add static inline stub for ddebug_add_module
  dynamic_debug: refactor dynamic_pr_debug and friends
  btrfs: implement btrfs_debug* in terms of helper macro
  ACPI: use proper DYNAMIC_DEBUG_BRANCH macro
  ACPI: remove unused __acpi_handle_debug macro
  ACPI: implement acpi_handle_debug in terms of _dynamic_func_call
  dynamic_debug: introduce accessors for string members of struct
    _ddebug
  dynamic_debug: drop use of bitfields in struct _ddebug
  dynamic_debug: introduce CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS
  x86: jump_label: introduce ASM_STATIC_KEY_INIT_{TRUE,FALSE}
  x86_64: use relative pointers with dynamic debug
  x86: dynamic_debug: protect against dynamic debug identifier reuse

 arch/x86/Kconfig                     |   1 +
 arch/x86/include/asm/dynamic_debug.h |  40 ++++++++
 arch/x86/include/asm/jump_label.h    |  18 ++++
 fs/btrfs/ctree.h                     |  34 ++-----
 include/linux/acpi.h                 |  11 +--
 include/linux/device.h               |   6 +-
 include/linux/dynamic_debug.h        | 126 +++++++++++++++----------
 include/linux/jump_label.h           |   2 +
 include/linux/net.h                  |   6 +-
 include/linux/printk.h               |   6 +-
 kernel/module.c                      |   6 +-
 lib/Kconfig.debug                    |   3 +
 lib/dynamic_debug.c                  | 133 ++++++++++++++++++---------
 13 files changed, 256 insertions(+), 136 deletions(-)
 create mode 100644 arch/x86/include/asm/dynamic_debug.h

-- 
2.19.1.3.g1d92a00e68

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 03/23] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited
  2018-10-09 11:19 ` [PATCH v2 00/23] " Rasmus Villemoes
@ 2018-10-09 11:19   ` Rasmus Villemoes
  2018-10-09 11:19   ` [PATCH v2 04/23] linux/net.h: use unique identifier for each struct _ddebug Rasmus Villemoes
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: Rasmus Villemoes @ 2018-10-09 11:19 UTC (permalink / raw)
  To: Jason Baron, Andrew Morton; +Cc: linux-kernel, Rasmus Villemoes, netdev

net_dbg_ratelimited tests the dynamic debug descriptor the old-fashioned
way, and doesn't utilize the static key/jump label implementation on
architectures that HAVE_JUMP_LABEL. Use the DYNAMIC_DEBUG_BRANCH which
is defined appropriately.

Cc: netdev@vger.kernel.org
Acked-by: Jason Baron <jbaron@akamai.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/net.h b/include/linux/net.h
index e0930678c8bf..651fca72286c 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -263,7 +263,7 @@ do {								\
 #define net_dbg_ratelimited(fmt, ...)					\
 do {									\
 	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
-	if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) &&	\
+	if (DYNAMIC_DEBUG_BRANCH(descriptor) &&				\
 	    net_ratelimit())						\
 		__dynamic_pr_debug(&descriptor, pr_fmt(fmt),		\
 		                   ##__VA_ARGS__);			\
-- 
2.19.1.3.g1d92a00e68

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 04/23] linux/net.h: use unique identifier for each struct _ddebug
  2018-10-09 11:19 ` [PATCH v2 00/23] " Rasmus Villemoes
  2018-10-09 11:19   ` [PATCH v2 03/23] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited Rasmus Villemoes
@ 2018-10-09 11:19   ` Rasmus Villemoes
  2018-10-10  9:37   ` [PATCH v2 00/23] various dynamic_debug patches Rafael J. Wysocki
  2018-11-09 23:09   ` [PATCH v3 " Rasmus Villemoes
  3 siblings, 0 replies; 17+ messages in thread
From: Rasmus Villemoes @ 2018-10-09 11:19 UTC (permalink / raw)
  To: Jason Baron, Andrew Morton; +Cc: linux-kernel, Rasmus Villemoes, netdev

Changes on x86-64 later in this series require that all struct _ddebug
descriptors in a translation unit uses distinct identifiers. Realize
that for net_dbg_ratelimited by generating such an identifier via
__UNIQUE_ID and pass that to an extra level of macros.

No functional change.

Cc: netdev@vger.kernel.org
Acked-by: Jason Baron <jbaron@akamai.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/net.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/net.h b/include/linux/net.h
index 651fca72286c..397243a25f56 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -260,7 +260,7 @@ do {								\
 #define net_info_ratelimited(fmt, ...)				\
 	net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__)
 #if defined(CONFIG_DYNAMIC_DEBUG)
-#define net_dbg_ratelimited(fmt, ...)					\
+#define _net_dbg_ratelimited(descriptor, fmt, ...)			\
 do {									\
 	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
 	if (DYNAMIC_DEBUG_BRANCH(descriptor) &&				\
@@ -268,6 +268,8 @@ do {									\
 		__dynamic_pr_debug(&descriptor, pr_fmt(fmt),		\
 		                   ##__VA_ARGS__);			\
 } while (0)
+#define net_dbg_ratelimited(fmt, ...)					\
+	_net_dbg_ratelimited(__UNIQUE_ID(ddebug), fmt, ##__VA_ARGS__)
 #elif defined(DEBUG)
 #define net_dbg_ratelimited(fmt, ...)				\
 	net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
-- 
2.19.1.3.g1d92a00e68

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 00/23] various dynamic_debug patches
  2018-10-09 11:19 ` [PATCH v2 00/23] " Rasmus Villemoes
  2018-10-09 11:19   ` [PATCH v2 03/23] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited Rasmus Villemoes
  2018-10-09 11:19   ` [PATCH v2 04/23] linux/net.h: use unique identifier for each struct _ddebug Rasmus Villemoes
@ 2018-10-10  9:37   ` Rafael J. Wysocki
  2018-11-09 23:09   ` [PATCH v3 " Rasmus Villemoes
  3 siblings, 0 replies; 17+ messages in thread
From: Rafael J. Wysocki @ 2018-10-10  9:37 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: jbaron, Andrew Morton, Linux Kernel Mailing List,
	Greg Kroah-Hartman, netdev, Petr Mladek, Steven Rostedt,
	linux-btrfs, ACPI Devel Maling List, the arch/x86 maintainers

On Tue, Oct 9, 2018 at 1:20 PM Rasmus Villemoes
<linux@rasmusvillemoes.dk> wrote:
>
> v2: Added various acks/reviews. I'll follow up with rewriting the x86
> part as asm macros once that work is in mainline.
>
> Patches 15, 16 are in next-20181009; in hindsight I should probably
> have asked Rafael not to pick those.

So I have dropped them (which was easy enough to do).

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v3 00/23] various dynamic_debug patches
  2018-10-09 11:19 ` [PATCH v2 00/23] " Rasmus Villemoes
                     ` (2 preceding siblings ...)
  2018-10-10  9:37   ` [PATCH v2 00/23] various dynamic_debug patches Rafael J. Wysocki
@ 2018-11-09 23:09   ` Rasmus Villemoes
  2018-11-09 23:10     ` [PATCH v3 03/23] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited Rasmus Villemoes
                       ` (2 more replies)
  3 siblings, 3 replies; 17+ messages in thread
From: Rasmus Villemoes @ 2018-11-09 23:09 UTC (permalink / raw)
  To: Andrew Morton, Jason Baron
  Cc: linux-kernel, Rasmus Villemoes, David Sterba, Petr Mladek,
	Rafael J . Wysocki, linux-acpi, linux-btrfs, netdev,
	Steven Rostedt, x86, Greg Kroah-Hartman, Ingo Molnar

This started as an experiment to see how hard it would be to change
the four pointers in struct _ddebug into relative offsets, a la
CONFIG_GENERIC_BUG_RELATIVE_POINTERS, thus saving 16 bytes per
pr_debug site (and thus exactly making up for the extra space used by
the introduction of jump labels in 9049fc74). I stumbled on a few
things that are probably worth fixing regardless of whether that goal
is deemed worthwhile.

v2: Added various acks/reviews.

v3: Rebased on top of v4.20-rc1, and (consequently) reimplemented the
x86 part using Nadav's asm macro infrastructure. I've taken the
liberty of preserving acks/reviews for the first 20, since the rebase
was completely clean. OTOH, I've removed any acks/reviews from the
last three patches, since they are essentially completely new in this
version.

Since there are some interdependencies, it's simplest if these go
through the same tree. Andrew, can I get you to pick up patches 1
through 17? They should be ready for some time in -next. If and when
the last three (new) patches get ack'ed, I'll ask you to pick up the
last 6 (Jason has ack'ed 18-20, but they don't make much sense without
at least one arch opting in to use DYNAMIC_DEBUG_RELATIVE_POINTERS).

Rasmus Villemoes (23):
  linux/device.h: use DYNAMIC_DEBUG_BRANCH in dev_dbg_ratelimited
  linux/device.h: use unique identifier for each struct _ddebug
  linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited
  linux/net.h: use unique identifier for each struct _ddebug
  linux/printk.h: use DYNAMIC_DEBUG_BRANCH in pr_debug_ratelimited
  linux/printk.h: use unique identifier for each struct _ddebug
  dynamic_debug: consolidate DEFINE_DYNAMIC_DEBUG_METADATA definitions
  dynamic_debug: don't duplicate modname in ddebug_add_module
  dynamic_debug: use pointer comparison in ddebug_remove_module
  dynamic_debug: remove unused EXPORT_SYMBOLs
  dynamic_debug: move pr_err from module.c to ddebug_add_module
  dynamic_debug: add static inline stub for ddebug_add_module
  dynamic_debug: refactor dynamic_pr_debug and friends
  btrfs: implement btrfs_debug* in terms of helper macro
  ACPI: use proper DYNAMIC_DEBUG_BRANCH macro
  ACPI: remove unused __acpi_handle_debug macro
  ACPI: implement acpi_handle_debug in terms of _dynamic_func_call
  dynamic_debug: introduce accessors for string members of struct
    _ddebug
  dynamic_debug: drop use of bitfields in struct _ddebug
  dynamic_debug: introduce CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS
  jump_label: move JUMP_TYPE_* constants to new asm-generic file
  x86: jump_label: introduce asm macros STATIC_KEY_INIT{,_TRUE,_FALSE}
  x86_64: use relative pointers with dynamic debug

 arch/x86/Kconfig                     |   1 +
 arch/x86/include/asm/dynamic_debug.h |  58 ++++++++++++
 arch/x86/include/asm/jump_label.h    |  17 ++++
 arch/x86/kernel/macros.S             |   1 +
 fs/btrfs/ctree.h                     |  34 ++-----
 include/asm-generic/jump_label.h     |  11 +++
 include/linux/acpi.h                 |  11 +--
 include/linux/device.h               |   6 +-
 include/linux/dynamic_debug.h        | 126 +++++++++++++++----------
 include/linux/jump_label.h           |   6 +-
 include/linux/net.h                  |   6 +-
 include/linux/printk.h               |   6 +-
 kernel/module.c                      |   6 +-
 lib/Kconfig.debug                    |   3 +
 lib/dynamic_debug.c                  | 133 ++++++++++++++++++---------
 15 files changed, 284 insertions(+), 141 deletions(-)
 create mode 100644 arch/x86/include/asm/dynamic_debug.h
 create mode 100644 include/asm-generic/jump_label.h

-- 
2.19.1.6.gbde171bbf5

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v3 03/23] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited
  2018-11-09 23:09   ` [PATCH v3 " Rasmus Villemoes
@ 2018-11-09 23:10     ` Rasmus Villemoes
  2018-11-09 23:10     ` [PATCH v3 04/23] linux/net.h: use unique identifier for each struct _ddebug Rasmus Villemoes
  2019-02-12 21:41     ` [PATCH v4 00/14] various dynamic_debug patches Rasmus Villemoes
  2 siblings, 0 replies; 17+ messages in thread
From: Rasmus Villemoes @ 2018-11-09 23:10 UTC (permalink / raw)
  To: Andrew Morton, Jason Baron; +Cc: linux-kernel, Rasmus Villemoes, netdev

net_dbg_ratelimited tests the dynamic debug descriptor the old-fashioned
way, and doesn't utilize the static key/jump label implementation on
architectures that HAVE_JUMP_LABEL. Use the DYNAMIC_DEBUG_BRANCH which
is defined appropriately.

Cc: netdev@vger.kernel.org
Acked-by: Jason Baron <jbaron@akamai.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/net.h b/include/linux/net.h
index e0930678c8bf..651fca72286c 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -263,7 +263,7 @@ do {								\
 #define net_dbg_ratelimited(fmt, ...)					\
 do {									\
 	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
-	if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) &&	\
+	if (DYNAMIC_DEBUG_BRANCH(descriptor) &&				\
 	    net_ratelimit())						\
 		__dynamic_pr_debug(&descriptor, pr_fmt(fmt),		\
 		                   ##__VA_ARGS__);			\
-- 
2.19.1.6.gbde171bbf5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v3 04/23] linux/net.h: use unique identifier for each struct _ddebug
  2018-11-09 23:09   ` [PATCH v3 " Rasmus Villemoes
  2018-11-09 23:10     ` [PATCH v3 03/23] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited Rasmus Villemoes
@ 2018-11-09 23:10     ` Rasmus Villemoes
  2018-11-09 23:22       ` Joe Perches
  2019-02-12 21:41     ` [PATCH v4 00/14] various dynamic_debug patches Rasmus Villemoes
  2 siblings, 1 reply; 17+ messages in thread
From: Rasmus Villemoes @ 2018-11-09 23:10 UTC (permalink / raw)
  To: Andrew Morton, Jason Baron; +Cc: linux-kernel, Rasmus Villemoes, netdev

Changes on x86-64 later in this series require that all struct _ddebug
descriptors in a translation unit uses distinct identifiers. Realize
that for net_dbg_ratelimited by generating such an identifier via
__UNIQUE_ID and pass that to an extra level of macros.

No functional change.

Cc: netdev@vger.kernel.org
Acked-by: Jason Baron <jbaron@akamai.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/net.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/net.h b/include/linux/net.h
index 651fca72286c..397243a25f56 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -260,7 +260,7 @@ do {								\
 #define net_info_ratelimited(fmt, ...)				\
 	net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__)
 #if defined(CONFIG_DYNAMIC_DEBUG)
-#define net_dbg_ratelimited(fmt, ...)					\
+#define _net_dbg_ratelimited(descriptor, fmt, ...)			\
 do {									\
 	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
 	if (DYNAMIC_DEBUG_BRANCH(descriptor) &&				\
@@ -268,6 +268,8 @@ do {									\
 		__dynamic_pr_debug(&descriptor, pr_fmt(fmt),		\
 		                   ##__VA_ARGS__);			\
 } while (0)
+#define net_dbg_ratelimited(fmt, ...)					\
+	_net_dbg_ratelimited(__UNIQUE_ID(ddebug), fmt, ##__VA_ARGS__)
 #elif defined(DEBUG)
 #define net_dbg_ratelimited(fmt, ...)				\
 	net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
-- 
2.19.1.6.gbde171bbf5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v3 04/23] linux/net.h: use unique identifier for each struct _ddebug
  2018-11-09 23:10     ` [PATCH v3 04/23] linux/net.h: use unique identifier for each struct _ddebug Rasmus Villemoes
@ 2018-11-09 23:22       ` Joe Perches
  2018-11-09 23:31         ` Rasmus Villemoes
  0 siblings, 1 reply; 17+ messages in thread
From: Joe Perches @ 2018-11-09 23:22 UTC (permalink / raw)
  To: Rasmus Villemoes, Andrew Morton, Jason Baron; +Cc: linux-kernel, netdev

On Sat, 2018-11-10 at 00:10 +0100, Rasmus Villemoes wrote:
> Changes on x86-64 later in this series require that all struct _ddebug
> descriptors in a translation unit uses distinct identifiers. Realize
> that for net_dbg_ratelimited by generating such an identifier via
> __UNIQUE_ID and pass that to an extra level of macros.
> 
> No functional change.

Why does this require an extra indirection _<macro>?

> Cc: netdev@vger.kernel.org
> Acked-by: Jason Baron <jbaron@akamai.com>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
>  include/linux/net.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/net.h b/include/linux/net.h
> index 651fca72286c..397243a25f56 100644
> --- a/include/linux/net.h
> +++ b/include/linux/net.h
> @@ -260,7 +260,7 @@ do {								\
>  #define net_info_ratelimited(fmt, ...)				\
>  	net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__)
>  #if defined(CONFIG_DYNAMIC_DEBUG)
> -#define net_dbg_ratelimited(fmt, ...)					\
> +#define _net_dbg_ratelimited(descriptor, fmt, ...)			\
>  do {									\
>  	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
>  	if (DYNAMIC_DEBUG_BRANCH(descriptor) &&				\
> @@ -268,6 +268,8 @@ do {									\
>  		__dynamic_pr_debug(&descriptor, pr_fmt(fmt),		\
>  		                   ##__VA_ARGS__);			\
>  } while (0)
> +#define net_dbg_ratelimited(fmt, ...)					\
> +	_net_dbg_ratelimited(__UNIQUE_ID(ddebug), fmt, ##__VA_ARGS__)
>  #elif defined(DEBUG)
>  #define net_dbg_ratelimited(fmt, ...)				\
>  	net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v3 04/23] linux/net.h: use unique identifier for each struct _ddebug
  2018-11-09 23:22       ` Joe Perches
@ 2018-11-09 23:31         ` Rasmus Villemoes
  0 siblings, 0 replies; 17+ messages in thread
From: Rasmus Villemoes @ 2018-11-09 23:31 UTC (permalink / raw)
  To: Joe Perches, Rasmus Villemoes, Andrew Morton, Jason Baron
  Cc: linux-kernel, netdev

On 10/11/2018 00.22, Joe Perches wrote:
> On Sat, 2018-11-10 at 00:10 +0100, Rasmus Villemoes wrote:
>> Changes on x86-64 later in this series require that all struct _ddebug
>> descriptors in a translation unit uses distinct identifiers. Realize
>> that for net_dbg_ratelimited by generating such an identifier via
>> __UNIQUE_ID and pass that to an extra level of macros.
>>
>> No functional change.
> 
> Why does this require an extra indirection _<macro>?
> 

Because the identifier used in the

>>  	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);

line must be the same as the one in the

>>  	if (DYNAMIC_DEBUG_BRANCH(descriptor) &&	

line. That identifier used to be simply "descriptor", with C scope rules
making that ok. But because of the asm games I'm playing later, I need
to generate a fresh identifier for each instance. That identifier must
be referenced in two places in the C source - hence the need to use an
extra level of macros to have the __UNIQUE_ID() expanded before
_net_dbg_ratelimited gets expanded.

More or less every use of __UNIQUE_ID requires such an extra level
(because one very rarely needs to use an identifier exactly once - the
point of giving stuff a name is to refer to it again.)

Rasmus

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v4 00/14] various dynamic_debug patches
  2018-11-09 23:09   ` [PATCH v3 " Rasmus Villemoes
  2018-11-09 23:10     ` [PATCH v3 03/23] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited Rasmus Villemoes
  2018-11-09 23:10     ` [PATCH v3 04/23] linux/net.h: use unique identifier for each struct _ddebug Rasmus Villemoes
@ 2019-02-12 21:41     ` Rasmus Villemoes
  2019-02-12 21:41       ` [PATCH v4 02/14] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited Rasmus Villemoes
  2 siblings, 1 reply; 17+ messages in thread
From: Rasmus Villemoes @ 2019-02-12 21:41 UTC (permalink / raw)
  To: Andrew Morton, Jason Baron
  Cc: linux-kernel, Rasmus Villemoes, David Sterba, Petr Mladek,
	Rafael J . Wysocki, linux-acpi, linux-btrfs, netdev,
	Steven Rostedt, x86, Greg Kroah-Hartman, Ingo Molnar

This started as an experiment to see how hard it would be to change
the four pointers in struct _ddebug into relative offsets, a la
CONFIG_GENERIC_BUG_RELATIVE_POINTERS, thus saving 16 bytes per
pr_debug site (and thus exactly making up for the extra space used by
the introduction of jump labels in 9049fc74). I stumbled on a few
things that are probably worth fixing regardless of whether that goal
is deemed worthwhile.

Back at v3 (in November), I redid the implementation on top of the
fancy new asm-macros stuff. Luckily enough, v3 didn't get picked up,
since the asm-macros were backed out again. I still want to do the
relative-pointers thing eventually, but we're close to the merge
window opening, so here's just most of the "incidental" patches, some
of which also serve as preparation for the relative pointers.

I'm not sure how long an Ack/Reviewed-by is good for, but OTOH it also
feels rude to just drop them on the floor. I've kept those tags since
the rebasing to current master went completely smooth.

Andrew, please pick these up for soaking in -next.

v3 series: lkml.kernel.org/r/20181109231021.11658-1-linux@rasmusvillemoes.dk
v2 series: lkml.kernel.org/r/20181009112013.14238-1-linux@rasmusvillemoes.dk

Rasmus Villemoes (14):
  linux/device.h: use DYNAMIC_DEBUG_BRANCH in dev_dbg_ratelimited
  linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited
  linux/printk.h: use DYNAMIC_DEBUG_BRANCH in pr_debug_ratelimited
  dynamic_debug: consolidate DEFINE_DYNAMIC_DEBUG_METADATA definitions
  dynamic_debug: don't duplicate modname in ddebug_add_module
  dynamic_debug: use pointer comparison in ddebug_remove_module
  dynamic_debug: remove unused EXPORT_SYMBOLs
  dynamic_debug: move pr_err from module.c to ddebug_add_module
  dynamic_debug: add static inline stub for ddebug_add_module
  dynamic_debug: refactor dynamic_pr_debug and friends
  btrfs: implement btrfs_debug* in terms of helper macro
  ACPI: use proper DYNAMIC_DEBUG_BRANCH macro
  ACPI: remove unused __acpi_handle_debug macro
  ACPI: implement acpi_handle_debug in terms of _dynamic_func_call

 fs/btrfs/ctree.h              |  34 ++++--------
 include/linux/acpi.h          |  11 +---
 include/linux/device.h        |   2 +-
 include/linux/dynamic_debug.h | 102 +++++++++++++++++++---------------
 include/linux/net.h           |   2 +-
 include/linux/printk.h        |   2 +-
 kernel/module.c               |   6 +-
 lib/dynamic_debug.c           |  22 ++++----
 8 files changed, 84 insertions(+), 97 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v4 02/14] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited
  2019-02-12 21:41     ` [PATCH v4 00/14] various dynamic_debug patches Rasmus Villemoes
@ 2019-02-12 21:41       ` Rasmus Villemoes
  0 siblings, 0 replies; 17+ messages in thread
From: Rasmus Villemoes @ 2019-02-12 21:41 UTC (permalink / raw)
  To: Andrew Morton, Jason Baron; +Cc: linux-kernel, Rasmus Villemoes, netdev

net_dbg_ratelimited tests the dynamic debug descriptor the
old-fashioned way, and doesn't utilize the static key/jump label
implementation when CONFIG_JUMP_LABEL is set. Use the
DYNAMIC_DEBUG_BRANCH which is defined appropriately.

Cc: netdev@vger.kernel.org
Acked-by: Jason Baron <jbaron@akamai.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/net.h b/include/linux/net.h
index e0930678c8bf..651fca72286c 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -263,7 +263,7 @@ do {								\
 #define net_dbg_ratelimited(fmt, ...)					\
 do {									\
 	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
-	if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) &&	\
+	if (DYNAMIC_DEBUG_BRANCH(descriptor) &&				\
 	    net_ratelimit())						\
 		__dynamic_pr_debug(&descriptor, pr_fmt(fmt),		\
 		                   ##__VA_ARGS__);			\
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2019-02-12 21:43 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-19 22:04 [PATCH 00/22] various dynamic_debug patches Rasmus Villemoes
2018-09-19 22:04 ` [PATCH 03/22] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited Rasmus Villemoes
2018-09-19 22:04 ` [PATCH 04/22] linux/net.h: use unique identifier for each struct _ddebug Rasmus Villemoes
2018-09-20  8:05 ` [PATCH 00/22] various dynamic_debug patches Rafael J. Wysocki
2018-10-03  9:25   ` Rafael J. Wysocki
2018-09-22  0:27 ` Jason Baron
2018-10-09 11:19 ` [PATCH v2 00/23] " Rasmus Villemoes
2018-10-09 11:19   ` [PATCH v2 03/23] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited Rasmus Villemoes
2018-10-09 11:19   ` [PATCH v2 04/23] linux/net.h: use unique identifier for each struct _ddebug Rasmus Villemoes
2018-10-10  9:37   ` [PATCH v2 00/23] various dynamic_debug patches Rafael J. Wysocki
2018-11-09 23:09   ` [PATCH v3 " Rasmus Villemoes
2018-11-09 23:10     ` [PATCH v3 03/23] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited Rasmus Villemoes
2018-11-09 23:10     ` [PATCH v3 04/23] linux/net.h: use unique identifier for each struct _ddebug Rasmus Villemoes
2018-11-09 23:22       ` Joe Perches
2018-11-09 23:31         ` Rasmus Villemoes
2019-02-12 21:41     ` [PATCH v4 00/14] various dynamic_debug patches Rasmus Villemoes
2019-02-12 21:41       ` [PATCH v4 02/14] linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited Rasmus Villemoes

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).