Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3473438yba; Tue, 23 Apr 2019 04:34:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqUh1GYLfteSKGTENVgaXzyXNLYuFL9NeHq9wyASyzU8LlKsnoXmQQX5LLtcrdR28uCB4l X-Received: by 2002:a62:304:: with SMTP id 4mr25464926pfd.99.1556019255695; Tue, 23 Apr 2019 04:34:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556019255; cv=none; d=google.com; s=arc-20160816; b=X/QlvYiw6g3eJL1sSwxw90k5/o8iMGcg/SXOUOSwrxRSefFwEuoL9PZr4/q0Hxo8Xj LUVBESkOqKt3vF6vWYhA7kC+qcB/CyWBSEchEB7W2/MajNC/FQYCZKd3c2UgxfBI42Cd 3M6uLs5m2JGOEcMjfXaUYgbg/mj67j6aOUUR+rWgNsZR6Oh8PqHJB1kIZmhiuyOgaihT UAPpwJhFE7myE+xIJhl801Fp8VlIoWBrm413dRZeyPFuwca11WqaOxwRH74d9tQExD1b C5UyrNGUi/28cKbJ/vJkUCb8WHys1RwNTfmXKLFSAz7sqFyuQrx+8saMkiBq+VtNCuIM heFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=vckakqp2VT0vgCQUmzztpP8C3KJNQiYgK3WCAQUigMs=; b=amd31N/OnK6/UKXh+iXkIpFpndIL83QhG/yiKv0iaDS7Oq54iU40Vte5VuZytIVz0p i3HjPsCofbuaV4gUiW1WQMpSR4o90G4S46tWjFJaTk6AwKqfSxIzd936rAVYtXSUNBMY NzAqlYMFm4EiJ1aVnm0rG46Wlmp3Obc2lTdDcdIFhQ0p3gzLmdZAhw7zWcMLiKWBI869 cIe5S4LMHw5wUVyl/cqNmBkT+zQEm5Km/irZZHA672xIEwT8Dp87tXOnVih0th++fpj3 pM3Vz2/LP4NvskF3tA3UT+Oq4dSS4pjF8lGtpxrzkmPfMBgURXpLVbS4keMwjExRYDgr 54+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8si15471478plk.392.2019.04.23.04.33.59; Tue, 23 Apr 2019 04:34:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727523AbfDWLco (ORCPT + 99 others); Tue, 23 Apr 2019 07:32:44 -0400 Received: from foss.arm.com ([217.140.101.70]:54920 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726033AbfDWLco (ORCPT ); Tue, 23 Apr 2019 07:32:44 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 006D2A78; Tue, 23 Apr 2019 04:32:44 -0700 (PDT) Received: from [10.1.196.75] (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B98383F557; Tue, 23 Apr 2019 04:32:42 -0700 (PDT) Subject: Re: [RFC] arm64: swiotlb: cma_alloc error spew To: dann frazier , Christoph Hellwig Cc: Marek Szyprowski , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Xinwei Kong References: <20190417204817.GA28897@xps13.dannf> From: Robin Murphy Message-ID: Date: Tue, 23 Apr 2019 12:32:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190417204817.GA28897@xps13.dannf> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/04/2019 21:48, dann frazier wrote: > hey, > I'm seeing an issue on a couple of arm64 systems[*] where they spew > ~10K "cma: cma_alloc: alloc failed" messages at boot. The errors are > non-fatal, and bumping up cma to a large enough size (~128M) gets rid > of them - but that seems suboptimal. Bisection shows that this started > after commit fafadcd16595 ("swiotlb: don't dip into swiotlb pool for > coherent allocations"). It looks like __dma_direct_alloc_pages() > is opportunistically using CMA memory but falls back to non-CMA if CMA > disabled or unavailable. I've demonstrated that this fallback is > indeed returning a valid pointer. So perhaps the issue is really just > the warning emission. The CMA area being full isn't necessarily an ignorable non-problem, since it means you won't be able to allocate the kind of large buffers for which CMA was intended. The question is, is it actually filling up with allocations that deserve to be there, or is this the same as I've seen on a log from a ThunderX2 system where it's getting exhausted by thousands upon thousands of trivial single page allocations? If it's the latter (CONFIG_CMA_DEBUG should help shed some light if necessary), then that does lean towards spending a bit more effort on this idea: https://lore.kernel.org/lkml/20190327080821.GB20336@lst.de/ Robin. > The following naive patch solves the problem for me - just silence the > cma errors, since it looks like a soft error. But is there a better > approach? > > [*] APM X-Gene & HiSilicon Hi1620 w/ SMMU disabled > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > index 6310ad01f915b..0324aa606c173 100644 > --- a/kernel/dma/direct.c > +++ b/kernel/dma/direct.c > @@ -112,7 +112,7 @@ struct page *__dma_direct_alloc_pages(struct device *dev, size_t size, > /* CMA can be used only in the context which permits sleeping */ > if (gfpflags_allow_blocking(gfp)) { > page = dma_alloc_from_contiguous(dev, count, page_order, > - gfp & __GFP_NOWARN); > + true); > if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) { > dma_release_from_contiguous(dev, page, count); > page = NULL; > > > >