linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] iommu/arm-smmu-v3: remove unnecessary oom message
@ 2021-06-09 12:54 Zhen Lei
  2021-06-11 10:32 ` Will Deacon
  2021-06-15 19:18 ` Will Deacon
  0 siblings, 2 replies; 10+ messages in thread
From: Zhen Lei @ 2021-06-09 12:54 UTC (permalink / raw)
  To: Robin Murphy, linux-arm-kernel, Joerg Roedel, Will Deacon, iommu; +Cc: Zhen Lei

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 2ddc3cd5a7d1..fd7c55b44881 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -2787,10 +2787,8 @@ static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)
 	void *strtab = smmu->strtab_cfg.strtab;
 
 	cfg->l1_desc = devm_kzalloc(smmu->dev, size, GFP_KERNEL);
-	if (!cfg->l1_desc) {
-		dev_err(smmu->dev, "failed to allocate l1 stream table desc\n");
+	if (!cfg->l1_desc)
 		return -ENOMEM;
-	}
 
 	for (i = 0; i < cfg->num_l1_ents; ++i) {
 		arm_smmu_write_strtab_l1_desc(strtab, &cfg->l1_desc[i]);
@@ -3581,10 +3579,8 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
 	bool bypass;
 
 	smmu = devm_kzalloc(dev, sizeof(*smmu), GFP_KERNEL);
-	if (!smmu) {
-		dev_err(dev, "failed to allocate arm_smmu_device\n");
+	if (!smmu)
 		return -ENOMEM;
-	}
 	smmu->dev = dev;
 
 	if (dev->of_node) {
-- 
2.25.1



_______________________________________________
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 1/1] iommu/arm-smmu-v3: remove unnecessary oom message
  2021-06-09 12:54 [PATCH 1/1] iommu/arm-smmu-v3: remove unnecessary oom message Zhen Lei
@ 2021-06-11 10:32 ` Will Deacon
  2021-06-15 11:22   ` Leizhen (ThunderTown)
  2021-06-15 19:18 ` Will Deacon
  1 sibling, 1 reply; 10+ messages in thread
From: Will Deacon @ 2021-06-11 10:32 UTC (permalink / raw)
  To: Zhen Lei; +Cc: Robin Murphy, linux-arm-kernel, Joerg Roedel, iommu

On Wed, Jun 09, 2021 at 08:54:38PM +0800, Zhen Lei wrote:
> Fixes scripts/checkpatch.pl warning:
> WARNING: Possible unnecessary 'out of memory' message
> 
> Remove it can help us save a bit of memory.
> 
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index 2ddc3cd5a7d1..fd7c55b44881 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -2787,10 +2787,8 @@ static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)
>  	void *strtab = smmu->strtab_cfg.strtab;
>  
>  	cfg->l1_desc = devm_kzalloc(smmu->dev, size, GFP_KERNEL);
> -	if (!cfg->l1_desc) {
> -		dev_err(smmu->dev, "failed to allocate l1 stream table desc\n");
> +	if (!cfg->l1_desc)

What error do you get if devm_kzalloc() fails? I'd like to make sure it's
easy to track down _which_ allocation failed in that case -- does it give
you a line number, for example?

Will

_______________________________________________
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 1/1] iommu/arm-smmu-v3: remove unnecessary oom message
  2021-06-11 10:32 ` Will Deacon
@ 2021-06-15 11:22   ` Leizhen (ThunderTown)
  2021-06-15 11:34     ` Will Deacon
  0 siblings, 1 reply; 10+ messages in thread
From: Leizhen (ThunderTown) @ 2021-06-15 11:22 UTC (permalink / raw)
  To: Will Deacon; +Cc: Robin Murphy, linux-arm-kernel, Joerg Roedel, iommu



On 2021/6/11 18:32, Will Deacon wrote:
> On Wed, Jun 09, 2021 at 08:54:38PM +0800, Zhen Lei wrote:
>> Fixes scripts/checkpatch.pl warning:
>> WARNING: Possible unnecessary 'out of memory' message
>>
>> Remove it can help us save a bit of memory.
>>
>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
>> ---
>>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 ++------
>>  1 file changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>> index 2ddc3cd5a7d1..fd7c55b44881 100644
>> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>> @@ -2787,10 +2787,8 @@ static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)
>>  	void *strtab = smmu->strtab_cfg.strtab;
>>  
>>  	cfg->l1_desc = devm_kzalloc(smmu->dev, size, GFP_KERNEL);
>> -	if (!cfg->l1_desc) {
>> -		dev_err(smmu->dev, "failed to allocate l1 stream table desc\n");
>> +	if (!cfg->l1_desc)
> 
> What error do you get if devm_kzalloc() fails? I'd like to make sure it's
> easy to track down _which_ allocation failed in that case -- does it give
> you a line number, for example?

When devm_kzalloc() fails, the OOM information is printed. No line number information, but the
size(order) and call stack is printed. It doesn't matter which allocation failed, the failure
is caused by insufficient system memory rather than the fault of the SMMU driver. Therefore,
the current printing is not helpful for locating the problem of insufficient memory. After all,
when memory allocation fails, the SMMU driver cannot work at a lower specification.

[   44.126661] swapper/0 invoked oom-killer: gfp_mask=0x40cc0(GFP_KERNEL|__GFP_COMP), order=1, oom_score_adj=0
[   44.136381] CPU: 26 PID: 1 Comm: swapper/0 Not tainted 5.13.0-rc6-00001-g0d973bf828c8 #1
[   44.144436] Hardware name: Huawei TaiShan 2280 V2/BC82AMDC, BIOS 2280-V2 CS V3.B220.02 03/27/2020
[   44.153266] Call trace:
[   44.155703]  dump_backtrace+0x0/0x1c0
[   44.159355]  show_stack+0x18/0x68
[   44.162658]  dump_stack+0xd8/0x134
[   44.166047]  dump_header+0x44/0x208
[   44.169524]  out_of_memory+0x530/0x580
[   44.173256]  __alloc_pages_slowpath.constprop.120+0x85c/0xac0
[   44.178976]  __alloc_pages+0x238/0x300
[   44.182709]  allocate_slab+0x3bc/0x3d8
[   44.186440]  ___slab_alloc+0x508/0x6b0
[   44.190172]  __slab_alloc.isra.100+0x2c/0x58
[   44.194422]  __kmalloc_node_track_caller+0x138/0x2e8
[   44.199365]  devm_kmalloc+0x58/0x100
[   44.202926]  arm_smmu_device_probe+0x858/0x1150
[   44.207437]  platform_probe+0x68/0xe0

> 
> Will
> 
> .
> 


_______________________________________________
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 1/1] iommu/arm-smmu-v3: remove unnecessary oom message
  2021-06-15 11:22   ` Leizhen (ThunderTown)
@ 2021-06-15 11:34     ` Will Deacon
  2021-06-15 11:36       ` Will Deacon
  2021-06-15 11:51       ` Robin Murphy
  0 siblings, 2 replies; 10+ messages in thread
From: Will Deacon @ 2021-06-15 11:34 UTC (permalink / raw)
  To: Leizhen (ThunderTown); +Cc: Robin Murphy, linux-arm-kernel, Joerg Roedel, iommu

On Tue, Jun 15, 2021 at 07:22:10PM +0800, Leizhen (ThunderTown) wrote:
> 
> 
> On 2021/6/11 18:32, Will Deacon wrote:
> > On Wed, Jun 09, 2021 at 08:54:38PM +0800, Zhen Lei wrote:
> >> Fixes scripts/checkpatch.pl warning:
> >> WARNING: Possible unnecessary 'out of memory' message
> >>
> >> Remove it can help us save a bit of memory.
> >>
> >> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> >> ---
> >>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 ++------
> >>  1 file changed, 2 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> >> index 2ddc3cd5a7d1..fd7c55b44881 100644
> >> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> >> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> >> @@ -2787,10 +2787,8 @@ static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)
> >>  	void *strtab = smmu->strtab_cfg.strtab;
> >>  
> >>  	cfg->l1_desc = devm_kzalloc(smmu->dev, size, GFP_KERNEL);
> >> -	if (!cfg->l1_desc) {
> >> -		dev_err(smmu->dev, "failed to allocate l1 stream table desc\n");
> >> +	if (!cfg->l1_desc)
> > 
> > What error do you get if devm_kzalloc() fails? I'd like to make sure it's
> > easy to track down _which_ allocation failed in that case -- does it give
> > you a line number, for example?
> 
> When devm_kzalloc() fails, the OOM information is printed. No line number information, but the
> size(order) and call stack is printed. It doesn't matter which allocation failed, the failure
> is caused by insufficient system memory rather than the fault of the SMMU driver. Therefore,
> the current printing is not helpful for locating the problem of insufficient memory. After all,
> when memory allocation fails, the SMMU driver cannot work at a lower specification.

I don't entirely agree. Another reason for the failure is because the driver
might be asking for a huge (or negative) allocation, in which case it might
be instructive to have a look at the actual caller, particularly if the
size is derived from hardware or firmware properties.

Will

_______________________________________________
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 1/1] iommu/arm-smmu-v3: remove unnecessary oom message
  2021-06-15 11:34     ` Will Deacon
@ 2021-06-15 11:36       ` Will Deacon
  2021-06-15 11:51       ` Robin Murphy
  1 sibling, 0 replies; 10+ messages in thread
From: Will Deacon @ 2021-06-15 11:36 UTC (permalink / raw)
  To: Leizhen (ThunderTown); +Cc: Robin Murphy, linux-arm-kernel, Joerg Roedel, iommu

On Tue, Jun 15, 2021 at 12:34:17PM +0100, Will Deacon wrote:
> On Tue, Jun 15, 2021 at 07:22:10PM +0800, Leizhen (ThunderTown) wrote:
> > 
> > 
> > On 2021/6/11 18:32, Will Deacon wrote:
> > > On Wed, Jun 09, 2021 at 08:54:38PM +0800, Zhen Lei wrote:
> > >> Fixes scripts/checkpatch.pl warning:
> > >> WARNING: Possible unnecessary 'out of memory' message
> > >>
> > >> Remove it can help us save a bit of memory.
> > >>
> > >> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> > >> ---
> > >>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 ++------
> > >>  1 file changed, 2 insertions(+), 6 deletions(-)
> > >>
> > >> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > >> index 2ddc3cd5a7d1..fd7c55b44881 100644
> > >> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > >> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > >> @@ -2787,10 +2787,8 @@ static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)
> > >>  	void *strtab = smmu->strtab_cfg.strtab;
> > >>  
> > >>  	cfg->l1_desc = devm_kzalloc(smmu->dev, size, GFP_KERNEL);
> > >> -	if (!cfg->l1_desc) {
> > >> -		dev_err(smmu->dev, "failed to allocate l1 stream table desc\n");
> > >> +	if (!cfg->l1_desc)
> > > 
> > > What error do you get if devm_kzalloc() fails? I'd like to make sure it's
> > > easy to track down _which_ allocation failed in that case -- does it give
> > > you a line number, for example?
> > 
> > When devm_kzalloc() fails, the OOM information is printed. No line number information, but the
> > size(order) and call stack is printed. It doesn't matter which allocation failed, the failure
> > is caused by insufficient system memory rather than the fault of the SMMU driver. Therefore,
> > the current printing is not helpful for locating the problem of insufficient memory. After all,
> > when memory allocation fails, the SMMU driver cannot work at a lower specification.
> 
> I don't entirely agree. Another reason for the failure is because the driver
> might be asking for a huge (or negative) allocation, in which case it might
> be instructive to have a look at the actual caller, particularly if the
> size is derived from hardware or firmware properties.

That said, the callstack would solve this problem, so I think that's good
enough.

Will

_______________________________________________
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 1/1] iommu/arm-smmu-v3: remove unnecessary oom message
  2021-06-15 11:34     ` Will Deacon
  2021-06-15 11:36       ` Will Deacon
@ 2021-06-15 11:51       ` Robin Murphy
  2021-06-15 11:55         ` Will Deacon
  1 sibling, 1 reply; 10+ messages in thread
From: Robin Murphy @ 2021-06-15 11:51 UTC (permalink / raw)
  To: Will Deacon, Leizhen (ThunderTown); +Cc: linux-arm-kernel, Joerg Roedel, iommu

On 2021-06-15 12:34, Will Deacon wrote:
> On Tue, Jun 15, 2021 at 07:22:10PM +0800, Leizhen (ThunderTown) wrote:
>>
>>
>> On 2021/6/11 18:32, Will Deacon wrote:
>>> On Wed, Jun 09, 2021 at 08:54:38PM +0800, Zhen Lei wrote:
>>>> Fixes scripts/checkpatch.pl warning:
>>>> WARNING: Possible unnecessary 'out of memory' message
>>>>
>>>> Remove it can help us save a bit of memory.
>>>>
>>>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
>>>> ---
>>>>   drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 ++------
>>>>   1 file changed, 2 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>>>> index 2ddc3cd5a7d1..fd7c55b44881 100644
>>>> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>>>> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>>>> @@ -2787,10 +2787,8 @@ static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)
>>>>   	void *strtab = smmu->strtab_cfg.strtab;
>>>>   
>>>>   	cfg->l1_desc = devm_kzalloc(smmu->dev, size, GFP_KERNEL);
>>>> -	if (!cfg->l1_desc) {
>>>> -		dev_err(smmu->dev, "failed to allocate l1 stream table desc\n");
>>>> +	if (!cfg->l1_desc)
>>>
>>> What error do you get if devm_kzalloc() fails? I'd like to make sure it's
>>> easy to track down _which_ allocation failed in that case -- does it give
>>> you a line number, for example?
>>
>> When devm_kzalloc() fails, the OOM information is printed. No line number information, but the
>> size(order) and call stack is printed. It doesn't matter which allocation failed, the failure
>> is caused by insufficient system memory rather than the fault of the SMMU driver. Therefore,
>> the current printing is not helpful for locating the problem of insufficient memory. After all,
>> when memory allocation fails, the SMMU driver cannot work at a lower specification.
> 
> I don't entirely agree. Another reason for the failure is because the driver
> might be asking for a huge (or negative) allocation, in which case it might
> be instructive to have a look at the actual caller, particularly if the
> size is derived from hardware or firmware properties.

Agreed - other than deliberately-contrived situations I don't think I've 
ever hit a genuine OOM, but I definitely have debugged attempts to 
allocate -1 of something. If the driver-specific message actually calls 
out the critical information, e.g. "failed to allocate %d stream table 
entries", it gives debugging a head start since the miscalculation is 
obvious, but a static message that only identifies the callsite really 
only saves a quick trip to scripts/faddr2line, and personally I've never 
found that particularly valuable.

Robin.

_______________________________________________
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 1/1] iommu/arm-smmu-v3: remove unnecessary oom message
  2021-06-15 11:51       ` Robin Murphy
@ 2021-06-15 11:55         ` Will Deacon
  2021-06-16  1:47           ` Leizhen (ThunderTown)
  0 siblings, 1 reply; 10+ messages in thread
From: Will Deacon @ 2021-06-15 11:55 UTC (permalink / raw)
  To: Robin Murphy; +Cc: Leizhen (ThunderTown), linux-arm-kernel, Joerg Roedel, iommu

On Tue, Jun 15, 2021 at 12:51:38PM +0100, Robin Murphy wrote:
> On 2021-06-15 12:34, Will Deacon wrote:
> > On Tue, Jun 15, 2021 at 07:22:10PM +0800, Leizhen (ThunderTown) wrote:
> > > 
> > > 
> > > On 2021/6/11 18:32, Will Deacon wrote:
> > > > On Wed, Jun 09, 2021 at 08:54:38PM +0800, Zhen Lei wrote:
> > > > > Fixes scripts/checkpatch.pl warning:
> > > > > WARNING: Possible unnecessary 'out of memory' message
> > > > > 
> > > > > Remove it can help us save a bit of memory.
> > > > > 
> > > > > Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> > > > > ---
> > > > >   drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 ++------
> > > > >   1 file changed, 2 insertions(+), 6 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > > > > index 2ddc3cd5a7d1..fd7c55b44881 100644
> > > > > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > > > > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > > > > @@ -2787,10 +2787,8 @@ static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)
> > > > >   	void *strtab = smmu->strtab_cfg.strtab;
> > > > >   	cfg->l1_desc = devm_kzalloc(smmu->dev, size, GFP_KERNEL);
> > > > > -	if (!cfg->l1_desc) {
> > > > > -		dev_err(smmu->dev, "failed to allocate l1 stream table desc\n");
> > > > > +	if (!cfg->l1_desc)
> > > > 
> > > > What error do you get if devm_kzalloc() fails? I'd like to make sure it's
> > > > easy to track down _which_ allocation failed in that case -- does it give
> > > > you a line number, for example?
> > > 
> > > When devm_kzalloc() fails, the OOM information is printed. No line number information, but the
> > > size(order) and call stack is printed. It doesn't matter which allocation failed, the failure
> > > is caused by insufficient system memory rather than the fault of the SMMU driver. Therefore,
> > > the current printing is not helpful for locating the problem of insufficient memory. After all,
> > > when memory allocation fails, the SMMU driver cannot work at a lower specification.
> > 
> > I don't entirely agree. Another reason for the failure is because the driver
> > might be asking for a huge (or negative) allocation, in which case it might
> > be instructive to have a look at the actual caller, particularly if the
> > size is derived from hardware or firmware properties.
> 
> Agreed - other than deliberately-contrived situations I don't think I've
> ever hit a genuine OOM, but I definitely have debugged attempts to allocate
> -1 of something. If the driver-specific message actually calls out the
> critical information, e.g. "failed to allocate %d stream table entries", it
> gives debugging a head start since the miscalculation is obvious, but a
> static message that only identifies the callsite really only saves a quick
> trip to scripts/faddr2line, and personally I've never found that
> particularly valuable.

So it sounds like this particular patch is fine, but the one for smmuv2
should leave the IRQ allocation message alone (by virtue of it printing
something a bit more useful -- the number of irqs).

Will

_______________________________________________
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 1/1] iommu/arm-smmu-v3: remove unnecessary oom message
  2021-06-09 12:54 [PATCH 1/1] iommu/arm-smmu-v3: remove unnecessary oom message Zhen Lei
  2021-06-11 10:32 ` Will Deacon
@ 2021-06-15 19:18 ` Will Deacon
  1 sibling, 0 replies; 10+ messages in thread
From: Will Deacon @ 2021-06-15 19:18 UTC (permalink / raw)
  To: linux-arm-kernel, Zhen Lei, iommu, Joerg Roedel, Robin Murphy
  Cc: catalin.marinas, kernel-team, Will Deacon

On Wed, 9 Jun 2021 20:54:38 +0800, Zhen Lei wrote:
> Fixes scripts/checkpatch.pl warning:
> WARNING: Possible unnecessary 'out of memory' message
> 
> Remove it can help us save a bit of memory.

Applied to will (for-joerg/arm-smmu/updates), thanks!

[1/1] iommu/arm-smmu-v3: Remove unnecessary oom message
      https://git.kernel.org/will/c/affa909571b0

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

_______________________________________________
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 1/1] iommu/arm-smmu-v3: remove unnecessary oom message
  2021-06-15 11:55         ` Will Deacon
@ 2021-06-16  1:47           ` Leizhen (ThunderTown)
  2021-06-16 10:10             ` Will Deacon
  0 siblings, 1 reply; 10+ messages in thread
From: Leizhen (ThunderTown) @ 2021-06-16  1:47 UTC (permalink / raw)
  To: Will Deacon, Robin Murphy; +Cc: linux-arm-kernel, Joerg Roedel, iommu



On 2021/6/15 19:55, Will Deacon wrote:
> On Tue, Jun 15, 2021 at 12:51:38PM +0100, Robin Murphy wrote:
>> On 2021-06-15 12:34, Will Deacon wrote:
>>> On Tue, Jun 15, 2021 at 07:22:10PM +0800, Leizhen (ThunderTown) wrote:
>>>>
>>>>
>>>> On 2021/6/11 18:32, Will Deacon wrote:
>>>>> On Wed, Jun 09, 2021 at 08:54:38PM +0800, Zhen Lei wrote:
>>>>>> Fixes scripts/checkpatch.pl warning:
>>>>>> WARNING: Possible unnecessary 'out of memory' message
>>>>>>
>>>>>> Remove it can help us save a bit of memory.
>>>>>>
>>>>>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
>>>>>> ---
>>>>>>   drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 ++------
>>>>>>   1 file changed, 2 insertions(+), 6 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>>>>>> index 2ddc3cd5a7d1..fd7c55b44881 100644
>>>>>> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>>>>>> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>>>>>> @@ -2787,10 +2787,8 @@ static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)
>>>>>>   	void *strtab = smmu->strtab_cfg.strtab;
>>>>>>   	cfg->l1_desc = devm_kzalloc(smmu->dev, size, GFP_KERNEL);
>>>>>> -	if (!cfg->l1_desc) {
>>>>>> -		dev_err(smmu->dev, "failed to allocate l1 stream table desc\n");
>>>>>> +	if (!cfg->l1_desc)
>>>>>
>>>>> What error do you get if devm_kzalloc() fails? I'd like to make sure it's
>>>>> easy to track down _which_ allocation failed in that case -- does it give
>>>>> you a line number, for example?
>>>>
>>>> When devm_kzalloc() fails, the OOM information is printed. No line number information, but the
>>>> size(order) and call stack is printed. It doesn't matter which allocation failed, the failure
>>>> is caused by insufficient system memory rather than the fault of the SMMU driver. Therefore,
>>>> the current printing is not helpful for locating the problem of insufficient memory. After all,
>>>> when memory allocation fails, the SMMU driver cannot work at a lower specification.
>>>
>>> I don't entirely agree. Another reason for the failure is because the driver
>>> might be asking for a huge (or negative) allocation, in which case it might
>>> be instructive to have a look at the actual caller, particularly if the
>>> size is derived from hardware or firmware properties.
>>
>> Agreed - other than deliberately-contrived situations I don't think I've
>> ever hit a genuine OOM, but I definitely have debugged attempts to allocate
>> -1 of something. If the driver-specific message actually calls out the
>> critical information, e.g. "failed to allocate %d stream table entries", it
>> gives debugging a head start since the miscalculation is obvious, but a
>> static message that only identifies the callsite really only saves a quick
>> trip to scripts/faddr2line, and personally I've never found that
>> particularly valuable.
> 
> So it sounds like this particular patch is fine, but the one for smmuv2
> should leave the IRQ allocation message alone (by virtue of it printing
> something a bit more useful -- the number of irqs).

        num_irqs = 0;
        while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
                num_irqs++;
        }

As the above code, num_irqs is calculated based on the number of dtb or acpi
configuration items, it can't be too large. That is, there is almost zero chance
that devm_kcalloc() will fail because num_irqs is too large.


> 
> Will
> 
> .
> 


_______________________________________________
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 1/1] iommu/arm-smmu-v3: remove unnecessary oom message
  2021-06-16  1:47           ` Leizhen (ThunderTown)
@ 2021-06-16 10:10             ` Will Deacon
  0 siblings, 0 replies; 10+ messages in thread
From: Will Deacon @ 2021-06-16 10:10 UTC (permalink / raw)
  To: Leizhen (ThunderTown); +Cc: Robin Murphy, linux-arm-kernel, Joerg Roedel, iommu

On Wed, Jun 16, 2021 at 09:47:18AM +0800, Leizhen (ThunderTown) wrote:
> 
> 
> On 2021/6/15 19:55, Will Deacon wrote:
> > On Tue, Jun 15, 2021 at 12:51:38PM +0100, Robin Murphy wrote:
> >> On 2021-06-15 12:34, Will Deacon wrote:
> >>> On Tue, Jun 15, 2021 at 07:22:10PM +0800, Leizhen (ThunderTown) wrote:
> >>>>
> >>>>
> >>>> On 2021/6/11 18:32, Will Deacon wrote:
> >>>>> On Wed, Jun 09, 2021 at 08:54:38PM +0800, Zhen Lei wrote:
> >>>>>> Fixes scripts/checkpatch.pl warning:
> >>>>>> WARNING: Possible unnecessary 'out of memory' message
> >>>>>>
> >>>>>> Remove it can help us save a bit of memory.
> >>>>>>
> >>>>>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> >>>>>> ---
> >>>>>>   drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 ++------
> >>>>>>   1 file changed, 2 insertions(+), 6 deletions(-)
> >>>>>>
> >>>>>> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> >>>>>> index 2ddc3cd5a7d1..fd7c55b44881 100644
> >>>>>> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> >>>>>> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> >>>>>> @@ -2787,10 +2787,8 @@ static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)
> >>>>>>   	void *strtab = smmu->strtab_cfg.strtab;
> >>>>>>   	cfg->l1_desc = devm_kzalloc(smmu->dev, size, GFP_KERNEL);
> >>>>>> -	if (!cfg->l1_desc) {
> >>>>>> -		dev_err(smmu->dev, "failed to allocate l1 stream table desc\n");
> >>>>>> +	if (!cfg->l1_desc)
> >>>>>
> >>>>> What error do you get if devm_kzalloc() fails? I'd like to make sure it's
> >>>>> easy to track down _which_ allocation failed in that case -- does it give
> >>>>> you a line number, for example?
> >>>>
> >>>> When devm_kzalloc() fails, the OOM information is printed. No line number information, but the
> >>>> size(order) and call stack is printed. It doesn't matter which allocation failed, the failure
> >>>> is caused by insufficient system memory rather than the fault of the SMMU driver. Therefore,
> >>>> the current printing is not helpful for locating the problem of insufficient memory. After all,
> >>>> when memory allocation fails, the SMMU driver cannot work at a lower specification.
> >>>
> >>> I don't entirely agree. Another reason for the failure is because the driver
> >>> might be asking for a huge (or negative) allocation, in which case it might
> >>> be instructive to have a look at the actual caller, particularly if the
> >>> size is derived from hardware or firmware properties.
> >>
> >> Agreed - other than deliberately-contrived situations I don't think I've
> >> ever hit a genuine OOM, but I definitely have debugged attempts to allocate
> >> -1 of something. If the driver-specific message actually calls out the
> >> critical information, e.g. "failed to allocate %d stream table entries", it
> >> gives debugging a head start since the miscalculation is obvious, but a
> >> static message that only identifies the callsite really only saves a quick
> >> trip to scripts/faddr2line, and personally I've never found that
> >> particularly valuable.
> > 
> > So it sounds like this particular patch is fine, but the one for smmuv2
> > should leave the IRQ allocation message alone (by virtue of it printing
> > something a bit more useful -- the number of irqs).
> 
>         num_irqs = 0;
>         while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
>                 num_irqs++;
>         }
> 
> As the above code, num_irqs is calculated based on the number of dtb or acpi
> configuration items, it can't be too large. That is, there is almost zero chance
> that devm_kcalloc() will fail because num_irqs is too large.

Right, because firmware is never wrong about anything :)

Will

_______________________________________________
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

end of thread, other threads:[~2021-06-16 10:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 12:54 [PATCH 1/1] iommu/arm-smmu-v3: remove unnecessary oom message Zhen Lei
2021-06-11 10:32 ` Will Deacon
2021-06-15 11:22   ` Leizhen (ThunderTown)
2021-06-15 11:34     ` Will Deacon
2021-06-15 11:36       ` Will Deacon
2021-06-15 11:51       ` Robin Murphy
2021-06-15 11:55         ` Will Deacon
2021-06-16  1:47           ` Leizhen (ThunderTown)
2021-06-16 10:10             ` Will Deacon
2021-06-15 19:18 ` Will Deacon

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