Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3880836yba; Tue, 23 Apr 2019 11:06:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFL+o3vk4UsOXbmtu3Jl7Qe+lQbiml5Cw2RNYQ17/ufdOAcZgEfCCFtzYhI70n8gSF8r4y X-Received: by 2002:a63:fb01:: with SMTP id o1mr15793505pgh.135.1556042802365; Tue, 23 Apr 2019 11:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556042802; cv=none; d=google.com; s=arc-20160816; b=Mc1NLDsj11rF1htZOslQHwV4mChr5NJxbJgeNcRP80+SENK12mls9Oayg2sLLiPe+7 vUSzzW8tqm9+QgeLpXCGPyU/nz1h2KHaeyfUO7BvC2BGCZKymWfLqY9LEBKIKlvUUVrT f2qxSjBdtJ8cnH3P4Vhk7mmfTmbQmO0YrGLnmFjMGC1jnYApVY2rtYPCijxDCcGazRuh jV16l9QydPEjsTmrCPzkNcLjGihiU5d64vSRdIpCDfWXZp1B3AJwfZDLDERMVkKal1SI ffvbMrcxjAeWjhv71ggTVezwh3j9KkCHIKUskt4t+wTJMxUPfzFdKL11L8DXh3L3vUJ0 3AMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=aTmuaA1oe/FK4WqytYnAJNG23063bz707sGkM242IOI=; b=Wib2wuY6zCaj1+O46ACKLNF5W7HEdyXlt/db2ju64pKQQHYlRiGnmUFDDzHL6jzP4/ z/EFYs1jV+hsuXuKL33W/q5zjtR8ITC67o8Un8ACHvT6YGgv9jR7idVD9Lp15GNrG0SL 7o4AYABRhFSit41myWifwIH3TqqvThF5tQaIiiNxnCiZN4AUnR6Bzg8BptWQkJTEIj4J jMDW7/kequsgR+dXX4DyA9/zIom1GmwnlFONbksFbScmxUtlbulFqyDeDnKfFL+6Sa92 O80/QopaGqiMXStAJLOvyRj4MeHLRnhTSphRUIDGG7PO98LVBAuMlDNC7BNupbszX3c1 2CjA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x7si15080985pgg.565.2019.04.23.11.06.26; Tue, 23 Apr 2019 11:06:42 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728715AbfDWSDd (ORCPT + 99 others); Tue, 23 Apr 2019 14:03:33 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:45194 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727745AbfDWSDc (ORCPT ); Tue, 23 Apr 2019 14:03:32 -0400 Received: from mail-ot1-f70.google.com ([209.85.210.70]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hIzlT-0006to-Ac for linux-kernel@vger.kernel.org; Tue, 23 Apr 2019 18:03:31 +0000 Received: by mail-ot1-f70.google.com with SMTP id q23so9456199otk.10 for ; Tue, 23 Apr 2019 11:03:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aTmuaA1oe/FK4WqytYnAJNG23063bz707sGkM242IOI=; b=TZpenyfzPJnfW5OlHvf147VO+VQNoBhjU1kVv3Kpt4vbwj95dQe75DujjAO0q2EtBF FOCmylxRpVNbBpAFP1gOSOgkRM/uCgW/AQApuy4rYgObeziO+0xKPGqLnEwUevDZKDnZ 91kw82DYbaLkSljqNmkHteYFMV7LWwrBBHrfHLKSVBIT6Y584yVkCsX9QyKWxob27xhv 79vJT3cQGS9OYJcDGRcFgHWCJKl3VQHtHnAfCUQz1koXMU69H4UpdmAgZkTxD9y6u76d 1doNhY2VF8g4zc8fmF2ouHHzX4RRMu129Giunst0CB0IasGZ8Kq4VXJBz6zKrrfsT8zY 30eQ== X-Gm-Message-State: APjAAAWjdmjGs/ggWn6jcXiIQvq0o0zW9WtElwFWA8NDWdW+a4uoMLjQ DYlYuy/aZe/RwRfSMHaHXueWJtdgJr3dqfmsZDkAmezweXw4MZlqoVdLtdGuOvVOwYBrTn3bL6T +VeNRgI6UAyz7nKn+meRJs70pVy6T5OTh3VvwgsUjgH64YLeeOtK2I35j2A== X-Received: by 2002:aca:b8c4:: with SMTP id i187mr2650234oif.6.1556042610175; Tue, 23 Apr 2019 11:03:30 -0700 (PDT) X-Received: by 2002:aca:b8c4:: with SMTP id i187mr2650207oif.6.1556042609663; Tue, 23 Apr 2019 11:03:29 -0700 (PDT) MIME-Version: 1.0 References: <20190417204817.GA28897@xps13.dannf> In-Reply-To: From: dann frazier Date: Tue, 23 Apr 2019 12:03:18 -0600 Message-ID: Subject: Re: [RFC] arm64: swiotlb: cma_alloc error spew To: Robin Murphy Cc: Christoph Hellwig , Marek Szyprowski , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel , Xinwei Kong Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 23, 2019 at 5:32 AM Robin Murphy wrote: > > 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), Appears so. Here's a histogram of count/size w/ a cma= large enough to avoid failures: $ dmesg | grep "cma: cma_alloc(cma" | sed -r 's/.*count ([0-9]+)\,.*/\1/' | sort -n | uniq -c 2062 1 32 2 266 8 2 24 4 32 256 33 7 64 2 128 2 1024 -dann > 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; > > > > > > > >