[v3,3/4] arch_topology: Remove early cacheinfo error message

Message ID 20230413091436.230134-4-pierre.gondois@arm.com
State New
Headers
Series cacheinfo: Correctly fallback to using clidr_el1's information |

Commit Message

Pierre Gondois April 13, 2023, 9:14 a.m. UTC
  fetch_cache_info() tries to get the number of cache leaves/levels
for each CPU in order to pre-allocate memory for cacheinfo struct.
Allocating this memory later triggers a:
  'BUG: sleeping function called from invalid context'
in PREEMPT_RT kernels.

If there is no cache related information available in DT or ACPI,
fetch_cache_info() fails and an error message is printed:
  'Early cacheinfo failed, ret = ...'

Not having cache information should be a valid configuration.
Remove the error message if fetch_cache_info() fails.

Suggested-by: Conor Dooley <conor@kernel.org>
Link: https://lore.kernel.org/all/20230404-hatred-swimmer-6fecdf33b57a@spud/
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/base/arch_topology.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Comments

Conor Dooley April 13, 2023, 10:02 a.m. UTC | #1
On Thu, Apr 13, 2023 at 11:14:33AM +0200, Pierre Gondois wrote:
> fetch_cache_info() tries to get the number of cache leaves/levels
> for each CPU in order to pre-allocate memory for cacheinfo struct.
> Allocating this memory later triggers a:
>   'BUG: sleeping function called from invalid context'
> in PREEMPT_RT kernels.
> 
> If there is no cache related information available in DT or ACPI,
> fetch_cache_info() fails and an error message is printed:
>   'Early cacheinfo failed, ret = ...'
> 
> Not having cache information should be a valid configuration.
> Remove the error message if fetch_cache_info() fails.
> 
> Suggested-by: Conor Dooley <conor@kernel.org>

Not that it really matters for suggested-by, and there's no way really
for you to know, but the corporate overlords prefer:
s/conor@kernel.org/conor.dooley@microchip.com/

> Link: https://lore.kernel.org/all/20230404-hatred-swimmer-6fecdf33b57a@spud/
> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
> ---
>  drivers/base/arch_topology.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
> index b1c1dd38ab01..1f071eaede5b 100644
> --- a/drivers/base/arch_topology.c
> +++ b/drivers/base/arch_topology.c
> @@ -843,10 +843,8 @@ void __init init_cpu_topology(void)
>  
>  	for_each_possible_cpu(cpu) {
>  		ret = fetch_cache_info(cpu);
> -		if (ret) {
> -			pr_err("Early cacheinfo failed, ret = %d\n", ret);

Hmm do you really want to remove the print altogether? This can fail
with -EINVAL and -ENOMEM too, so should we just check for
| if (ret && ret != -ENOENT)
instead, since in the other cases it really did fail?

Cheers,
Conor.
  
Conor Dooley April 13, 2023, 10:25 a.m. UTC | #2
On Thu, Apr 13, 2023 at 11:02:49AM +0100, Conor Dooley wrote:
> On Thu, Apr 13, 2023 at 11:14:33AM +0200, Pierre Gondois wrote:
> > fetch_cache_info() tries to get the number of cache leaves/levels
> > for each CPU in order to pre-allocate memory for cacheinfo struct.
> > Allocating this memory later triggers a:
> >   'BUG: sleeping function called from invalid context'
> > in PREEMPT_RT kernels.
> > 
> > If there is no cache related information available in DT or ACPI,
> > fetch_cache_info() fails and an error message is printed:
> >   'Early cacheinfo failed, ret = ...'
> > 
> > Not having cache information should be a valid configuration.
> > Remove the error message if fetch_cache_info() fails.
> > 
> > Suggested-by: Conor Dooley <conor@kernel.org>
> 
> Not that it really matters for suggested-by, and there's no way really
> for you to know, but the corporate overlords prefer:
> s/conor@kernel.org/conor.dooley@microchip.com/
> 
> > Link: https://lore.kernel.org/all/20230404-hatred-swimmer-6fecdf33b57a@spud/
> > Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
> > ---
> >  drivers/base/arch_topology.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
> > index b1c1dd38ab01..1f071eaede5b 100644
> > --- a/drivers/base/arch_topology.c
> > +++ b/drivers/base/arch_topology.c
> > @@ -843,10 +843,8 @@ void __init init_cpu_topology(void)
> >  
> >  	for_each_possible_cpu(cpu) {
> >  		ret = fetch_cache_info(cpu);
> > -		if (ret) {
> > -			pr_err("Early cacheinfo failed, ret = %d\n", ret);
> 
> Hmm do you really want to remove the print altogether? This can fail
> with -EINVAL and -ENOMEM too, so should we just check for
> | if (ret && ret != -ENOENT)
> instead, since in the other cases it really did fail?

To save Sudeep (potentially) waiting for me when you resubmit, with that
change:
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>

Thanks,
Conor.
  
Pierre Gondois April 13, 2023, 3:25 p.m. UTC | #3
On 4/13/23 12:02, Conor Dooley wrote:
> On Thu, Apr 13, 2023 at 11:14:33AM +0200, Pierre Gondois wrote:
>> fetch_cache_info() tries to get the number of cache leaves/levels
>> for each CPU in order to pre-allocate memory for cacheinfo struct.
>> Allocating this memory later triggers a:
>>    'BUG: sleeping function called from invalid context'
>> in PREEMPT_RT kernels.
>>
>> If there is no cache related information available in DT or ACPI,
>> fetch_cache_info() fails and an error message is printed:
>>    'Early cacheinfo failed, ret = ...'
>>
>> Not having cache information should be a valid configuration.
>> Remove the error message if fetch_cache_info() fails.
>>
>> Suggested-by: Conor Dooley <conor@kernel.org>
> 
> Not that it really matters for suggested-by, and there's no way really
> for you to know, but the corporate overlords prefer:
> s/conor@kernel.org/conor.dooley@microchip.com/
> 
>> Link: https://lore.kernel.org/all/20230404-hatred-swimmer-6fecdf33b57a@spud/
>> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
>> ---
>>   drivers/base/arch_topology.c | 4 +---
>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
>> index b1c1dd38ab01..1f071eaede5b 100644
>> --- a/drivers/base/arch_topology.c
>> +++ b/drivers/base/arch_topology.c
>> @@ -843,10 +843,8 @@ void __init init_cpu_topology(void)
>>   
>>   	for_each_possible_cpu(cpu) {
>>   		ret = fetch_cache_info(cpu);
>> -		if (ret) {
>> -			pr_err("Early cacheinfo failed, ret = %d\n", ret);
> 
> Hmm do you really want to remove the print altogether? This can fail
> with -EINVAL and -ENOMEM too, so should we just check for
> | if (ret && ret != -ENOENT)
> instead, since in the other cases it really did fail?

I think [PATCH 2/4] requires the following update in this case:

--- a/drivers/base/cacheinfo.c
+++ b/drivers/base/cacheinfo.c
@@ -288,8 +288,10 @@ int init_of_cache_level(unsigned int cpu)
         struct device_node *prev = NULL;
         unsigned int levels = 0, leaves, level;
  
-       if (!of_check_cache_nodes(np))
-               goto err_out;
+       if (!of_check_cache_nodes(np)) {
+               of_node_put(np);
+               return -ENOENT;
+       }
  
         leaves = of_count_cache_leaves(np);
         if (leaves > 0)

Is it ok to do this and keep your Reviewed-by ?

Thanks for the review,
Regards,
Pierre
  
Conor Dooley April 13, 2023, 4:23 p.m. UTC | #4
On Thu, Apr 13, 2023 at 05:25:25PM +0200, Pierre Gondois wrote:

> Is it ok to do this and keep your Reviewed-by ?

Yah, should be grand chief.
  

Patch

diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index b1c1dd38ab01..1f071eaede5b 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -843,10 +843,8 @@  void __init init_cpu_topology(void)
 
 	for_each_possible_cpu(cpu) {
 		ret = fetch_cache_info(cpu);
-		if (ret) {
-			pr_err("Early cacheinfo failed, ret = %d\n", ret);
+		if (ret)
 			break;
-		}
 	}
 }