2018-04-09 10:50:00

by Jia-Ju Bai

[permalink] [raw]
Subject: [PATCH] sound: soc: intel: bxt_da7219_max98357a: Replace GFP_ATOMIC with GFP_KERNEL in broxton_audio_probe

broxton_audio_probe() is never called in atomic context.
This function is only set as ".probe" in "struct platform_driver".

Despite never getting called from atomic context,
broxton_audio_probe() calls devm_kzalloc() with GFP_ATOMIC,
which waits busily for allocation.
GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
to avoid busy waiting and improve the possibility of sucessful allocation.

This is found by a static analysis tool named DCNS written by myself.

Signed-off-by: Jia-Ju Bai <[email protected]>
---
sound/soc/intel/boards/bxt_da7219_max98357a.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c
index ce35ec7..f4361b7 100644
--- a/sound/soc/intel/boards/bxt_da7219_max98357a.c
+++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c
@@ -585,7 +585,7 @@ static int broxton_audio_probe(struct platform_device *pdev)
{
struct bxt_card_private *ctx;

- ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
+ ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return -ENOMEM;

--
1.9.1



2018-04-09 19:01:55

by Pierre-Louis Bossart

[permalink] [raw]
Subject: Re: [alsa-devel] [PATCH] sound: soc: intel: bxt_da7219_max98357a: Replace GFP_ATOMIC with GFP_KERNEL in broxton_audio_probe

On 4/9/18 5:46 AM, Jia-Ju Bai wrote:
> broxton_audio_probe() is never called in atomic context.
> This function is only set as ".probe" in "struct platform_driver".
>
> Despite never getting called from atomic context,
> broxton_audio_probe() calls devm_kzalloc() with GFP_ATOMIC,
> which waits busily for allocation.
> GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
> to avoid busy waiting and improve the possibility of sucessful allocation.

[answering for the series]
Humm, this is interesting.
If indeed we can afford to sleep then the change should be done on ALL
14 boards in sound/soc/intel/boards which follow the same code pattern.
If we cannot sleep then then none of these changes should be applied.
Liam and Vinod?

>
> This is found by a static analysis tool named DCNS written by myself.
>
> Signed-off-by: Jia-Ju Bai <[email protected]>
> ---
> sound/soc/intel/boards/bxt_da7219_max98357a.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c
> index ce35ec7..f4361b7 100644
> --- a/sound/soc/intel/boards/bxt_da7219_max98357a.c
> +++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c
> @@ -585,7 +585,7 @@ static int broxton_audio_probe(struct platform_device *pdev)
> {
> struct bxt_card_private *ctx;
>
> - ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
> + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
> if (!ctx)
> return -ENOMEM;
>
>


2018-04-09 19:43:34

by Takashi Iwai

[permalink] [raw]
Subject: Re: [alsa-devel] [PATCH] sound: soc: intel: bxt_da7219_max98357a: Replace GFP_ATOMIC with GFP_KERNEL in broxton_audio_probe

On Mon, 09 Apr 2018 20:57:43 +0200,
Pierre-Louis Bossart wrote:
>
> On 4/9/18 5:46 AM, Jia-Ju Bai wrote:
> > broxton_audio_probe() is never called in atomic context.
> > This function is only set as ".probe" in "struct platform_driver".
> >
> > Despite never getting called from atomic context,
> > broxton_audio_probe() calls devm_kzalloc() with GFP_ATOMIC,
> > which waits busily for allocation.
> > GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
> > to avoid busy waiting and improve the possibility of sucessful allocation.
>
> [answering for the series]
> Humm, this is interesting.
> If indeed we can afford to sleep then the change should be done on ALL
> 14 boards in sound/soc/intel/boards which follow the same code
> pattern.
> If we cannot sleep then then none of these changes should be applied.
> Liam and Vinod?

It must be sleepable context as it's a standard platform driver probe
callback.

And now looking at grep output, only sound/soc/intel contains so many
calls with GFP_ATOMIC. I bet that almost all can be done with
GFP_KERNEL, maybe only one or two in atom/sst would be conditionally
with GFP_ATOMIC.


thanks,

Takashi

2018-04-10 14:07:35

by Mark Brown

[permalink] [raw]
Subject: Re: [alsa-devel] [PATCH] sound: soc: intel: bxt_da7219_max98357a: Replace GFP_ATOMIC with GFP_KERNEL in broxton_audio_probe

On Mon, Apr 09, 2018 at 09:39:06PM +0200, Takashi Iwai wrote:

> It must be sleepable context as it's a standard platform driver probe
> callback.

> And now looking at grep output, only sound/soc/intel contains so many
> calls with GFP_ATOMIC. I bet that almost all can be done with
> GFP_KERNEL, maybe only one or two in atom/sst would be conditionally
> with GFP_ATOMIC.

Yeah, it's not like it'd be the first code quality problem found in the
Intel drivers.


Attachments:
(No filename) (475.00 B)
signature.asc (499.00 B)
Download all attachments

2018-04-10 14:17:25

by Vinod Koul

[permalink] [raw]
Subject: Re: [alsa-devel] [PATCH] sound: soc: intel: bxt_da7219_max98357a: Replace GFP_ATOMIC with GFP_KERNEL in broxton_audio_probe

On Mon, Apr 09, 2018 at 09:39:06PM +0200, Takashi Iwai wrote:
> On Mon, 09 Apr 2018 20:57:43 +0200,
> Pierre-Louis Bossart wrote:
> >
> > On 4/9/18 5:46 AM, Jia-Ju Bai wrote:
> > > broxton_audio_probe() is never called in atomic context.
> > > This function is only set as ".probe" in "struct platform_driver".
> > >
> > > Despite never getting called from atomic context,
> > > broxton_audio_probe() calls devm_kzalloc() with GFP_ATOMIC,
> > > which waits busily for allocation.
> > > GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
> > > to avoid busy waiting and improve the possibility of sucessful allocation.
> >
> > [answering for the series]
> > Humm, this is interesting.
> > If indeed we can afford to sleep then the change should be done on ALL
> > 14 boards in sound/soc/intel/boards which follow the same code
> > pattern.
> > If we cannot sleep then then none of these changes should be applied.
> > Liam and Vinod?
>
> It must be sleepable context as it's a standard platform driver probe
> callback.
>
> And now looking at grep output, only sound/soc/intel contains so many
> calls with GFP_ATOMIC. I bet that almost all can be done with
> GFP_KERNEL, maybe only one or two in atom/sst would be conditionally
> with GFP_ATOMIC.

Yeah I don't see many cases which would warrant atomic context, I will review
them and fix these after merge window closes. Clearly machines have no
reason for that, and I guess most are copy-paste from 1st culprit

--
~Vinod

2018-04-13 10:58:10

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] sound: soc: intel: bxt_da7219_max98357a: Replace GFP_ATOMIC with GFP_KERNEL in broxton_audio_probe

On Mon, Apr 09, 2018 at 06:46:21PM +0800, Jia-Ju Bai wrote:
> broxton_audio_probe() is never called in atomic context.
> This function is only set as ".probe" in "struct platform_driver".

Please submit patches using subject lines reflecting the style for the
subsystem. This makes it easier for people to identify relevant
patches. Look at what existing commits in the area you're changing are
doing and make sure your subject lines visually resemble what they're
doing.


Attachments:
(No filename) (483.00 B)
signature.asc (499.00 B)
Download all attachments

2018-04-13 10:58:58

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] sound: soc: intel: bxt_da7219_max98357a: Replace GFP_ATOMIC with GFP_KERNEL in broxton_audio_probe

On Fri, Apr 13, 2018 at 06:54:15PM +0800, Jia-Ju Bai wrote:

> I looked at previous related patches, and find the subject should be "ASoC:
> Intel: ...."
> I will follow it in my future patches.

Right, that's it for these thanks.

> Do I need to send V2 patches?

No, it's OK - I already applied them.


Attachments:
(No filename) (314.00 B)
signature.asc (499.00 B)
Download all attachments

2018-04-13 10:59:24

by Mark Brown

[permalink] [raw]
Subject: Applied "ASoC: intel: bxt_da7219_max98357a: Replace GFP_ATOMIC with GFP_KERNEL in broxton_audio_probe" to the asoc tree

The patch

ASoC: intel: bxt_da7219_max98357a: Replace GFP_ATOMIC with GFP_KERNEL in broxton_audio_probe

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 8f2f9215aa14904ddd9775f3b4e7af2d94189dea Mon Sep 17 00:00:00 2001
From: Jia-Ju Bai <[email protected]>
Date: Mon, 9 Apr 2018 18:46:21 +0800
Subject: [PATCH] ASoC: intel: bxt_da7219_max98357a: Replace GFP_ATOMIC with
GFP_KERNEL in broxton_audio_probe

broxton_audio_probe() is never called in atomic context.
This function is only set as ".probe" in "struct platform_driver".

Despite never getting called from atomic context,
broxton_audio_probe() calls devm_kzalloc() with GFP_ATOMIC,
which waits busily for allocation.
GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
to avoid busy waiting and improve the possibility of sucessful allocation.

This is found by a static analysis tool named DCNS written by myself.

Signed-off-by: Jia-Ju Bai <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
sound/soc/intel/boards/bxt_da7219_max98357a.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c
index 668c0934e942..40eb979d5ac1 100644
--- a/sound/soc/intel/boards/bxt_da7219_max98357a.c
+++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c
@@ -571,7 +571,7 @@ static int broxton_audio_probe(struct platform_device *pdev)
{
struct bxt_card_private *ctx;

- ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
+ ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return -ENOMEM;

--
2.17.0


2018-04-13 11:50:06

by Jia-Ju Bai

[permalink] [raw]
Subject: Re: [PATCH] sound: soc: intel: bxt_da7219_max98357a: Replace GFP_ATOMIC with GFP_KERNEL in broxton_audio_probe



On 2018/4/13 18:41, Mark Brown wrote:
> On Mon, Apr 09, 2018 at 06:46:21PM +0800, Jia-Ju Bai wrote:
>> broxton_audio_probe() is never called in atomic context.
>> This function is only set as ".probe" in "struct platform_driver".
> Please submit patches using subject lines reflecting the style for the
> subsystem. This makes it easier for people to identify relevant
> patches. Look at what existing commits in the area you're changing are
> doing and make sure your subject lines visually resemble what they're
> doing.

Oh, sorry for my improper subjects.
Thanks for your very helpful advice :)
I looked at previous related patches, and find the subject should be
"ASoC: Intel: ...."
I will follow it in my future patches.

Do I need to send V2 patches?


Best wishes,
Jia-Ju Bai

2018-04-13 12:16:36

by Mark Brown

[permalink] [raw]
Subject: Applied "ASoC: intel: bxt_da7219_max98357a: Replace GFP_ATOMIC with GFP_KERNEL in broxton_audio_probe" to the asoc tree

The patch

ASoC: intel: bxt_da7219_max98357a: Replace GFP_ATOMIC with GFP_KERNEL in broxton_audio_probe

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 8f2f9215aa14904ddd9775f3b4e7af2d94189dea Mon Sep 17 00:00:00 2001
From: Jia-Ju Bai <[email protected]>
Date: Mon, 9 Apr 2018 18:46:21 +0800
Subject: [PATCH] ASoC: intel: bxt_da7219_max98357a: Replace GFP_ATOMIC with
GFP_KERNEL in broxton_audio_probe

broxton_audio_probe() is never called in atomic context.
This function is only set as ".probe" in "struct platform_driver".

Despite never getting called from atomic context,
broxton_audio_probe() calls devm_kzalloc() with GFP_ATOMIC,
which waits busily for allocation.
GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
to avoid busy waiting and improve the possibility of sucessful allocation.

This is found by a static analysis tool named DCNS written by myself.

Signed-off-by: Jia-Ju Bai <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
sound/soc/intel/boards/bxt_da7219_max98357a.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c
index 668c0934e942..40eb979d5ac1 100644
--- a/sound/soc/intel/boards/bxt_da7219_max98357a.c
+++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c
@@ -571,7 +571,7 @@ static int broxton_audio_probe(struct platform_device *pdev)
{
struct bxt_card_private *ctx;

- ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
+ ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return -ENOMEM;

--
2.17.0