Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp223451rdb; Wed, 14 Feb 2024 19:46:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUyu465yH4rsWwFmgMMzIm/yM/eHwYDQ13m50bshaZ3ja92ODsOKbcdk3OQYt4kzJMgwx3ngvWdnoC85eenUb8dS4gbgiPnr8O4YJkx2w== X-Google-Smtp-Source: AGHT+IGGEdYP3wBN6qFkh/cyErlk0tFXX2PSgPNeb0cA2Qvg8zQj3nKG7+Ur2gc1mwj18mtJrDHe X-Received: by 2002:a05:622a:103:b0:42d:ca95:5125 with SMTP id u3-20020a05622a010300b0042dca955125mr1006172qtw.35.1707968799418; Wed, 14 Feb 2024 19:46:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707968799; cv=pass; d=google.com; s=arc-20160816; b=rx8po/7ZktZ5kFTd2Lydy4KSiavuhmVufowgYVe4r5aRiG//99avGgCyPL1sPx5Afu 7swWepsJPlUYX8oTmzB1NHxrSkgk588kwooydhFj7hd/Q+YrwGUX5tVMJaNnEs1wO7SX 9Xl+SLSFt+vwuDtC+lqe2hvtpQZfvtQkzXu85c/7jCZNK7zHkg/u4kOVlHCapQaGB5La DZGrwTndBsviygiVcmFRfOVFNY4/nLPRwvjTOj1hH0EYv5OQRRx/PHOkWLl4M+KM/oHP owpixautkdZ3DwgAKFdXP19aettfctdEWi1xgfywPPOqfMfmP25FTvTqdiCQx3clpnMZ LNGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=TDjGGCufOf6/TZtUOdtP7n51wMhjmoW18TsSmXOGPs8=; fh=+SF/lNqPp8Eox15XFhvOpxXePUuGY1Pu8QTVQHsYZ7I=; b=V9lwAhi/lE5MTFtlJhtawQfw1Q/gAUTUJueA4lxXf0Zow9BYT88JImGx3T2w76SP7J ilB/+LSv0NYfhAPvlT3AepP37OI1eCAHel+SP3+FlsE3rbJB/7c3LOSjE2uI2LTf7wHR 49VnKI/QbWV1eYqYWOp+jvEN7HFpfHSBSYpqTWb7wgaOYc83SbkHdSoK6g6F5A/aU6Be g+EF9IDU3HjvOtWLAd8Lg8rs7cNVa6vOeZhebOQDwc7mrljN4H729ywkqjZ0jH0yxWYc mg5Ps0886vvTqzHzn3Mr20/WUWfiTEsXuayyUfkkc1hV/TEbL79PhX53i74hyFa7LBaQ dIPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-66271-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66271-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d8-20020ac847c8000000b0042db60cb428si453935qtr.576.2024.02.14.19.46.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 19:46:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66271-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-66271-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66271-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 942111C29FB2 for ; Thu, 15 Feb 2024 03:45:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC5F47475; Thu, 15 Feb 2024 03:45:54 +0000 (UTC) Received: from mail3-163.sinamail.sina.com.cn (mail3-163.sinamail.sina.com.cn [202.108.3.163]) (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 3A31C6FB1 for ; Thu, 15 Feb 2024 03:45:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.108.3.163 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707968754; cv=none; b=uW6W95CW6a1Y/6HPU5ofOAbt6XfeoyAp/+sM823VAaVWZo41VSp1j39pwVhqp0+ETUcXnhH3rQotlIarrOMo5KZL0OCTu7PR6F+22fuJFHkgDJNDD+ReAAkRYRBeAdrK3/lE943luPeJHrmfOHidrX/t/vQwqs45hOS58JqiGvQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707968754; c=relaxed/simple; bh=Pr7MlXtPo86/mwM5YDwntO9BuKQlpseSIwMVWLpanLc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=blXlIEKfzTYqY6CNUaRfQqP2wBwNK2tpH7bwYj0AabcTrg9RcB16uuZb9sjMKHnAQN0/L4cNURNDrgR33FqB0/GxrHqQLjN2hqzMLTsUr/KmTnjMmZMsWIQP1nXmX4PqYVV9id4X6KLWtPp0iHguk7YZwa/iccx3aJeah6DURO8= 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.163 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.22) with ESMTP id 65CD88E200003AAC; Thu, 15 Feb 2024 11:45:42 +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: 2817766816217 X-SMAIL-UIID: 31BAFFEE8DCD4C388D6388F22D028CF1-20240215-114542-1 From: Hillf Danton To: Karthikeyan Ramasubramanian Cc: LKML , Takashi Iwai , Sven van Ashbrook , Brian Geffon , linux-sound@vger.kernel.org Subject: Re: [PATCH v1] ALSA: memalloc: Fix indefinite hang in non-iommu case Date: Thu, 15 Feb 2024 11:45:27 +0800 Message-ID: <20240215034528.240-1-hdanton@sina.com> In-Reply-To: <20240214170720.v1.1.Ic3de2566a7fd3de8501b2f18afa9f94eadb2df0a@changeid> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Wed, 14 Feb 2024 17:07:25 -0700 Karthikeyan Ramasubramanian > 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.