linux-acpi.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 15/22] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
                   ` (5 more replies)
  0 siblings, 6 replies; 23+ 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] 23+ messages in thread

* [PATCH 15/22] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro
  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 16/22] ACPI: remove unused __acpi_handle_debug macro Rasmus Villemoes
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 23+ messages in thread
From: Rasmus Villemoes @ 2018-09-19 22:04 UTC (permalink / raw)
  To: Jason Baron, Andrew Morton; +Cc: linux-kernel, Rasmus Villemoes, linux-acpi

dynamic debug may be implemented via static keys, but ACPI is missing
out on that runtime benefit since it open-codes one possible definition
of DYNAMIC_DEBUG_BRANCH.

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

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index de8d3d3fa651..21e03aa32aae 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -982,7 +982,7 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c
 #define acpi_handle_debug(handle, fmt, ...)				\
 do {									\
 	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
-	if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))		\
+	if (DYNAMIC_DEBUG_BRANCH(descriptor))				\
 		__acpi_handle_debug(&descriptor, handle, pr_fmt(fmt),	\
 				##__VA_ARGS__);				\
 } while (0)
-- 
2.16.4

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

* [PATCH 16/22] ACPI: remove unused __acpi_handle_debug macro
  2018-09-19 22:04 [PATCH 00/22] various dynamic_debug patches Rasmus Villemoes
  2018-09-19 22:04 ` [PATCH 15/22] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
@ 2018-09-19 22:04 ` Rasmus Villemoes
  2018-09-19 22:04 ` [PATCH 17/22] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call Rasmus Villemoes
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 23+ messages in thread
From: Rasmus Villemoes @ 2018-09-19 22:04 UTC (permalink / raw)
  To: Jason Baron, Andrew Morton; +Cc: linux-kernel, Rasmus Villemoes, linux-acpi

If CONFIG_DYNAMIC_DEBUG is not set, acpi_handle_debug directly invokes
acpi_handle_printk (if DEBUG) or does a no-printk (if !DEBUG). So this
macro is never used.

Cc: linux-acpi@vger.kernel.org
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/acpi.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 21e03aa32aae..e12d5ef1a054 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -948,9 +948,6 @@ acpi_handle_printk(const char *level, void *handle, const char *fmt, ...) {}
 #if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG)
 __printf(3, 4)
 void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const char *fmt, ...);
-#else
-#define __acpi_handle_debug(descriptor, handle, fmt, ...)		\
-	acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__);
 #endif
 
 /*
-- 
2.16.4

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

* [PATCH 17/22] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call
  2018-09-19 22:04 [PATCH 00/22] various dynamic_debug patches Rasmus Villemoes
  2018-09-19 22:04 ` [PATCH 15/22] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
  2018-09-19 22:04 ` [PATCH 16/22] ACPI: remove unused __acpi_handle_debug macro Rasmus Villemoes
@ 2018-09-19 22:04 ` Rasmus Villemoes
  2018-09-20  8:05   ` Rafael J. Wysocki
  2018-09-20  8:05 ` [PATCH 00/22] various dynamic_debug patches Rafael J. Wysocki
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 23+ messages in thread
From: Rasmus Villemoes @ 2018-09-19 22:04 UTC (permalink / raw)
  To: Jason Baron, Andrew Morton; +Cc: linux-kernel, Rasmus Villemoes, linux-acpi

With coming changes on x86-64, all dynamic debug descriptors in a
translation unit must have distinct names. The macro _dynamic_func_call
takes care of that. No functional change.

Cc: linux-acpi@vger.kernel.org
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/acpi.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index e12d5ef1a054..83bacf9039e9 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -977,12 +977,8 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c
 #else
 #if defined(CONFIG_DYNAMIC_DEBUG)
 #define acpi_handle_debug(handle, fmt, ...)				\
-do {									\
-	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
-	if (DYNAMIC_DEBUG_BRANCH(descriptor))				\
-		__acpi_handle_debug(&descriptor, handle, pr_fmt(fmt),	\
-				##__VA_ARGS__);				\
-} while (0)
+	_dynamic_func_call(fmt, __acpi_handle_debug,			\
+			   handle, pr_fmt(fmt), ##__VA_ARGS__)
 #else
 #define acpi_handle_debug(handle, fmt, ...)				\
 ({									\
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 23+ 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-19 22:04 ` [PATCH 17/22] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call 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
  5 siblings, 1 reply; 23+ 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] 23+ messages in thread

* Re: [PATCH 17/22] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call
  2018-09-19 22:04 ` [PATCH 17/22] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call Rasmus Villemoes
@ 2018-09-20  8:05   ` Rafael J. Wysocki
  0 siblings, 0 replies; 23+ 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, linux-acpi

On Thursday, September 20, 2018 12:04:39 AM CEST Rasmus Villemoes wrote:
> With coming changes on x86-64, all dynamic debug descriptors in a
> translation unit must have distinct names. The macro _dynamic_func_call
> takes care of that. No functional change.
> 
> Cc: linux-acpi@vger.kernel.org
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
>  include/linux/acpi.h | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index e12d5ef1a054..83bacf9039e9 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -977,12 +977,8 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c
>  #else
>  #if defined(CONFIG_DYNAMIC_DEBUG)
>  #define acpi_handle_debug(handle, fmt, ...)				\
> -do {									\
> -	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
> -	if (DYNAMIC_DEBUG_BRANCH(descriptor))				\
> -		__acpi_handle_debug(&descriptor, handle, pr_fmt(fmt),	\
> -				##__VA_ARGS__);				\
> -} while (0)
> +	_dynamic_func_call(fmt, __acpi_handle_debug,			\
> +			   handle, pr_fmt(fmt), ##__VA_ARGS__)
>  #else
>  #define acpi_handle_debug(handle, fmt, ...)				\
>  ({									\
> 

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

^ permalink raw reply	[flat|nested] 23+ 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
                   ` (3 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
  5 siblings, 0 replies; 23+ 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] 23+ 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; 23+ 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] 23+ 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
                   ` (4 preceding siblings ...)
  2018-09-22  0:27 ` Jason Baron
@ 2018-10-09 11:19 ` Rasmus Villemoes
  2018-10-09 11:20   ` [PATCH v2 15/23] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
                     ` (4 more replies)
  5 siblings, 5 replies; 23+ 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] 23+ messages in thread

* [PATCH v2 15/23] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro
  2018-10-09 11:19 ` [PATCH v2 00/23] " Rasmus Villemoes
@ 2018-10-09 11:20   ` Rasmus Villemoes
  2018-10-10  9:38     ` Rafael J. Wysocki
  2018-10-09 11:20   ` [PATCH v2 16/23] ACPI: remove unused __acpi_handle_debug macro Rasmus Villemoes
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 23+ messages in thread
From: Rasmus Villemoes @ 2018-10-09 11:20 UTC (permalink / raw)
  To: Jason Baron, Andrew Morton; +Cc: linux-kernel, Rasmus Villemoes, linux-acpi

dynamic debug may be implemented via static keys, but ACPI is missing
out on that runtime benefit since it open-codes one possible definition
of DYNAMIC_DEBUG_BRANCH.

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

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index de8d3d3fa651..21e03aa32aae 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -982,7 +982,7 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c
 #define acpi_handle_debug(handle, fmt, ...)				\
 do {									\
 	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
-	if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))		\
+	if (DYNAMIC_DEBUG_BRANCH(descriptor))				\
 		__acpi_handle_debug(&descriptor, handle, pr_fmt(fmt),	\
 				##__VA_ARGS__);				\
 } while (0)
-- 
2.19.1.3.g1d92a00e68

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

* [PATCH v2 16/23] ACPI: remove unused __acpi_handle_debug macro
  2018-10-09 11:19 ` [PATCH v2 00/23] " Rasmus Villemoes
  2018-10-09 11:20   ` [PATCH v2 15/23] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
@ 2018-10-09 11:20   ` Rasmus Villemoes
  2018-10-10  9:38     ` Rafael J. Wysocki
  2018-10-09 11:20   ` [PATCH v2 17/23] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call Rasmus Villemoes
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 23+ messages in thread
From: Rasmus Villemoes @ 2018-10-09 11:20 UTC (permalink / raw)
  To: Jason Baron, Andrew Morton; +Cc: linux-kernel, Rasmus Villemoes, linux-acpi

If CONFIG_DYNAMIC_DEBUG is not set, acpi_handle_debug directly invokes
acpi_handle_printk (if DEBUG) or does a no-printk (if !DEBUG). So this
macro is never used.

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

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 21e03aa32aae..e12d5ef1a054 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -948,9 +948,6 @@ acpi_handle_printk(const char *level, void *handle, const char *fmt, ...) {}
 #if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG)
 __printf(3, 4)
 void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const char *fmt, ...);
-#else
-#define __acpi_handle_debug(descriptor, handle, fmt, ...)		\
-	acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__);
 #endif
 
 /*
-- 
2.19.1.3.g1d92a00e68

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

* [PATCH v2 17/23] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call
  2018-10-09 11:19 ` [PATCH v2 00/23] " Rasmus Villemoes
  2018-10-09 11:20   ` [PATCH v2 15/23] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
  2018-10-09 11:20   ` [PATCH v2 16/23] ACPI: remove unused __acpi_handle_debug macro Rasmus Villemoes
@ 2018-10-09 11:20   ` 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
  4 siblings, 0 replies; 23+ messages in thread
From: Rasmus Villemoes @ 2018-10-09 11:20 UTC (permalink / raw)
  To: Jason Baron, Andrew Morton
  Cc: linux-kernel, Rasmus Villemoes, linux-acpi, Rafael J . Wysocki

With coming changes on x86-64, all dynamic debug descriptors in a
translation unit must have distinct names. The macro _dynamic_func_call
takes care of that. No functional change.

Cc: linux-acpi@vger.kernel.org
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Jason Baron <jbaron@akamai.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/acpi.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index e12d5ef1a054..83bacf9039e9 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -977,12 +977,8 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c
 #else
 #if defined(CONFIG_DYNAMIC_DEBUG)
 #define acpi_handle_debug(handle, fmt, ...)				\
-do {									\
-	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
-	if (DYNAMIC_DEBUG_BRANCH(descriptor))				\
-		__acpi_handle_debug(&descriptor, handle, pr_fmt(fmt),	\
-				##__VA_ARGS__);				\
-} while (0)
+	_dynamic_func_call(fmt, __acpi_handle_debug,			\
+			   handle, pr_fmt(fmt), ##__VA_ARGS__)
 #else
 #define acpi_handle_debug(handle, fmt, ...)				\
 ({									\
-- 
2.19.1.3.g1d92a00e68

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

* Re: [PATCH v2 00/23] various dynamic_debug patches
  2018-10-09 11:19 ` [PATCH v2 00/23] " Rasmus Villemoes
                     ` (2 preceding siblings ...)
  2018-10-09 11:20   ` [PATCH v2 17/23] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call Rasmus Villemoes
@ 2018-10-10  9:37   ` Rafael J. Wysocki
  2018-11-09 23:09   ` [PATCH v3 " Rasmus Villemoes
  4 siblings, 0 replies; 23+ 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] 23+ messages in thread

* Re: [PATCH v2 15/23] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro
  2018-10-09 11:20   ` [PATCH v2 15/23] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
@ 2018-10-10  9:38     ` Rafael J. Wysocki
  0 siblings, 0 replies; 23+ messages in thread
From: Rafael J. Wysocki @ 2018-10-10  9:38 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: jbaron, Andrew Morton, Linux Kernel Mailing List, ACPI Devel Maling List

On Tue, Oct 9, 2018 at 1:21 PM Rasmus Villemoes
<linux@rasmusvillemoes.dk> wrote:
>
> dynamic debug may be implemented via static keys, but ACPI is missing
> out on that runtime benefit since it open-codes one possible definition
> of DYNAMIC_DEBUG_BRANCH.
>
> Cc: linux-acpi@vger.kernel.org
> Acked-by: Jason Baron <jbaron@akamai.com>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  include/linux/acpi.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index de8d3d3fa651..21e03aa32aae 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -982,7 +982,7 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c
>  #define acpi_handle_debug(handle, fmt, ...)                            \
>  do {                                                                   \
>         DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);                 \
> -       if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))          \
> +       if (DYNAMIC_DEBUG_BRANCH(descriptor))                           \
>                 __acpi_handle_debug(&descriptor, handle, pr_fmt(fmt),   \
>                                 ##__VA_ARGS__);                         \
>  } while (0)
> --
> 2.19.1.3.g1d92a00e68
>

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

* Re: [PATCH v2 16/23] ACPI: remove unused __acpi_handle_debug macro
  2018-10-09 11:20   ` [PATCH v2 16/23] ACPI: remove unused __acpi_handle_debug macro Rasmus Villemoes
@ 2018-10-10  9:38     ` Rafael J. Wysocki
  0 siblings, 0 replies; 23+ messages in thread
From: Rafael J. Wysocki @ 2018-10-10  9:38 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: jbaron, Andrew Morton, Linux Kernel Mailing List, ACPI Devel Maling List

On Tue, Oct 9, 2018 at 1:20 PM Rasmus Villemoes
<linux@rasmusvillemoes.dk> wrote:
>
> If CONFIG_DYNAMIC_DEBUG is not set, acpi_handle_debug directly invokes
> acpi_handle_printk (if DEBUG) or does a no-printk (if !DEBUG). So this
> macro is never used.
>
> Cc: linux-acpi@vger.kernel.org
> Acked-by: Jason Baron <jbaron@akamai.com>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  include/linux/acpi.h | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 21e03aa32aae..e12d5ef1a054 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -948,9 +948,6 @@ acpi_handle_printk(const char *level, void *handle, const char *fmt, ...) {}
>  #if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG)
>  __printf(3, 4)
>  void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const char *fmt, ...);
> -#else
> -#define __acpi_handle_debug(descriptor, handle, fmt, ...)              \
> -       acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__);
>  #endif
>
>  /*
> --
> 2.19.1.3.g1d92a00e68
>

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

* [PATCH v3 00/23] various dynamic_debug patches
  2018-10-09 11:19 ` [PATCH v2 00/23] " Rasmus Villemoes
                     ` (3 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 15/23] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
                       ` (3 more replies)
  4 siblings, 4 replies; 23+ 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] 23+ messages in thread

* [PATCH v3 15/23] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro
  2018-11-09 23:09   ` [PATCH v3 " Rasmus Villemoes
@ 2018-11-09 23:10     ` Rasmus Villemoes
  2018-11-09 23:10     ` [PATCH v3 16/23] ACPI: remove unused __acpi_handle_debug macro Rasmus Villemoes
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 23+ messages in thread
From: Rasmus Villemoes @ 2018-11-09 23:10 UTC (permalink / raw)
  To: Andrew Morton, Jason Baron
  Cc: linux-kernel, Rasmus Villemoes, linux-acpi, Rafael J . Wysocki

dynamic debug may be implemented via static keys, but ACPI is missing
out on that runtime benefit since it open-codes one possible definition
of DYNAMIC_DEBUG_BRANCH.

Cc: linux-acpi@vger.kernel.org
Acked-by: Jason Baron <jbaron@akamai.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/acpi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index ed80f147bd50..052e6492ebd7 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -980,7 +980,7 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c
 #define acpi_handle_debug(handle, fmt, ...)				\
 do {									\
 	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
-	if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))		\
+	if (DYNAMIC_DEBUG_BRANCH(descriptor))				\
 		__acpi_handle_debug(&descriptor, handle, pr_fmt(fmt),	\
 				##__VA_ARGS__);				\
 } while (0)
-- 
2.19.1.6.gbde171bbf5

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

* [PATCH v3 16/23] ACPI: remove unused __acpi_handle_debug macro
  2018-11-09 23:09   ` [PATCH v3 " Rasmus Villemoes
  2018-11-09 23:10     ` [PATCH v3 15/23] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
@ 2018-11-09 23:10     ` Rasmus Villemoes
  2018-11-09 23:10     ` [PATCH v3 17/23] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call Rasmus Villemoes
  2019-02-12 21:41     ` [PATCH v4 00/14] various dynamic_debug patches Rasmus Villemoes
  3 siblings, 0 replies; 23+ messages in thread
From: Rasmus Villemoes @ 2018-11-09 23:10 UTC (permalink / raw)
  To: Andrew Morton, Jason Baron
  Cc: linux-kernel, Rasmus Villemoes, linux-acpi, Rafael J . Wysocki

If CONFIG_DYNAMIC_DEBUG is not set, acpi_handle_debug directly invokes
acpi_handle_printk (if DEBUG) or does a no-printk (if !DEBUG). So this
macro is never used.

Cc: linux-acpi@vger.kernel.org
Acked-by: Jason Baron <jbaron@akamai.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/acpi.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 052e6492ebd7..de8633456d71 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -946,9 +946,6 @@ acpi_handle_printk(const char *level, void *handle, const char *fmt, ...) {}
 #if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG)
 __printf(3, 4)
 void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const char *fmt, ...);
-#else
-#define __acpi_handle_debug(descriptor, handle, fmt, ...)		\
-	acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__);
 #endif
 
 /*
-- 
2.19.1.6.gbde171bbf5

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

* [PATCH v3 17/23] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call
  2018-11-09 23:09   ` [PATCH v3 " Rasmus Villemoes
  2018-11-09 23:10     ` [PATCH v3 15/23] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
  2018-11-09 23:10     ` [PATCH v3 16/23] ACPI: remove unused __acpi_handle_debug macro Rasmus Villemoes
@ 2018-11-09 23:10     ` Rasmus Villemoes
  2019-02-12 21:41     ` [PATCH v4 00/14] various dynamic_debug patches Rasmus Villemoes
  3 siblings, 0 replies; 23+ messages in thread
From: Rasmus Villemoes @ 2018-11-09 23:10 UTC (permalink / raw)
  To: Andrew Morton, Jason Baron
  Cc: linux-kernel, Rasmus Villemoes, linux-acpi, Rafael J . Wysocki

With coming changes on x86-64, all dynamic debug descriptors in a
translation unit must have distinct names. The macro _dynamic_func_call
takes care of that. No functional change.

Cc: linux-acpi@vger.kernel.org
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Jason Baron <jbaron@akamai.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/acpi.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index de8633456d71..b284598ae023 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -975,12 +975,8 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c
 #else
 #if defined(CONFIG_DYNAMIC_DEBUG)
 #define acpi_handle_debug(handle, fmt, ...)				\
-do {									\
-	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
-	if (DYNAMIC_DEBUG_BRANCH(descriptor))				\
-		__acpi_handle_debug(&descriptor, handle, pr_fmt(fmt),	\
-				##__VA_ARGS__);				\
-} while (0)
+	_dynamic_func_call(fmt, __acpi_handle_debug,			\
+			   handle, pr_fmt(fmt), ##__VA_ARGS__)
 #else
 #define acpi_handle_debug(handle, fmt, ...)				\
 ({									\
-- 
2.19.1.6.gbde171bbf5

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

* [PATCH v4 00/14] various dynamic_debug patches
  2018-11-09 23:09   ` [PATCH v3 " Rasmus Villemoes
                       ` (2 preceding siblings ...)
  2018-11-09 23:10     ` [PATCH v3 17/23] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call Rasmus Villemoes
@ 2019-02-12 21:41     ` Rasmus Villemoes
  2019-02-12 21:41       ` [PATCH v4 12/14] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
                         ` (2 more replies)
  3 siblings, 3 replies; 23+ 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] 23+ messages in thread

* [PATCH v4 12/14] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro
  2019-02-12 21:41     ` [PATCH v4 00/14] various dynamic_debug patches Rasmus Villemoes
@ 2019-02-12 21:41       ` Rasmus Villemoes
  2019-02-12 21:41       ` [PATCH v4 13/14] ACPI: remove unused __acpi_handle_debug macro Rasmus Villemoes
  2019-02-12 21:41       ` [PATCH v4 14/14] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call Rasmus Villemoes
  2 siblings, 0 replies; 23+ messages in thread
From: Rasmus Villemoes @ 2019-02-12 21:41 UTC (permalink / raw)
  To: Andrew Morton, Jason Baron
  Cc: linux-kernel, Rasmus Villemoes, linux-acpi, Rafael J . Wysocki

dynamic debug may be implemented via static keys, but ACPI is missing
out on that runtime benefit since it open-codes one possible definition
of DYNAMIC_DEBUG_BRANCH.

Cc: linux-acpi@vger.kernel.org
Acked-by: Jason Baron <jbaron@akamai.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/acpi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 87715f20b69a..bcdfbb2bea24 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -987,7 +987,7 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c
 #define acpi_handle_debug(handle, fmt, ...)				\
 do {									\
 	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
-	if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))		\
+	if (DYNAMIC_DEBUG_BRANCH(descriptor))				\
 		__acpi_handle_debug(&descriptor, handle, pr_fmt(fmt),	\
 				##__VA_ARGS__);				\
 } while (0)
-- 
2.20.1

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

* [PATCH v4 13/14] ACPI: remove unused __acpi_handle_debug macro
  2019-02-12 21:41     ` [PATCH v4 00/14] various dynamic_debug patches Rasmus Villemoes
  2019-02-12 21:41       ` [PATCH v4 12/14] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
@ 2019-02-12 21:41       ` Rasmus Villemoes
  2019-02-12 21:41       ` [PATCH v4 14/14] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call Rasmus Villemoes
  2 siblings, 0 replies; 23+ messages in thread
From: Rasmus Villemoes @ 2019-02-12 21:41 UTC (permalink / raw)
  To: Andrew Morton, Jason Baron
  Cc: linux-kernel, Rasmus Villemoes, linux-acpi, Rafael J . Wysocki

If CONFIG_DYNAMIC_DEBUG is not set, acpi_handle_debug directly invokes
acpi_handle_printk (if DEBUG) or does a no-printk (if !DEBUG). So this
macro is never used.

Cc: linux-acpi@vger.kernel.org
Acked-by: Jason Baron <jbaron@akamai.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/acpi.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index bcdfbb2bea24..07b9fa507824 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -953,9 +953,6 @@ acpi_handle_printk(const char *level, void *handle, const char *fmt, ...) {}
 #if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG)
 __printf(3, 4)
 void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const char *fmt, ...);
-#else
-#define __acpi_handle_debug(descriptor, handle, fmt, ...)		\
-	acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__);
 #endif
 
 /*
-- 
2.20.1

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

* [PATCH v4 14/14] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call
  2019-02-12 21:41     ` [PATCH v4 00/14] various dynamic_debug patches Rasmus Villemoes
  2019-02-12 21:41       ` [PATCH v4 12/14] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
  2019-02-12 21:41       ` [PATCH v4 13/14] ACPI: remove unused __acpi_handle_debug macro Rasmus Villemoes
@ 2019-02-12 21:41       ` Rasmus Villemoes
  2 siblings, 0 replies; 23+ messages in thread
From: Rasmus Villemoes @ 2019-02-12 21:41 UTC (permalink / raw)
  To: Andrew Morton, Jason Baron
  Cc: linux-kernel, Rasmus Villemoes, linux-acpi, Rafael J . Wysocki

With coming changes on x86-64, all dynamic debug descriptors in a
translation unit must have distinct names. The macro _dynamic_func_call
takes care of that. No functional change.

Cc: linux-acpi@vger.kernel.org
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Jason Baron <jbaron@akamai.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/acpi.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 07b9fa507824..96c4eaed9439 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -982,12 +982,8 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c
 #else
 #if defined(CONFIG_DYNAMIC_DEBUG)
 #define acpi_handle_debug(handle, fmt, ...)				\
-do {									\
-	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
-	if (DYNAMIC_DEBUG_BRANCH(descriptor))				\
-		__acpi_handle_debug(&descriptor, handle, pr_fmt(fmt),	\
-				##__VA_ARGS__);				\
-} while (0)
+	_dynamic_func_call(fmt, __acpi_handle_debug,			\
+			   handle, pr_fmt(fmt), ##__VA_ARGS__)
 #else
 #define acpi_handle_debug(handle, fmt, ...)				\
 ({									\
-- 
2.20.1

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

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

Thread overview: 23+ 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 15/22] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
2018-09-19 22:04 ` [PATCH 16/22] ACPI: remove unused __acpi_handle_debug macro Rasmus Villemoes
2018-09-19 22:04 ` [PATCH 17/22] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call Rasmus Villemoes
2018-09-20  8:05   ` Rafael J. Wysocki
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:20   ` [PATCH v2 15/23] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
2018-10-10  9:38     ` Rafael J. Wysocki
2018-10-09 11:20   ` [PATCH v2 16/23] ACPI: remove unused __acpi_handle_debug macro Rasmus Villemoes
2018-10-10  9:38     ` Rafael J. Wysocki
2018-10-09 11:20   ` [PATCH v2 17/23] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call 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 15/23] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
2018-11-09 23:10     ` [PATCH v3 16/23] ACPI: remove unused __acpi_handle_debug macro Rasmus Villemoes
2018-11-09 23:10     ` [PATCH v3 17/23] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call Rasmus Villemoes
2019-02-12 21:41     ` [PATCH v4 00/14] various dynamic_debug patches Rasmus Villemoes
2019-02-12 21:41       ` [PATCH v4 12/14] ACPI: use proper DYNAMIC_DEBUG_BRANCH macro Rasmus Villemoes
2019-02-12 21:41       ` [PATCH v4 13/14] ACPI: remove unused __acpi_handle_debug macro Rasmus Villemoes
2019-02-12 21:41       ` [PATCH v4 14/14] ACPI: implement acpi_handle_debug in terms of _dynamic_func_call 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).