All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lockdep: Correct lock_classes index mapping
@ 2022-02-10 10:50 ` Cheng Jui Wang
  0 siblings, 0 replies; 10+ messages in thread
From: Cheng Jui Wang @ 2022-02-10 10:50 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar
  Cc: Will Deacon, Waiman Long, Boqun Feng, Matthias Brugger,
	linux-kernel, linux-arm-kernel, linux-mediatek, stable,
	wsd_upstream, Eason-YH Lin, Kobe-CP Wu, Jeff-CC Hsu,
	Cheng Jui Wang

A kernel exception was hit when trying to dump /proc/lockdep_chains after
lockdep report "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!":

Unable to handle kernel paging request at virtual address 00054005450e05c3
...
00054005450e05c3] address between user and kernel address ranges
...
pc : [0xffffffece769b3a8] string+0x50/0x10c
lr : [0xffffffece769ac88] vsnprintf+0x468/0x69c
...
 Call trace:
  string+0x50/0x10c
  vsnprintf+0x468/0x69c
  seq_printf+0x8c/0xd8
  print_name+0x64/0xf4
  lc_show+0xb8/0x128
  seq_read_iter+0x3cc/0x5fc
  proc_reg_read_iter+0xdc/0x1d4

The cause of the problem is the function lock_chain_get_class() will
shift lock_classes index by 1, but the index don't need to be shifted
anymore since commit 01bb6f0af992 ("locking/lockdep: Change the range of
class_idx in held_lock struct") already change the index to start from
0.

The lock_classes[-1] located at chain_hlocks array. When printing
lock_classes[-1] after the chain_hlocks entries are modified, the
exception happened.

The output of lockdep_chains are incorrect due to this problem too.

Fixes: f611e8cf98ec ("lockdep: Take read/write status in consideration when generate chainkey")

Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
---
 kernel/locking/lockdep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 4a882f83aeb9..f8a0212189ca 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3462,7 +3462,7 @@ struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i)
 	u16 chain_hlock = chain_hlocks[chain->base + i];
 	unsigned int class_idx = chain_hlock_class_idx(chain_hlock);
 
-	return lock_classes + class_idx - 1;
+	return lock_classes + class_idx;
 }
 
 /*
@@ -3530,7 +3530,7 @@ static void print_chain_keys_chain(struct lock_chain *chain)
 		hlock_id = chain_hlocks[chain->base + i];
 		chain_key = print_chain_key_iteration(hlock_id, chain_key);
 
-		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id) - 1);
+		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id));
 		printk("\n");
 	}
 }
-- 
2.18.0


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

* [PATCH] lockdep: Correct lock_classes index mapping
@ 2022-02-10 10:50 ` Cheng Jui Wang
  0 siblings, 0 replies; 10+ messages in thread
From: Cheng Jui Wang @ 2022-02-10 10:50 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar
  Cc: Will Deacon, Waiman Long, Boqun Feng, Matthias Brugger,
	linux-kernel, linux-arm-kernel, linux-mediatek, stable,
	wsd_upstream, Eason-YH Lin, Kobe-CP Wu, Jeff-CC Hsu,
	Cheng Jui Wang

A kernel exception was hit when trying to dump /proc/lockdep_chains after
lockdep report "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!":

Unable to handle kernel paging request at virtual address 00054005450e05c3
...
00054005450e05c3] address between user and kernel address ranges
...
pc : [0xffffffece769b3a8] string+0x50/0x10c
lr : [0xffffffece769ac88] vsnprintf+0x468/0x69c
...
 Call trace:
  string+0x50/0x10c
  vsnprintf+0x468/0x69c
  seq_printf+0x8c/0xd8
  print_name+0x64/0xf4
  lc_show+0xb8/0x128
  seq_read_iter+0x3cc/0x5fc
  proc_reg_read_iter+0xdc/0x1d4

The cause of the problem is the function lock_chain_get_class() will
shift lock_classes index by 1, but the index don't need to be shifted
anymore since commit 01bb6f0af992 ("locking/lockdep: Change the range of
class_idx in held_lock struct") already change the index to start from
0.

The lock_classes[-1] located at chain_hlocks array. When printing
lock_classes[-1] after the chain_hlocks entries are modified, the
exception happened.

The output of lockdep_chains are incorrect due to this problem too.

Fixes: f611e8cf98ec ("lockdep: Take read/write status in consideration when generate chainkey")

Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
---
 kernel/locking/lockdep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 4a882f83aeb9..f8a0212189ca 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3462,7 +3462,7 @@ struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i)
 	u16 chain_hlock = chain_hlocks[chain->base + i];
 	unsigned int class_idx = chain_hlock_class_idx(chain_hlock);
 
-	return lock_classes + class_idx - 1;
+	return lock_classes + class_idx;
 }
 
 /*
@@ -3530,7 +3530,7 @@ static void print_chain_keys_chain(struct lock_chain *chain)
 		hlock_id = chain_hlocks[chain->base + i];
 		chain_key = print_chain_key_iteration(hlock_id, chain_key);
 
-		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id) - 1);
+		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id));
 		printk("\n");
 	}
 }
-- 
2.18.0


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH] lockdep: Correct lock_classes index mapping
@ 2022-02-10 10:50 ` Cheng Jui Wang
  0 siblings, 0 replies; 10+ messages in thread
From: Cheng Jui Wang @ 2022-02-10 10:50 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar
  Cc: Will Deacon, Waiman Long, Boqun Feng, Matthias Brugger,
	linux-kernel, linux-arm-kernel, linux-mediatek, stable,
	wsd_upstream, Eason-YH Lin, Kobe-CP Wu, Jeff-CC Hsu,
	Cheng Jui Wang

A kernel exception was hit when trying to dump /proc/lockdep_chains after
lockdep report "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!":

Unable to handle kernel paging request at virtual address 00054005450e05c3
...
00054005450e05c3] address between user and kernel address ranges
...
pc : [0xffffffece769b3a8] string+0x50/0x10c
lr : [0xffffffece769ac88] vsnprintf+0x468/0x69c
...
 Call trace:
  string+0x50/0x10c
  vsnprintf+0x468/0x69c
  seq_printf+0x8c/0xd8
  print_name+0x64/0xf4
  lc_show+0xb8/0x128
  seq_read_iter+0x3cc/0x5fc
  proc_reg_read_iter+0xdc/0x1d4

The cause of the problem is the function lock_chain_get_class() will
shift lock_classes index by 1, but the index don't need to be shifted
anymore since commit 01bb6f0af992 ("locking/lockdep: Change the range of
class_idx in held_lock struct") already change the index to start from
0.

The lock_classes[-1] located at chain_hlocks array. When printing
lock_classes[-1] after the chain_hlocks entries are modified, the
exception happened.

The output of lockdep_chains are incorrect due to this problem too.

Fixes: f611e8cf98ec ("lockdep: Take read/write status in consideration when generate chainkey")

Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
---
 kernel/locking/lockdep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 4a882f83aeb9..f8a0212189ca 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3462,7 +3462,7 @@ struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i)
 	u16 chain_hlock = chain_hlocks[chain->base + i];
 	unsigned int class_idx = chain_hlock_class_idx(chain_hlock);
 
-	return lock_classes + class_idx - 1;
+	return lock_classes + class_idx;
 }
 
 /*
@@ -3530,7 +3530,7 @@ static void print_chain_keys_chain(struct lock_chain *chain)
 		hlock_id = chain_hlocks[chain->base + i];
 		chain_key = print_chain_key_iteration(hlock_id, chain_key);
 
-		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id) - 1);
+		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id));
 		printk("\n");
 	}
 }
-- 
2.18.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] lockdep: Correct lock_classes index mapping
  2022-02-10 10:50 ` Cheng Jui Wang
  (?)
@ 2022-02-10 12:45   ` Boqun Feng
  -1 siblings, 0 replies; 10+ messages in thread
From: Boqun Feng @ 2022-02-10 12:45 UTC (permalink / raw)
  To: Cheng Jui Wang
  Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Waiman Long,
	Matthias Brugger, linux-kernel, linux-arm-kernel, linux-mediatek,
	stable, wsd_upstream, Eason-YH Lin, Kobe-CP Wu, Jeff-CC Hsu

[-- Attachment #1: Type: text/plain, Size: 2584 bytes --]

On Thu, Feb 10, 2022 at 06:50:11PM +0800, Cheng Jui Wang wrote:
> A kernel exception was hit when trying to dump /proc/lockdep_chains after
> lockdep report "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!":
> 
> Unable to handle kernel paging request at virtual address 00054005450e05c3
> ...
> 00054005450e05c3] address between user and kernel address ranges
> ...
> pc : [0xffffffece769b3a8] string+0x50/0x10c
> lr : [0xffffffece769ac88] vsnprintf+0x468/0x69c
> ...
>  Call trace:
>   string+0x50/0x10c
>   vsnprintf+0x468/0x69c
>   seq_printf+0x8c/0xd8
>   print_name+0x64/0xf4
>   lc_show+0xb8/0x128
>   seq_read_iter+0x3cc/0x5fc
>   proc_reg_read_iter+0xdc/0x1d4
> 
> The cause of the problem is the function lock_chain_get_class() will
> shift lock_classes index by 1, but the index don't need to be shifted
> anymore since commit 01bb6f0af992 ("locking/lockdep: Change the range of
> class_idx in held_lock struct") already change the index to start from
> 0.
> 
> The lock_classes[-1] located at chain_hlocks array. When printing
> lock_classes[-1] after the chain_hlocks entries are modified, the
> exception happened.
> 
> The output of lockdep_chains are incorrect due to this problem too.
> 
> Fixes: f611e8cf98ec ("lockdep: Take read/write status in consideration when generate chainkey")
> 
> Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>

Hmm.. this means that the /proc/lockdep_chains has been incorrect since
commit f611e8cf89ec..

Nice catch!

Reviewed-by: Boqun Feng <boqun.feng@gmail.com>

Regards,
Boqun

> ---
>  kernel/locking/lockdep.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 4a882f83aeb9..f8a0212189ca 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -3462,7 +3462,7 @@ struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i)
>  	u16 chain_hlock = chain_hlocks[chain->base + i];
>  	unsigned int class_idx = chain_hlock_class_idx(chain_hlock);
>  
> -	return lock_classes + class_idx - 1;
> +	return lock_classes + class_idx;
>  }
>  
>  /*
> @@ -3530,7 +3530,7 @@ static void print_chain_keys_chain(struct lock_chain *chain)
>  		hlock_id = chain_hlocks[chain->base + i];
>  		chain_key = print_chain_key_iteration(hlock_id, chain_key);
>  
> -		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id) - 1);
> +		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id));
>  		printk("\n");
>  	}
>  }
> -- 
> 2.18.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] lockdep: Correct lock_classes index mapping
@ 2022-02-10 12:45   ` Boqun Feng
  0 siblings, 0 replies; 10+ messages in thread
From: Boqun Feng @ 2022-02-10 12:45 UTC (permalink / raw)
  To: Cheng Jui Wang
  Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Waiman Long,
	Matthias Brugger, linux-kernel, linux-arm-kernel, linux-mediatek,
	stable, wsd_upstream, Eason-YH Lin, Kobe-CP Wu, Jeff-CC Hsu


[-- Attachment #1.1: Type: text/plain, Size: 2584 bytes --]

On Thu, Feb 10, 2022 at 06:50:11PM +0800, Cheng Jui Wang wrote:
> A kernel exception was hit when trying to dump /proc/lockdep_chains after
> lockdep report "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!":
> 
> Unable to handle kernel paging request at virtual address 00054005450e05c3
> ...
> 00054005450e05c3] address between user and kernel address ranges
> ...
> pc : [0xffffffece769b3a8] string+0x50/0x10c
> lr : [0xffffffece769ac88] vsnprintf+0x468/0x69c
> ...
>  Call trace:
>   string+0x50/0x10c
>   vsnprintf+0x468/0x69c
>   seq_printf+0x8c/0xd8
>   print_name+0x64/0xf4
>   lc_show+0xb8/0x128
>   seq_read_iter+0x3cc/0x5fc
>   proc_reg_read_iter+0xdc/0x1d4
> 
> The cause of the problem is the function lock_chain_get_class() will
> shift lock_classes index by 1, but the index don't need to be shifted
> anymore since commit 01bb6f0af992 ("locking/lockdep: Change the range of
> class_idx in held_lock struct") already change the index to start from
> 0.
> 
> The lock_classes[-1] located at chain_hlocks array. When printing
> lock_classes[-1] after the chain_hlocks entries are modified, the
> exception happened.
> 
> The output of lockdep_chains are incorrect due to this problem too.
> 
> Fixes: f611e8cf98ec ("lockdep: Take read/write status in consideration when generate chainkey")
> 
> Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>

Hmm.. this means that the /proc/lockdep_chains has been incorrect since
commit f611e8cf89ec..

Nice catch!

Reviewed-by: Boqun Feng <boqun.feng@gmail.com>

Regards,
Boqun

> ---
>  kernel/locking/lockdep.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 4a882f83aeb9..f8a0212189ca 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -3462,7 +3462,7 @@ struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i)
>  	u16 chain_hlock = chain_hlocks[chain->base + i];
>  	unsigned int class_idx = chain_hlock_class_idx(chain_hlock);
>  
> -	return lock_classes + class_idx - 1;
> +	return lock_classes + class_idx;
>  }
>  
>  /*
> @@ -3530,7 +3530,7 @@ static void print_chain_keys_chain(struct lock_chain *chain)
>  		hlock_id = chain_hlocks[chain->base + i];
>  		chain_key = print_chain_key_iteration(hlock_id, chain_key);
>  
> -		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id) - 1);
> +		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id));
>  		printk("\n");
>  	}
>  }
> -- 
> 2.18.0
> 

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH] lockdep: Correct lock_classes index mapping
@ 2022-02-10 12:45   ` Boqun Feng
  0 siblings, 0 replies; 10+ messages in thread
From: Boqun Feng @ 2022-02-10 12:45 UTC (permalink / raw)
  To: Cheng Jui Wang
  Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Waiman Long,
	Matthias Brugger, linux-kernel, linux-arm-kernel, linux-mediatek,
	stable, wsd_upstream, Eason-YH Lin, Kobe-CP Wu, Jeff-CC Hsu


[-- Attachment #1.1: Type: text/plain, Size: 2584 bytes --]

On Thu, Feb 10, 2022 at 06:50:11PM +0800, Cheng Jui Wang wrote:
> A kernel exception was hit when trying to dump /proc/lockdep_chains after
> lockdep report "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!":
> 
> Unable to handle kernel paging request at virtual address 00054005450e05c3
> ...
> 00054005450e05c3] address between user and kernel address ranges
> ...
> pc : [0xffffffece769b3a8] string+0x50/0x10c
> lr : [0xffffffece769ac88] vsnprintf+0x468/0x69c
> ...
>  Call trace:
>   string+0x50/0x10c
>   vsnprintf+0x468/0x69c
>   seq_printf+0x8c/0xd8
>   print_name+0x64/0xf4
>   lc_show+0xb8/0x128
>   seq_read_iter+0x3cc/0x5fc
>   proc_reg_read_iter+0xdc/0x1d4
> 
> The cause of the problem is the function lock_chain_get_class() will
> shift lock_classes index by 1, but the index don't need to be shifted
> anymore since commit 01bb6f0af992 ("locking/lockdep: Change the range of
> class_idx in held_lock struct") already change the index to start from
> 0.
> 
> The lock_classes[-1] located at chain_hlocks array. When printing
> lock_classes[-1] after the chain_hlocks entries are modified, the
> exception happened.
> 
> The output of lockdep_chains are incorrect due to this problem too.
> 
> Fixes: f611e8cf98ec ("lockdep: Take read/write status in consideration when generate chainkey")
> 
> Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>

Hmm.. this means that the /proc/lockdep_chains has been incorrect since
commit f611e8cf89ec..

Nice catch!

Reviewed-by: Boqun Feng <boqun.feng@gmail.com>

Regards,
Boqun

> ---
>  kernel/locking/lockdep.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 4a882f83aeb9..f8a0212189ca 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -3462,7 +3462,7 @@ struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i)
>  	u16 chain_hlock = chain_hlocks[chain->base + i];
>  	unsigned int class_idx = chain_hlock_class_idx(chain_hlock);
>  
> -	return lock_classes + class_idx - 1;
> +	return lock_classes + class_idx;
>  }
>  
>  /*
> @@ -3530,7 +3530,7 @@ static void print_chain_keys_chain(struct lock_chain *chain)
>  		hlock_id = chain_hlocks[chain->base + i];
>  		chain_key = print_chain_key_iteration(hlock_id, chain_key);
>  
> -		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id) - 1);
> +		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id));
>  		printk("\n");
>  	}
>  }
> -- 
> 2.18.0
> 

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] lockdep: Correct lock_classes index mapping
  2022-02-10 10:50 ` Cheng Jui Wang
  (?)
@ 2022-02-10 12:53   ` Greg KH
  -1 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2022-02-10 12:53 UTC (permalink / raw)
  To: Cheng Jui Wang
  Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Waiman Long,
	Boqun Feng, Matthias Brugger, linux-kernel, linux-arm-kernel,
	linux-mediatek, stable, wsd_upstream, Eason-YH Lin, Kobe-CP Wu,
	Jeff-CC Hsu

On Thu, Feb 10, 2022 at 06:50:11PM +0800, Cheng Jui Wang wrote:
> A kernel exception was hit when trying to dump /proc/lockdep_chains after
> lockdep report "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!":
> 
> Unable to handle kernel paging request at virtual address 00054005450e05c3
> ...
> 00054005450e05c3] address between user and kernel address ranges
> ...
> pc : [0xffffffece769b3a8] string+0x50/0x10c
> lr : [0xffffffece769ac88] vsnprintf+0x468/0x69c
> ...
>  Call trace:
>   string+0x50/0x10c
>   vsnprintf+0x468/0x69c
>   seq_printf+0x8c/0xd8
>   print_name+0x64/0xf4
>   lc_show+0xb8/0x128
>   seq_read_iter+0x3cc/0x5fc
>   proc_reg_read_iter+0xdc/0x1d4
> 
> The cause of the problem is the function lock_chain_get_class() will
> shift lock_classes index by 1, but the index don't need to be shifted
> anymore since commit 01bb6f0af992 ("locking/lockdep: Change the range of
> class_idx in held_lock struct") already change the index to start from
> 0.
> 
> The lock_classes[-1] located at chain_hlocks array. When printing
> lock_classes[-1] after the chain_hlocks entries are modified, the
> exception happened.
> 
> The output of lockdep_chains are incorrect due to this problem too.
> 
> Fixes: f611e8cf98ec ("lockdep: Take read/write status in consideration when generate chainkey")
> 
> Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
> ---
>  kernel/locking/lockdep.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 4a882f83aeb9..f8a0212189ca 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -3462,7 +3462,7 @@ struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i)
>  	u16 chain_hlock = chain_hlocks[chain->base + i];
>  	unsigned int class_idx = chain_hlock_class_idx(chain_hlock);
>  
> -	return lock_classes + class_idx - 1;
> +	return lock_classes + class_idx;
>  }
>  
>  /*
> @@ -3530,7 +3530,7 @@ static void print_chain_keys_chain(struct lock_chain *chain)
>  		hlock_id = chain_hlocks[chain->base + i];
>  		chain_key = print_chain_key_iteration(hlock_id, chain_key);
>  
> -		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id) - 1);
> +		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id));
>  		printk("\n");
>  	}
>  }
> -- 
> 2.18.0
> 

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

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

* Re: [PATCH] lockdep: Correct lock_classes index mapping
@ 2022-02-10 12:53   ` Greg KH
  0 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2022-02-10 12:53 UTC (permalink / raw)
  To: Cheng Jui Wang
  Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Waiman Long,
	Boqun Feng, Matthias Brugger, linux-kernel, linux-arm-kernel,
	linux-mediatek, stable, wsd_upstream, Eason-YH Lin, Kobe-CP Wu,
	Jeff-CC Hsu

On Thu, Feb 10, 2022 at 06:50:11PM +0800, Cheng Jui Wang wrote:
> A kernel exception was hit when trying to dump /proc/lockdep_chains after
> lockdep report "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!":
> 
> Unable to handle kernel paging request at virtual address 00054005450e05c3
> ...
> 00054005450e05c3] address between user and kernel address ranges
> ...
> pc : [0xffffffece769b3a8] string+0x50/0x10c
> lr : [0xffffffece769ac88] vsnprintf+0x468/0x69c
> ...
>  Call trace:
>   string+0x50/0x10c
>   vsnprintf+0x468/0x69c
>   seq_printf+0x8c/0xd8
>   print_name+0x64/0xf4
>   lc_show+0xb8/0x128
>   seq_read_iter+0x3cc/0x5fc
>   proc_reg_read_iter+0xdc/0x1d4
> 
> The cause of the problem is the function lock_chain_get_class() will
> shift lock_classes index by 1, but the index don't need to be shifted
> anymore since commit 01bb6f0af992 ("locking/lockdep: Change the range of
> class_idx in held_lock struct") already change the index to start from
> 0.
> 
> The lock_classes[-1] located at chain_hlocks array. When printing
> lock_classes[-1] after the chain_hlocks entries are modified, the
> exception happened.
> 
> The output of lockdep_chains are incorrect due to this problem too.
> 
> Fixes: f611e8cf98ec ("lockdep: Take read/write status in consideration when generate chainkey")
> 
> Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
> ---
>  kernel/locking/lockdep.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 4a882f83aeb9..f8a0212189ca 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -3462,7 +3462,7 @@ struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i)
>  	u16 chain_hlock = chain_hlocks[chain->base + i];
>  	unsigned int class_idx = chain_hlock_class_idx(chain_hlock);
>  
> -	return lock_classes + class_idx - 1;
> +	return lock_classes + class_idx;
>  }
>  
>  /*
> @@ -3530,7 +3530,7 @@ static void print_chain_keys_chain(struct lock_chain *chain)
>  		hlock_id = chain_hlocks[chain->base + i];
>  		chain_key = print_chain_key_iteration(hlock_id, chain_key);
>  
> -		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id) - 1);
> +		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id));
>  		printk("\n");
>  	}
>  }
> -- 
> 2.18.0
> 

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH] lockdep: Correct lock_classes index mapping
@ 2022-02-10 12:53   ` Greg KH
  0 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2022-02-10 12:53 UTC (permalink / raw)
  To: Cheng Jui Wang
  Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Waiman Long,
	Boqun Feng, Matthias Brugger, linux-kernel, linux-arm-kernel,
	linux-mediatek, stable, wsd_upstream, Eason-YH Lin, Kobe-CP Wu,
	Jeff-CC Hsu

On Thu, Feb 10, 2022 at 06:50:11PM +0800, Cheng Jui Wang wrote:
> A kernel exception was hit when trying to dump /proc/lockdep_chains after
> lockdep report "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!":
> 
> Unable to handle kernel paging request at virtual address 00054005450e05c3
> ...
> 00054005450e05c3] address between user and kernel address ranges
> ...
> pc : [0xffffffece769b3a8] string+0x50/0x10c
> lr : [0xffffffece769ac88] vsnprintf+0x468/0x69c
> ...
>  Call trace:
>   string+0x50/0x10c
>   vsnprintf+0x468/0x69c
>   seq_printf+0x8c/0xd8
>   print_name+0x64/0xf4
>   lc_show+0xb8/0x128
>   seq_read_iter+0x3cc/0x5fc
>   proc_reg_read_iter+0xdc/0x1d4
> 
> The cause of the problem is the function lock_chain_get_class() will
> shift lock_classes index by 1, but the index don't need to be shifted
> anymore since commit 01bb6f0af992 ("locking/lockdep: Change the range of
> class_idx in held_lock struct") already change the index to start from
> 0.
> 
> The lock_classes[-1] located at chain_hlocks array. When printing
> lock_classes[-1] after the chain_hlocks entries are modified, the
> exception happened.
> 
> The output of lockdep_chains are incorrect due to this problem too.
> 
> Fixes: f611e8cf98ec ("lockdep: Take read/write status in consideration when generate chainkey")
> 
> Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
> ---
>  kernel/locking/lockdep.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 4a882f83aeb9..f8a0212189ca 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -3462,7 +3462,7 @@ struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i)
>  	u16 chain_hlock = chain_hlocks[chain->base + i];
>  	unsigned int class_idx = chain_hlock_class_idx(chain_hlock);
>  
> -	return lock_classes + class_idx - 1;
> +	return lock_classes + class_idx;
>  }
>  
>  /*
> @@ -3530,7 +3530,7 @@ static void print_chain_keys_chain(struct lock_chain *chain)
>  		hlock_id = chain_hlocks[chain->base + i];
>  		chain_key = print_chain_key_iteration(hlock_id, chain_key);
>  
> -		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id) - 1);
> +		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id));
>  		printk("\n");
>  	}
>  }
> -- 
> 2.18.0
> 

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [tip: locking/urgent] lockdep: Correct lock_classes index mapping
  2022-02-10 10:50 ` Cheng Jui Wang
                   ` (3 preceding siblings ...)
  (?)
@ 2022-02-14 10:37 ` tip-bot2 for Cheng Jui Wang
  -1 siblings, 0 replies; 10+ messages in thread
From: tip-bot2 for Cheng Jui Wang @ 2022-02-14 10:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Cheng Jui Wang, Peter Zijlstra (Intel), Boqun Feng, x86, linux-kernel

The following commit has been merged into the locking/urgent branch of tip:

Commit-ID:     28df029d53a2fd80c1b8674d47895648ad26dcfb
Gitweb:        https://git.kernel.org/tip/28df029d53a2fd80c1b8674d47895648ad26dcfb
Author:        Cheng Jui Wang <cheng-jui.wang@mediatek.com>
AuthorDate:    Thu, 10 Feb 2022 18:50:11 +08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 11 Feb 2022 23:30:02 +01:00

lockdep: Correct lock_classes index mapping

A kernel exception was hit when trying to dump /proc/lockdep_chains after
lockdep report "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!":

Unable to handle kernel paging request at virtual address 00054005450e05c3
...
00054005450e05c3] address between user and kernel address ranges
...
pc : [0xffffffece769b3a8] string+0x50/0x10c
lr : [0xffffffece769ac88] vsnprintf+0x468/0x69c
...
 Call trace:
  string+0x50/0x10c
  vsnprintf+0x468/0x69c
  seq_printf+0x8c/0xd8
  print_name+0x64/0xf4
  lc_show+0xb8/0x128
  seq_read_iter+0x3cc/0x5fc
  proc_reg_read_iter+0xdc/0x1d4

The cause of the problem is the function lock_chain_get_class() will
shift lock_classes index by 1, but the index don't need to be shifted
anymore since commit 01bb6f0af992 ("locking/lockdep: Change the range
of class_idx in held_lock struct") already change the index to start
from 0.

The lock_classes[-1] located at chain_hlocks array. When printing
lock_classes[-1] after the chain_hlocks entries are modified, the
exception happened.

The output of lockdep_chains are incorrect due to this problem too.

Fixes: f611e8cf98ec ("lockdep: Take read/write status in consideration when generate chainkey")
Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://lore.kernel.org/r/20220210105011.21712-1-cheng-jui.wang@mediatek.com
---
 kernel/locking/lockdep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 4a882f8..f8a0212 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3462,7 +3462,7 @@ struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i)
 	u16 chain_hlock = chain_hlocks[chain->base + i];
 	unsigned int class_idx = chain_hlock_class_idx(chain_hlock);
 
-	return lock_classes + class_idx - 1;
+	return lock_classes + class_idx;
 }
 
 /*
@@ -3530,7 +3530,7 @@ static void print_chain_keys_chain(struct lock_chain *chain)
 		hlock_id = chain_hlocks[chain->base + i];
 		chain_key = print_chain_key_iteration(hlock_id, chain_key);
 
-		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id) - 1);
+		print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id));
 		printk("\n");
 	}
 }

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

end of thread, other threads:[~2022-02-14 11:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10 10:50 [PATCH] lockdep: Correct lock_classes index mapping Cheng Jui Wang
2022-02-10 10:50 ` Cheng Jui Wang
2022-02-10 10:50 ` Cheng Jui Wang
2022-02-10 12:45 ` Boqun Feng
2022-02-10 12:45   ` Boqun Feng
2022-02-10 12:45   ` Boqun Feng
2022-02-10 12:53 ` Greg KH
2022-02-10 12:53   ` Greg KH
2022-02-10 12:53   ` Greg KH
2022-02-14 10:37 ` [tip: locking/urgent] " tip-bot2 for Cheng Jui Wang

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.