All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv4 1/2] mm: move KMEMLEAK's Kconfig items from lib to mm
@ 2023-01-19  1:22 zhaoyang.huang
  2023-01-19  1:22 ` [PATCHv4 2/2] mm: use stack_depot_early_init for kmemleak zhaoyang.huang
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: zhaoyang.huang @ 2023-01-19  1:22 UTC (permalink / raw)
  To: Andrew Morton, Catalin Marinas, Vlastimil Babka,
	Nathan Chancellor, Peter Zijlstra, Zhaoyang Huang, linux-mm,
	linux-kernel, ke.wang, Mirsad Todorovac

From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

Have the kmemleak's source code and Kconfig items be in the same directory.

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
 lib/Kconfig.debug | 70 -------------------------------------------------------
 mm/Kconfig.debug  | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 70 deletions(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 401ad4b..62884ac 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -716,76 +716,6 @@ config SHRINKER_DEBUG
 	  visibility into the kernel memory shrinkers subsystem.
 	  Disable it to avoid an extra memory footprint.
 
-config HAVE_DEBUG_KMEMLEAK
-	bool
-
-config DEBUG_KMEMLEAK
-	bool "Kernel memory leak detector"
-	depends on DEBUG_KERNEL && HAVE_DEBUG_KMEMLEAK
-	select DEBUG_FS
-	select STACKTRACE if STACKTRACE_SUPPORT
-	select KALLSYMS
-	select CRC32
-	select STACKDEPOT
-	help
-	  Say Y here if you want to enable the memory leak
-	  detector. The memory allocation/freeing is traced in a way
-	  similar to the Boehm's conservative garbage collector, the
-	  difference being that the orphan objects are not freed but
-	  only shown in /sys/kernel/debug/kmemleak. Enabling this
-	  feature will introduce an overhead to memory
-	  allocations. See Documentation/dev-tools/kmemleak.rst for more
-	  details.
-
-	  Enabling DEBUG_SLAB or SLUB_DEBUG may increase the chances
-	  of finding leaks due to the slab objects poisoning.
-
-	  In order to access the kmemleak file, debugfs needs to be
-	  mounted (usually at /sys/kernel/debug).
-
-config DEBUG_KMEMLEAK_MEM_POOL_SIZE
-	int "Kmemleak memory pool size"
-	depends on DEBUG_KMEMLEAK
-	range 200 1000000
-	default 16000
-	help
-	  Kmemleak must track all the memory allocations to avoid
-	  reporting false positives. Since memory may be allocated or
-	  freed before kmemleak is fully initialised, use a static pool
-	  of metadata objects to track such callbacks. After kmemleak is
-	  fully initialised, this memory pool acts as an emergency one
-	  if slab allocations fail.
-
-config DEBUG_KMEMLEAK_TEST
-	tristate "Simple test for the kernel memory leak detector"
-	depends on DEBUG_KMEMLEAK && m
-	help
-	  This option enables a module that explicitly leaks memory.
-
-	  If unsure, say N.
-
-config DEBUG_KMEMLEAK_DEFAULT_OFF
-	bool "Default kmemleak to off"
-	depends on DEBUG_KMEMLEAK
-	help
-	  Say Y here to disable kmemleak by default. It can then be enabled
-	  on the command line via kmemleak=on.
-
-config DEBUG_KMEMLEAK_AUTO_SCAN
-	bool "Enable kmemleak auto scan thread on boot up"
-	default y
-	depends on DEBUG_KMEMLEAK
-	help
-	  Depending on the cpu, kmemleak scan may be cpu intensive and can
-	  stall user tasks at times. This option enables/disables automatic
-	  kmemleak scan at boot up.
-
-	  Say N here to disable kmemleak auto scan thread to stop automatic
-	  scanning. Disabling this option disables automatic reporting of
-	  memory leaks.
-
-	  If unsure, say Y.
-
 config DEBUG_STACK_USAGE
 	bool "Stack utilization instrumentation"
 	depends on DEBUG_KERNEL && !IA64
diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug
index ce8dded..d1893ac 100644
--- a/mm/Kconfig.debug
+++ b/mm/Kconfig.debug
@@ -207,3 +207,73 @@ config PTDUMP_DEBUGFS
 	  kernel.
 
 	  If in doubt, say N.
+
+config HAVE_DEBUG_KMEMLEAK
+	bool
+
+config DEBUG_KMEMLEAK
+	bool "Kernel memory leak detector"
+	depends on DEBUG_KERNEL && HAVE_DEBUG_KMEMLEAK
+	select DEBUG_FS
+	select STACKTRACE if STACKTRACE_SUPPORT
+	select KALLSYMS
+	select CRC32
+	select STACKDEPOT
+	help
+	  Say Y here if you want to enable the memory leak
+	  detector. The memory allocation/freeing is traced in a way
+	  similar to the Boehm's conservative garbage collector, the
+	  difference being that the orphan objects are not freed but
+	  only shown in /sys/kernel/debug/kmemleak. Enabling this
+	  feature will introduce an overhead to memory
+	  allocations. See Documentation/dev-tools/kmemleak.rst for more
+	  details.
+
+	  Enabling DEBUG_SLAB or SLUB_DEBUG may increase the chances
+	  of finding leaks due to the slab objects poisoning.
+
+	  In order to access the kmemleak file, debugfs needs to be
+	  mounted (usually at /sys/kernel/debug).
+
+config DEBUG_KMEMLEAK_MEM_POOL_SIZE
+	int "Kmemleak memory pool size"
+	depends on DEBUG_KMEMLEAK
+	range 200 1000000
+	default 16000
+	help
+	  Kmemleak must track all the memory allocations to avoid
+	  reporting false positives. Since memory may be allocated or
+	  freed before kmemleak is fully initialised, use a static pool
+	  of metadata objects to track such callbacks. After kmemleak is
+	  fully initialised, this memory pool acts as an emergency one
+	  if slab allocations fail.
+
+config DEBUG_KMEMLEAK_TEST
+	tristate "Simple test for the kernel memory leak detector"
+	depends on DEBUG_KMEMLEAK && m
+	help
+	  This option enables a module that explicitly leaks memory.
+
+	  If unsure, say N.
+
+config DEBUG_KMEMLEAK_DEFAULT_OFF
+	bool "Default kmemleak to off"
+	depends on DEBUG_KMEMLEAK
+	help
+	  Say Y here to disable kmemleak by default. It can then be enabled
+	  on the command line via kmemleak=on.
+
+config DEBUG_KMEMLEAK_AUTO_SCAN
+	bool "Enable kmemleak auto scan thread on boot up"
+	default y
+	depends on DEBUG_KMEMLEAK
+	help
+	  Depending on the cpu, kmemleak scan may be cpu intensive and can
+	  stall user tasks at times. This option enables/disables automatic
+	  kmemleak scan at boot up.
+
+	  Say N here to disable kmemleak auto scan thread to stop automatic
+	  scanning. Disabling this option disables automatic reporting of
+	  memory leaks.
+
+	  If unsure, say Y.
-- 
1.9.1


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

* [PATCHv4 2/2] mm: use stack_depot_early_init for kmemleak
  2023-01-19  1:22 [PATCHv4 1/2] mm: move KMEMLEAK's Kconfig items from lib to mm zhaoyang.huang
@ 2023-01-19  1:22 ` zhaoyang.huang
  2023-01-19 10:03   ` Mike Rapoport
                     ` (2 more replies)
  2023-01-19 10:04 ` [PATCHv4 1/2] mm: move KMEMLEAK's Kconfig items from lib to mm Mike Rapoport
  2023-01-19 10:16 ` Vlastimil Babka
  2 siblings, 3 replies; 9+ messages in thread
From: zhaoyang.huang @ 2023-01-19  1:22 UTC (permalink / raw)
  To: Andrew Morton, Catalin Marinas, Vlastimil Babka,
	Nathan Chancellor, Peter Zijlstra, Zhaoyang Huang, linux-mm,
	linux-kernel, ke.wang, Mirsad Todorovac

From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

Mirsad report bellow error which caused by stack_depot_init failed in kvcalloc.
Solve this by having stackdepot use stack_depot_early_init.

On 1/4/23 17:08, Mirsad Goran Todorovac wrote:
I hate to bring bad news again, but there seems to be a problem with the output of /sys/kernel/debug/kmemleak:

[root@pc-mtodorov ~]# cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff951c118568b0 (size 16):
comm "kworker/u12:2", pid 56, jiffies 4294893952 (age 4356.548s)
hex dump (first 16 bytes):
    6d 65 6d 73 74 69 63 6b 30 00 00 00 00 00 00 00 memstick0.......
    backtrace:
[root@pc-mtodorov ~]#

Apparently, backtrace of called functions on the stack is no longer printed with the list of memory leaks.
This appeared on Lenovo desktop 10TX000VCR, with AlmaLinux 8.7 and BIOS version M22KT49A (11/10/2022)
and 6.2-rc1 and 6.2-rc2 builds.
This worked on 6.1 with the same CONFIG_KMEMLEAK=y and MGLRU enabled on a vanilla mainstream kernel
from Mr. Torvalds' tree. I don't know if this is deliberate feature for some reason or a bug.
Please find attached the config, lshw and kmemleak output.

reported-by: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr>
suggested-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
v2: use stack_depot_want_early_init instead of CONFIG_STACKDEPOT_ALWAYS_INIT
v3: have the Kconfig changes commited in another patch
v4: select CONFIG_STACKDEPOT_ALWAYS_INIT when DEBUG_KMEMLEAK_DEFAULT_OFF is off
---

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
 mm/Kconfig.debug | 1 +
 mm/kmemleak.c    | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug
index d1893ac..466a37e 100644
--- a/mm/Kconfig.debug
+++ b/mm/Kconfig.debug
@@ -219,6 +219,7 @@ config DEBUG_KMEMLEAK
 	select KALLSYMS
 	select CRC32
 	select STACKDEPOT
+	select STACKDEPOT_ALWAYS_INIT if !DEBUG_KMEMLEAK_DEFAULT_OFF
 	help
 	  Say Y here if you want to enable the memory leak
 	  detector. The memory allocation/freeing is traced in a way
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 762b91f..ddc1ddf 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -2070,8 +2070,10 @@ static int __init kmemleak_boot_config(char *str)
 		return -EINVAL;
 	if (strcmp(str, "off") == 0)
 		kmemleak_disable();
-	else if (strcmp(str, "on") == 0)
+	else if (strcmp(str, "on") == 0) {
 		kmemleak_skip_disable = 1;
+		stack_depot_want_early_init();
+	}
 	else
 		return -EINVAL;
 	return 0;
-- 
1.9.1


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

* Re: [PATCHv4 2/2] mm: use stack_depot_early_init for kmemleak
  2023-01-19  1:22 ` [PATCHv4 2/2] mm: use stack_depot_early_init for kmemleak zhaoyang.huang
@ 2023-01-19 10:03   ` Mike Rapoport
  2023-01-19 10:13   ` Catalin Marinas
  2023-01-19 10:32   ` Vlastimil Babka
  2 siblings, 0 replies; 9+ messages in thread
From: Mike Rapoport @ 2023-01-19 10:03 UTC (permalink / raw)
  To: zhaoyang.huang
  Cc: Andrew Morton, Catalin Marinas, Vlastimil Babka,
	Nathan Chancellor, Peter Zijlstra, Zhaoyang Huang, linux-mm,
	linux-kernel, ke.wang, Mirsad Todorovac

On Thu, Jan 19, 2023 at 09:22:25AM +0800, zhaoyang.huang wrote:
> From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> 
> Mirsad report bellow error which caused by stack_depot_init failed in kvcalloc.
> Solve this by having stackdepot use stack_depot_early_init.
> 
> On 1/4/23 17:08, Mirsad Goran Todorovac wrote:
> I hate to bring bad news again, but there seems to be a problem with the output of /sys/kernel/debug/kmemleak:
> 
> [root@pc-mtodorov ~]# cat /sys/kernel/debug/kmemleak
> unreferenced object 0xffff951c118568b0 (size 16):
> comm "kworker/u12:2", pid 56, jiffies 4294893952 (age 4356.548s)
> hex dump (first 16 bytes):
>     6d 65 6d 73 74 69 63 6b 30 00 00 00 00 00 00 00 memstick0.......
>     backtrace:
> [root@pc-mtodorov ~]#
> 
> Apparently, backtrace of called functions on the stack is no longer printed with the list of memory leaks.
> This appeared on Lenovo desktop 10TX000VCR, with AlmaLinux 8.7 and BIOS version M22KT49A (11/10/2022)
> and 6.2-rc1 and 6.2-rc2 builds.
> This worked on 6.1 with the same CONFIG_KMEMLEAK=y and MGLRU enabled on a vanilla mainstream kernel
> from Mr. Torvalds' tree. I don't know if this is deliberate feature for some reason or a bug.
> Please find attached the config, lshw and kmemleak output.
> 
> reported-by: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr>
> suggested-by: Vlastimil Babka <vbabka@suse.cz>
> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

Acked-by: Mike Rapoport (IBM) <rppt@kernel.org>

> ---
> v2: use stack_depot_want_early_init instead of CONFIG_STACKDEPOT_ALWAYS_INIT
> v3: have the Kconfig changes commited in another patch
> v4: select CONFIG_STACKDEPOT_ALWAYS_INIT when DEBUG_KMEMLEAK_DEFAULT_OFF is off
> ---
> 
> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> ---
>  mm/Kconfig.debug | 1 +
>  mm/kmemleak.c    | 4 +++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug
> index d1893ac..466a37e 100644
> --- a/mm/Kconfig.debug
> +++ b/mm/Kconfig.debug
> @@ -219,6 +219,7 @@ config DEBUG_KMEMLEAK
>  	select KALLSYMS
>  	select CRC32
>  	select STACKDEPOT
> +	select STACKDEPOT_ALWAYS_INIT if !DEBUG_KMEMLEAK_DEFAULT_OFF
>  	help
>  	  Say Y here if you want to enable the memory leak
>  	  detector. The memory allocation/freeing is traced in a way
> diff --git a/mm/kmemleak.c b/mm/kmemleak.c
> index 762b91f..ddc1ddf 100644
> --- a/mm/kmemleak.c
> +++ b/mm/kmemleak.c
> @@ -2070,8 +2070,10 @@ static int __init kmemleak_boot_config(char *str)
>  		return -EINVAL;
>  	if (strcmp(str, "off") == 0)
>  		kmemleak_disable();
> -	else if (strcmp(str, "on") == 0)
> +	else if (strcmp(str, "on") == 0) {
>  		kmemleak_skip_disable = 1;
> +		stack_depot_want_early_init();
> +	}
>  	else
>  		return -EINVAL;
>  	return 0;
> -- 
> 1.9.1
> 
> 

-- 
Sincerely yours,
Mike.

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

* Re: [PATCHv4 1/2] mm: move KMEMLEAK's Kconfig items from lib to mm
  2023-01-19  1:22 [PATCHv4 1/2] mm: move KMEMLEAK's Kconfig items from lib to mm zhaoyang.huang
  2023-01-19  1:22 ` [PATCHv4 2/2] mm: use stack_depot_early_init for kmemleak zhaoyang.huang
@ 2023-01-19 10:04 ` Mike Rapoport
  2023-01-19 10:16 ` Vlastimil Babka
  2 siblings, 0 replies; 9+ messages in thread
From: Mike Rapoport @ 2023-01-19 10:04 UTC (permalink / raw)
  To: zhaoyang.huang
  Cc: Andrew Morton, Catalin Marinas, Vlastimil Babka,
	Nathan Chancellor, Peter Zijlstra, Zhaoyang Huang, linux-mm,
	linux-kernel, ke.wang, Mirsad Todorovac

On Thu, Jan 19, 2023 at 09:22:24AM +0800, zhaoyang.huang wrote:
> From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> 
> Have the kmemleak's source code and Kconfig items be in the same directory.
> 
> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

Acked-by: Mike Rapoport (IBM) <rppt@kernel.org>

> ---
>  lib/Kconfig.debug | 70 -------------------------------------------------------
>  mm/Kconfig.debug  | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 70 insertions(+), 70 deletions(-)
> 
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index 401ad4b..62884ac 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -716,76 +716,6 @@ config SHRINKER_DEBUG
>  	  visibility into the kernel memory shrinkers subsystem.
>  	  Disable it to avoid an extra memory footprint.
>  
> -config HAVE_DEBUG_KMEMLEAK
> -	bool
> -
> -config DEBUG_KMEMLEAK
> -	bool "Kernel memory leak detector"
> -	depends on DEBUG_KERNEL && HAVE_DEBUG_KMEMLEAK
> -	select DEBUG_FS
> -	select STACKTRACE if STACKTRACE_SUPPORT
> -	select KALLSYMS
> -	select CRC32
> -	select STACKDEPOT
> -	help
> -	  Say Y here if you want to enable the memory leak
> -	  detector. The memory allocation/freeing is traced in a way
> -	  similar to the Boehm's conservative garbage collector, the
> -	  difference being that the orphan objects are not freed but
> -	  only shown in /sys/kernel/debug/kmemleak. Enabling this
> -	  feature will introduce an overhead to memory
> -	  allocations. See Documentation/dev-tools/kmemleak.rst for more
> -	  details.
> -
> -	  Enabling DEBUG_SLAB or SLUB_DEBUG may increase the chances
> -	  of finding leaks due to the slab objects poisoning.
> -
> -	  In order to access the kmemleak file, debugfs needs to be
> -	  mounted (usually at /sys/kernel/debug).
> -
> -config DEBUG_KMEMLEAK_MEM_POOL_SIZE
> -	int "Kmemleak memory pool size"
> -	depends on DEBUG_KMEMLEAK
> -	range 200 1000000
> -	default 16000
> -	help
> -	  Kmemleak must track all the memory allocations to avoid
> -	  reporting false positives. Since memory may be allocated or
> -	  freed before kmemleak is fully initialised, use a static pool
> -	  of metadata objects to track such callbacks. After kmemleak is
> -	  fully initialised, this memory pool acts as an emergency one
> -	  if slab allocations fail.
> -
> -config DEBUG_KMEMLEAK_TEST
> -	tristate "Simple test for the kernel memory leak detector"
> -	depends on DEBUG_KMEMLEAK && m
> -	help
> -	  This option enables a module that explicitly leaks memory.
> -
> -	  If unsure, say N.
> -
> -config DEBUG_KMEMLEAK_DEFAULT_OFF
> -	bool "Default kmemleak to off"
> -	depends on DEBUG_KMEMLEAK
> -	help
> -	  Say Y here to disable kmemleak by default. It can then be enabled
> -	  on the command line via kmemleak=on.
> -
> -config DEBUG_KMEMLEAK_AUTO_SCAN
> -	bool "Enable kmemleak auto scan thread on boot up"
> -	default y
> -	depends on DEBUG_KMEMLEAK
> -	help
> -	  Depending on the cpu, kmemleak scan may be cpu intensive and can
> -	  stall user tasks at times. This option enables/disables automatic
> -	  kmemleak scan at boot up.
> -
> -	  Say N here to disable kmemleak auto scan thread to stop automatic
> -	  scanning. Disabling this option disables automatic reporting of
> -	  memory leaks.
> -
> -	  If unsure, say Y.
> -
>  config DEBUG_STACK_USAGE
>  	bool "Stack utilization instrumentation"
>  	depends on DEBUG_KERNEL && !IA64
> diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug
> index ce8dded..d1893ac 100644
> --- a/mm/Kconfig.debug
> +++ b/mm/Kconfig.debug
> @@ -207,3 +207,73 @@ config PTDUMP_DEBUGFS
>  	  kernel.
>  
>  	  If in doubt, say N.
> +
> +config HAVE_DEBUG_KMEMLEAK
> +	bool
> +
> +config DEBUG_KMEMLEAK
> +	bool "Kernel memory leak detector"
> +	depends on DEBUG_KERNEL && HAVE_DEBUG_KMEMLEAK
> +	select DEBUG_FS
> +	select STACKTRACE if STACKTRACE_SUPPORT
> +	select KALLSYMS
> +	select CRC32
> +	select STACKDEPOT
> +	help
> +	  Say Y here if you want to enable the memory leak
> +	  detector. The memory allocation/freeing is traced in a way
> +	  similar to the Boehm's conservative garbage collector, the
> +	  difference being that the orphan objects are not freed but
> +	  only shown in /sys/kernel/debug/kmemleak. Enabling this
> +	  feature will introduce an overhead to memory
> +	  allocations. See Documentation/dev-tools/kmemleak.rst for more
> +	  details.
> +
> +	  Enabling DEBUG_SLAB or SLUB_DEBUG may increase the chances
> +	  of finding leaks due to the slab objects poisoning.
> +
> +	  In order to access the kmemleak file, debugfs needs to be
> +	  mounted (usually at /sys/kernel/debug).
> +
> +config DEBUG_KMEMLEAK_MEM_POOL_SIZE
> +	int "Kmemleak memory pool size"
> +	depends on DEBUG_KMEMLEAK
> +	range 200 1000000
> +	default 16000
> +	help
> +	  Kmemleak must track all the memory allocations to avoid
> +	  reporting false positives. Since memory may be allocated or
> +	  freed before kmemleak is fully initialised, use a static pool
> +	  of metadata objects to track such callbacks. After kmemleak is
> +	  fully initialised, this memory pool acts as an emergency one
> +	  if slab allocations fail.
> +
> +config DEBUG_KMEMLEAK_TEST
> +	tristate "Simple test for the kernel memory leak detector"
> +	depends on DEBUG_KMEMLEAK && m
> +	help
> +	  This option enables a module that explicitly leaks memory.
> +
> +	  If unsure, say N.
> +
> +config DEBUG_KMEMLEAK_DEFAULT_OFF
> +	bool "Default kmemleak to off"
> +	depends on DEBUG_KMEMLEAK
> +	help
> +	  Say Y here to disable kmemleak by default. It can then be enabled
> +	  on the command line via kmemleak=on.
> +
> +config DEBUG_KMEMLEAK_AUTO_SCAN
> +	bool "Enable kmemleak auto scan thread on boot up"
> +	default y
> +	depends on DEBUG_KMEMLEAK
> +	help
> +	  Depending on the cpu, kmemleak scan may be cpu intensive and can
> +	  stall user tasks at times. This option enables/disables automatic
> +	  kmemleak scan at boot up.
> +
> +	  Say N here to disable kmemleak auto scan thread to stop automatic
> +	  scanning. Disabling this option disables automatic reporting of
> +	  memory leaks.
> +
> +	  If unsure, say Y.
> -- 
> 1.9.1
> 
> 

-- 
Sincerely yours,
Mike.

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

* Re: [PATCHv4 2/2] mm: use stack_depot_early_init for kmemleak
  2023-01-19  1:22 ` [PATCHv4 2/2] mm: use stack_depot_early_init for kmemleak zhaoyang.huang
  2023-01-19 10:03   ` Mike Rapoport
@ 2023-01-19 10:13   ` Catalin Marinas
  2023-01-19 10:32   ` Vlastimil Babka
  2 siblings, 0 replies; 9+ messages in thread
From: Catalin Marinas @ 2023-01-19 10:13 UTC (permalink / raw)
  To: zhaoyang.huang
  Cc: Andrew Morton, Vlastimil Babka, Nathan Chancellor,
	Peter Zijlstra, Zhaoyang Huang, linux-mm, linux-kernel, ke.wang,
	Mirsad Todorovac

On Thu, Jan 19, 2023 at 09:22:25AM +0800, zhaoyang.huang wrote:
> From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> 
> Mirsad report bellow error which caused by stack_depot_init failed in kvcalloc.
> Solve this by having stackdepot use stack_depot_early_init.
> 
> On 1/4/23 17:08, Mirsad Goran Todorovac wrote:
> I hate to bring bad news again, but there seems to be a problem with the output of /sys/kernel/debug/kmemleak:
> 
> [root@pc-mtodorov ~]# cat /sys/kernel/debug/kmemleak
> unreferenced object 0xffff951c118568b0 (size 16):
> comm "kworker/u12:2", pid 56, jiffies 4294893952 (age 4356.548s)
> hex dump (first 16 bytes):
>     6d 65 6d 73 74 69 63 6b 30 00 00 00 00 00 00 00 memstick0.......
>     backtrace:
> [root@pc-mtodorov ~]#
> 
> Apparently, backtrace of called functions on the stack is no longer printed with the list of memory leaks.
> This appeared on Lenovo desktop 10TX000VCR, with AlmaLinux 8.7 and BIOS version M22KT49A (11/10/2022)
> and 6.2-rc1 and 6.2-rc2 builds.
> This worked on 6.1 with the same CONFIG_KMEMLEAK=y and MGLRU enabled on a vanilla mainstream kernel
> from Mr. Torvalds' tree. I don't know if this is deliberate feature for some reason or a bug.
> Please find attached the config, lshw and kmemleak output.
> 
> reported-by: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr>
> suggested-by: Vlastimil Babka <vbabka@suse.cz>
> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

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

* Re: [PATCHv4 1/2] mm: move KMEMLEAK's Kconfig items from lib to mm
  2023-01-19  1:22 [PATCHv4 1/2] mm: move KMEMLEAK's Kconfig items from lib to mm zhaoyang.huang
  2023-01-19  1:22 ` [PATCHv4 2/2] mm: use stack_depot_early_init for kmemleak zhaoyang.huang
  2023-01-19 10:04 ` [PATCHv4 1/2] mm: move KMEMLEAK's Kconfig items from lib to mm Mike Rapoport
@ 2023-01-19 10:16 ` Vlastimil Babka
  2 siblings, 0 replies; 9+ messages in thread
From: Vlastimil Babka @ 2023-01-19 10:16 UTC (permalink / raw)
  To: zhaoyang.huang, Andrew Morton, Catalin Marinas,
	Nathan Chancellor, Peter Zijlstra, Zhaoyang Huang, linux-mm,
	linux-kernel, ke.wang, Mirsad Todorovac

On 1/19/23 02:22, zhaoyang.huang wrote:
> From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> 
> Have the kmemleak's source code and Kconfig items be in the same directory.
> 
> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>


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

* Re: [PATCHv4 2/2] mm: use stack_depot_early_init for kmemleak
  2023-01-19  1:22 ` [PATCHv4 2/2] mm: use stack_depot_early_init for kmemleak zhaoyang.huang
  2023-01-19 10:03   ` Mike Rapoport
  2023-01-19 10:13   ` Catalin Marinas
@ 2023-01-19 10:32   ` Vlastimil Babka
  2023-01-19 22:42     ` Andrew Morton
  2 siblings, 1 reply; 9+ messages in thread
From: Vlastimil Babka @ 2023-01-19 10:32 UTC (permalink / raw)
  To: zhaoyang.huang, Andrew Morton, Catalin Marinas,
	Nathan Chancellor, Peter Zijlstra, Zhaoyang Huang, linux-mm,
	linux-kernel, ke.wang, Mirsad Todorovac

On 1/19/23 02:22, zhaoyang.huang wrote:
> From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> 
> Mirsad report bellow error which caused by stack_depot_init failed in kvcalloc.
> Solve this by having stackdepot use stack_depot_early_init.
> 
> On 1/4/23 17:08, Mirsad Goran Todorovac wrote:
> I hate to bring bad news again, but there seems to be a problem with the output of /sys/kernel/debug/kmemleak:
> 
> [root@pc-mtodorov ~]# cat /sys/kernel/debug/kmemleak
> unreferenced object 0xffff951c118568b0 (size 16):
> comm "kworker/u12:2", pid 56, jiffies 4294893952 (age 4356.548s)
> hex dump (first 16 bytes):
>     6d 65 6d 73 74 69 63 6b 30 00 00 00 00 00 00 00 memstick0.......
>     backtrace:
> [root@pc-mtodorov ~]#
> 
> Apparently, backtrace of called functions on the stack is no longer printed with the list of memory leaks.
> This appeared on Lenovo desktop 10TX000VCR, with AlmaLinux 8.7 and BIOS version M22KT49A (11/10/2022)
> and 6.2-rc1 and 6.2-rc2 builds.
> This worked on 6.1 with the same CONFIG_KMEMLEAK=y and MGLRU enabled on a vanilla mainstream kernel
> from Mr. Torvalds' tree. I don't know if this is deliberate feature for some reason or a bug.
> Please find attached the config, lshw and kmemleak output.

I think we could replace the full quote of the report with

Link: https://lore.kernel.org/all/5272a819-ef74-65ff-be61-4d2d567337de@alu.unizg.hr/

also

Fixes: 56a61617dd22 ("mm: use stack_depot for recording kmemleak's backtrace")

(Andrew can do that when picking up, no need to send v5)

> reported-by: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr>
> suggested-by: Vlastimil Babka <vbabka@suse.cz>
> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

But to be cleaner I'd also suggest Andrew adds the hunk below. The call
to stack_depot_init() becomes no-op after this patch so it's not a bug
to leave it there, but it's just misleading now.

---8<---
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 91dda5c2753a..55dc8b8b0616 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -2095,7 +2095,6 @@ void __init kmemleak_init(void)
 	if (kmemleak_error)
 		return;
 
-	stack_depot_init();
 	jiffies_min_age = msecs_to_jiffies(MSECS_MIN_AGE);
 	jiffies_scan_wait = msecs_to_jiffies(SECS_SCAN_WAIT * 1000);
 


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

* Re: [PATCHv4 2/2] mm: use stack_depot_early_init for kmemleak
  2023-01-19 10:32   ` Vlastimil Babka
@ 2023-01-19 22:42     ` Andrew Morton
  2023-01-20 12:52       ` Vlastimil Babka
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2023-01-19 22:42 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: zhaoyang.huang, Catalin Marinas, Nathan Chancellor,
	Peter Zijlstra, Zhaoyang Huang, linux-mm, linux-kernel, ke.wang,
	Mirsad Todorovac

On Thu, 19 Jan 2023 11:32:36 +0100 Vlastimil Babka <vbabka@suse.cz> wrote:

> But to be cleaner I'd also suggest Andrew adds the hunk below. The call
> to stack_depot_init() becomes no-op after this patch so it's not a bug
> to leave it there, but it's just misleading now.
> 
> ---8<---
> diff --git a/mm/kmemleak.c b/mm/kmemleak.c
> index 91dda5c2753a..55dc8b8b0616 100644
> --- a/mm/kmemleak.c
> +++ b/mm/kmemleak.c
> @@ -2095,7 +2095,6 @@ void __init kmemleak_init(void)
>  	if (kmemleak_error)
>  		return;
>  
> -	stack_depot_init();
>  	jiffies_min_age = msecs_to_jiffies(MSECS_MIN_AGE);
>  	jiffies_scan_wait = msecs_to_jiffies(SECS_SCAN_WAIT * 1000);
>  

I added your signoff to this.

I used not to bother for such minor to-be-folded fixups, but now
Stephen sends me automated nags when his scripts detect this.

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

* Re: [PATCHv4 2/2] mm: use stack_depot_early_init for kmemleak
  2023-01-19 22:42     ` Andrew Morton
@ 2023-01-20 12:52       ` Vlastimil Babka
  0 siblings, 0 replies; 9+ messages in thread
From: Vlastimil Babka @ 2023-01-20 12:52 UTC (permalink / raw)
  To: Andrew Morton
  Cc: zhaoyang.huang, Catalin Marinas, Nathan Chancellor,
	Peter Zijlstra, Zhaoyang Huang, linux-mm, linux-kernel, ke.wang,
	Mirsad Todorovac

On 1/19/23 23:42, Andrew Morton wrote:
> On Thu, 19 Jan 2023 11:32:36 +0100 Vlastimil Babka <vbabka@suse.cz> wrote:
> 
>> But to be cleaner I'd also suggest Andrew adds the hunk below. The call
>> to stack_depot_init() becomes no-op after this patch so it's not a bug
>> to leave it there, but it's just misleading now.
>>
>> ---8<---
>> diff --git a/mm/kmemleak.c b/mm/kmemleak.c
>> index 91dda5c2753a..55dc8b8b0616 100644
>> --- a/mm/kmemleak.c
>> +++ b/mm/kmemleak.c
>> @@ -2095,7 +2095,6 @@ void __init kmemleak_init(void)
>>   	if (kmemleak_error)
>>   		return;
>>   
>> -	stack_depot_init();
>>   	jiffies_min_age = msecs_to_jiffies(MSECS_MIN_AGE);
>>   	jiffies_scan_wait = msecs_to_jiffies(SECS_SCAN_WAIT * 1000);
>>   
> 
> I added your signoff to this.

Fine with me, thanks.

> I used not to bother for such minor to-be-folded fixups, but now
> Stephen sends me automated nags when his scripts detect this.

Ack, will try to remember that next time.

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

end of thread, other threads:[~2023-01-20 12:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-19  1:22 [PATCHv4 1/2] mm: move KMEMLEAK's Kconfig items from lib to mm zhaoyang.huang
2023-01-19  1:22 ` [PATCHv4 2/2] mm: use stack_depot_early_init for kmemleak zhaoyang.huang
2023-01-19 10:03   ` Mike Rapoport
2023-01-19 10:13   ` Catalin Marinas
2023-01-19 10:32   ` Vlastimil Babka
2023-01-19 22:42     ` Andrew Morton
2023-01-20 12:52       ` Vlastimil Babka
2023-01-19 10:04 ` [PATCHv4 1/2] mm: move KMEMLEAK's Kconfig items from lib to mm Mike Rapoport
2023-01-19 10:16 ` Vlastimil Babka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.