Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp886027rdb; Thu, 15 Feb 2024 20:40:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXyI/tOfpcnfJ4ncvXlm7rTMzOWu43XtkAA8U2wELSW9sealrmoSGQK/wzCfKch8SkL8fEgnqtT2ZmIMCJm97IoreqjV47S/s8qNBXDzg== X-Google-Smtp-Source: AGHT+IGNE9HD+g9F/LdHfQpHHZokEcqBudr83nFvxdgi16QZeHx/VAYejjZ7IQ5BPQAv3XKf0XYw X-Received: by 2002:ac8:5d0f:0:b0:42c:8b9a:e252 with SMTP id f15-20020ac85d0f000000b0042c8b9ae252mr13682079qtx.16.1708058434462; Thu, 15 Feb 2024 20:40:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708058434; cv=pass; d=google.com; s=arc-20160816; b=lrXDU3G4rfR4SqhwxWxwtQN9YEQmHyv5w0eUpetfzBkmZmdeCb7gs0eQlFrDh/KMSb Bk55OdkrCQBVd178US/EYn1TiIHxlZ8DMWLuIsApdjrWvFLK5uMeG6v4EPP05wPp82ZA 7KEfTo3yr1y+OhBBvK9Oyjj/o/GSGmkNR+DfJMfEUj/eRTMfWlk540qbyJe5+3wMNtJj izyrAG29DxnXGubhZOS8Hgs6n0BWwWhN8b32QTcKwP9beweam+MVoopmqrrzYWsYLtg4 1OYAB8Pa39RvVbK9MkSZ1hfjHSQCnAG0dMaGBD9/nrv7twoxgg+ulfbVBg5oNuul4/6L GH5g== 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=tJw3qyqwB5irB7ns180RrgsrmonqEshZKNnid2ok9xE=; fh=WKTfvpSi3ZwnDqR6ejHBMzFn8RNJOtd2PUzsNHEkYPw=; b=0VDs52W1yQOVItg2oF/M7A9rHZaM/7AHWrVL3X77uGTQmfzy8MdJCATTM7Pb8At7ow yNX3vsl1cqqxL0p62/sxf+e3cuTPC67s5tIZJ3lCVTtYg7fCQNYm+hqka1dPYit1ztn3 aGKxJRBf2dncy5E80h0Ya9e6UCce5LLUtNLULxCn+pI30lxVRa0YNCcCkNXRRurgLhjJ dyTusfPT08M5GMfNl2j4s7cCPDk3wqQYQWAV+6T2HTqYs5TlmxSUcxBxdwuuOYi1Y/JU +aF2zAQeG1P2scDuU6j3MWT0NJdWsm46k/llz8Gq3HZ32ymXiCIk4bBHjlRHn7H+lUxl ZCQQ==; 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-68052-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68052-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 f21-20020ac85d15000000b0042c66cff88asi3283748qtx.407.2024.02.15.20.40.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 20:40:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68052-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-68052-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68052-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 3F4F71C21C1A for ; Fri, 16 Feb 2024 04:40:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B327911183; Fri, 16 Feb 2024 04:40:11 +0000 (UTC) Received: from r3-21.sinamail.sina.com.cn (r3-21.sinamail.sina.com.cn [202.108.3.21]) (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 CD4397476 for ; Fri, 16 Feb 2024 04:40:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.108.3.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708058411; cv=none; b=J6B/vlyr3DrKD8Y60VfMTIqXKzHzHYCoCiNI0/W3H16+xyAYO+TKfIehmej+q/4Vs3Ymznm0Q3TeStO2nMKSqFYL2Hb0hrLZjJmyV4fInC6XBcCi2b+JwjB+iEYSib8MFS7gMwVqPnQ58YwV7n4GQP5272VjpxsFA0tYOB9ofVk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708058411; c=relaxed/simple; bh=vDsdmX04xYR/ZsrLeCRVmexAxmdlflhNdPC7th2GmoI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fxLPvG9AAjzk+ecueqpejkSz+NQvUAj7MqZJGtde1SQrSvluqVSZcias10ZG0nDFTz6DS+WbStnk6TKe+MgKqGEJIA2gwDkl15aqmsdASvtVwNmhBU1d8k4DXalG5W3D0cphavOk11e+y/PBidS7nhfUfS3CcboHBbT/YD5QyOM= 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.21 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.23) with ESMTP id 65CEE5DD00002E06; Fri, 16 Feb 2024 12:34:39 +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: 7718657864875 X-SMAIL-UIID: 7211912AF5AB4416B16F9F67BA944DE9-20240216-123439-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 12:34:24 +0800 Message-ID: <20240216043426.1218-1-hdanton@sina.com> In-Reply-To: <875xypk6d6.wl-tiwai@suse.de> References: <20240214170720.v1.1.Ic3de2566a7fd3de8501b2f18afa9f94eadb2df0a@changeid> <20240215034528.240-1-hdanton@sina.com> <87h6iaf7di.wl-tiwai@suse.de> 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 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(). --- x/sound/core/memalloc.c +++ y/sound/core/memalloc.c @@ -540,13 +540,20 @@ static void *snd_dma_noncontig_alloc(str { struct sg_table *sgt; void *p; + gfp_t gfp = DEFAULT_GFP; #ifdef CONFIG_SND_DMA_SGBUF if (cpu_feature_enabled(X86_FEATURE_XENPV)) return snd_dma_sg_fallback_alloc(dmab, size); + /* + * Given fallback, quit allocation in case of PAGE_ALLOC_COSTLY_ORDER with + * lower orders handled by page allocator + */ + if (!get_dma_ops(dmab->dev.dev)) + gfp &= ~__GFP_RETRY_MAYFAIL; #endif - sgt = dma_alloc_noncontiguous(dmab->dev.dev, size, dmab->dev.dir, - DEFAULT_GFP, 0); + sgt = dma_alloc_noncontiguous(dmab->dev.dev, size, dmab->dev.dir, gfp, 0); + #ifdef CONFIG_SND_DMA_SGBUF if (!sgt && !get_dma_ops(dmab->dev.dev)) return snd_dma_sg_fallback_alloc(dmab, size);