From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from r3-18.sinamail.sina.com.cn (r3-18.sinamail.sina.com.cn [202.108.3.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 928F01EA73 for ; Fri, 16 Feb 2024 10:51:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.108.3.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708080718; cv=none; b=IurLsfRjq98rTXH8DTIrFBo5iPVFribq0b6DuaCV39TUbSatX7AZn9i2sbWfYgIfCJ/Uv64OFRqlEELIi2zdiIGpygBlYMyVEPcg55W6w0cH1KjMftpXkPT/rqQGro61Lmsk5wcpQP4VKeXryVNPORTICF7WnZLWeGyxZg1Djgs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708080718; c=relaxed/simple; bh=abbIf03lUcClSEJqyuzm6ITM51kb8SzCiL98v7qTETU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EpP9qpz3HfkwSjlxsH7kgFpkNDvACfCqfDP+fud5mfZbx0br1O4OiQuHOK1IAG70d+Gb7OtHlTnrMDnqQM4MJCc8S3oVg7Psq25NLCXcD1/Wd1rucT6d/8J2FaEbqrBoGgyDhz4nsQiaIXcnwNIjCjWyZQg3SzEzEBM+/LynEVI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=202.108.3.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([114.249.59.61]) by sina.com (10.182.253.24) with ESMTP id 65CF3E4300004350; Fri, 16 Feb 2024 18:51:49 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 8475961048607 X-SMAIL-UIID: 47A789C0333140E1AF36F219A4107BDB-20240216-185149-1 From: Hillf Danton To: Takashi Iwai Cc: Sven van Ashbrook , Karthikeyan Ramasubramanian , LKML , Brian Geffon , linux-sound@vger.kernel.org, Kai Vehmanen Subject: Re: [PATCH v1] ALSA: memalloc: Fix indefinite hang in non-iommu case Date: Fri, 16 Feb 2024 18:51:35 +0800 Message-ID: <20240216105137.1242-1-hdanton@sina.com> In-Reply-To: <87plwwiz6z.wl-tiwai@suse.de> References: <20240214170720.v1.1.Ic3de2566a7fd3de8501b2f18afa9f94eadb2df0a@changeid> <20240215034528.240-1-hdanton@sina.com> <87h6iaf7di.wl-tiwai@suse.de> <875xypk6d6.wl-tiwai@suse.de> <20240216043426.1218-1-hdanton@sina.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Fri, 16 Feb 2024 09:35:32 +0100 Takashi Iwai wrote: > On Fri, 16 Feb 2024 05:34:24 +0100, Hillf Danton wrote: > > On Thu, 15 Feb 2024 18:03:01 +0100 Takashi Iwai wrote: > > > So it sounds like that we should go back for __GFP_NORETRY in general > > > for non-zero order allocations, not only the call you changed, as > > > __GFP_RETRY_MAYFAIL doesn't guarantee the stuck. > > > > > > How about the changes like below? > > > > > > +/* default GFP bits for our allocations */ > > > +static gfp_t default_gfp(size_t size) > > > +{ > > > + /* don't allocate intensively for high-order pages */ > > > + if (size > PAGE_SIZE) > > > + return GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY; > > > + else > > > + return GFP_KERNEL | __GFP_NOWARN | __GFP_RETRY_MAYFAIL; > > > +} > > > > Looks like an overdose because both __GFP_NORETRY and __GFP_RETRY_MAYFAIL > > are checked in __alloc_pages_slowpath(). > > If the check there worked as expected, this shouldn't have been a > problem, no? > > The fact that we have to drop __GFP_RETRY_MAYFAIL indicates that the > handling there doesn't suffice -- at least for the audio operation. Dropping the retry gfp flag makes no sense without checking fallback in sound allocation context in this thread, nor checking it without checking the costly order in the page allocator. OTOH page allocator will never work in every corner case particularly where perfermance/response is expected given insanely heavy fragmentation background. Fragmentation [1] is not anything new, nor is it a cure to fiddle with a couple flags. [1] https://lore.kernel.org/lkml/20230418191313.268131-1-hannes@cmpxchg.org/