From: Takashi Iwai <tiwai@suse.de>
To: Hillf Danton <hdanton@sina.com>
Cc: Karthikeyan Ramasubramanian <kramasub@chromium.org>,
LKML <linux-kernel@vger.kernel.org>, Takashi Iwai <tiwai@suse.de>,
Sven van Ashbrook <svenva@chromium.org>,
Brian Geffon <bgeffon@google.com>,
linux-sound@vger.kernel.org
Subject: Re: [PATCH v1] ALSA: memalloc: Fix indefinite hang in non-iommu case
Date: Thu, 15 Feb 2024 09:40:09 +0100 [thread overview]
Message-ID: <87h6iaf7di.wl-tiwai@suse.de> (raw)
In-Reply-To: <20240215034528.240-1-hdanton@sina.com>
On Thu, 15 Feb 2024 04:45:27 +0100,
Hillf Danton wrote:
>
> On Wed, 14 Feb 2024 17:07:25 -0700 Karthikeyan Ramasubramanian <kramasub@chromium.org>
> > Before 9d8e536 ("ALSA: memalloc: Try dma_alloc_noncontiguous() at first")
> > the alsa non-contiguous allocator always called the alsa fallback
> > allocator in the non-iommu case. This allocated non-contig memory
> > consisting of progressively smaller contiguous chunks. Allocation was
> > fast due to the OR-ing in of __GFP_NORETRY.
> >
> > After 9d8e536 ("ALSA: memalloc: Try dma_alloc_noncontiguous() at first")
> > the code tries the dma non-contig allocator first, then falls back to
> > the alsa fallback allocator. In the non-iommu case, the former supports
> > only a single contiguous chunk.
> >
> > We have observed experimentally that under heavy memory fragmentation,
> > allocating a large-ish contiguous chunk with __GFP_RETRY_MAYFAIL
> > triggers an indefinite hang in the dma non-contig allocator. This has
> > high-impact, as an occurrence will trigger a device reboot, resulting in
> > loss of user state.
> >
> > Fix the non-iommu path by letting dma_alloc_noncontiguous() fail quickly
> > so it does not get stuck looking for that elusive large contiguous chunk,
> > in which case we will fall back to the alsa fallback allocator.
>
> The faster dma_alloc_noncontiguous() fails the more likely the paperover
> in 9d8e536d36e7 fails to work, so this is another case of bandaid instead
> of mitigating heavy fragmentation at the first place.
Yes, the main problem is the indefinite hang from
dma_alloc_noncontiguous().
So, is the behavior more or less same even if you pass
__GFP_RETRY_MAYFAIL to dma_alloc_noncontiguous()? Or is this flag
already implicitly set somewhere in the middle? It shouldn't hang
indefinitely, but the other impact to the system like OOM-killer
kickoff may be seen.
As of now, I'm inclined to take the suggested workaround. It'll work
in most cases. The original issue worked around by the commit
9d8e536d36e7 still remains, and we need to address differently.
thanks,
Takashi
next prev parent reply other threads:[~2024-02-15 8:40 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-15 0:07 [PATCH v1] ALSA: memalloc: Fix indefinite hang in non-iommu case Karthikeyan Ramasubramanian
2024-02-15 3:45 ` Hillf Danton
2024-02-15 8:40 ` Takashi Iwai [this message]
2024-02-15 16:07 ` Sven van Ashbrook
2024-02-15 17:03 ` Takashi Iwai
2024-02-15 19:32 ` Karthikeyan Ramasubramanian
2024-02-16 7:47 ` Takashi Iwai
2024-02-16 4:34 ` Hillf Danton
2024-02-16 8:35 ` Takashi Iwai
2024-02-16 10:18 ` Takashi Iwai
2024-02-16 12:19 ` Kai Vehmanen
2024-02-16 14:43 ` Takashi Iwai
2024-02-16 16:22 ` Sven van Ashbrook
2024-02-19 11:19 ` Takashi Iwai
2024-02-21 18:09 ` Karthikeyan Ramasubramanian
2024-02-16 10:51 ` Hillf Danton
2024-02-19 11:36 ` Stall at page allocations with __GFP_RETRY_MAYFAIL (Re: [PATCH v1] ALSA: memalloc: Fix indefinite hang in non-iommu case) Takashi Iwai
2024-02-19 11:40 ` Vlastimil Babka
2024-02-20 15:52 ` Sven van Ashbrook
2024-02-21 9:21 ` Takashi Iwai
2024-02-21 15:37 ` Sven van Ashbrook
2024-02-21 9:58 ` Vlastimil Babka
2024-02-21 15:40 ` Sven van Ashbrook
2024-02-21 11:43 ` [PATCH] mm, vmscan: prevent infinite loop for costly GFP_NOIO | __GFP_RETRY_MAYFAIL allocations Vlastimil Babka
2024-02-21 15:52 ` Sven van Ashbrook
2024-02-22 16:43 ` Karthikeyan Ramasubramanian
2024-02-26 16:09 ` Sven van Ashbrook
2024-02-26 16:45 ` Vlastimil Babka
2024-02-28 19:33 ` Karthikeyan Ramasubramanian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h6iaf7di.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=bgeffon@google.com \
--cc=hdanton@sina.com \
--cc=kramasub@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=svenva@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox