Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8310490imu; Tue, 4 Dec 2018 06:28:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/UKU5AY9zWpLkPRnte+IdBfI9ZyuKvfc1zoCn/tg5aRwas0vgRzeUZPj310HzMR7kN2o90I X-Received: by 2002:a63:9c1a:: with SMTP id f26mr17080427pge.381.1543933690456; Tue, 04 Dec 2018 06:28:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543933690; cv=none; d=google.com; s=arc-20160816; b=NrcLCnO+8MS2kKkz3ehWQ8JdfzbOBHJlg+o4RaPgGdgddAp9WyC6nLxhTkCdXx2aqv gagf78ymHyekKWmCvGaQtSNfw2ime0kQDD3aHC4nFFNR2eN5PIuIdoE9OQnoW+MHNC4/ JdQ5XKBC97wgIh0P5HMtZLvn7SXclp/uggpvB6KREb+CIGv9VKz/Qfwd4/gC/51/uVtm fe8V9oesjK8OuggPDH1aDUOk8fXIgI9woDvBimWpRfhCJyo9T3gLoY5hUpywEYCQy7xa ObQBHPJ4/pOO7t2O2gLid2uY/s73iHb/0p9s2RpDdocjRkD9mVHAPJcoMk5v4SOvDlQE 1GMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=z3uC1vmpTJVoFxYiRbCk3Per90fbpG1AtA+1J7CklsE=; b=tPgH26hXj8h+034zaxCsW/dPcGIjIG4wmVpHNX+2YJUDG3Ri8dMZfd70+uxeuvSoAN YbhjRvIshtk65arM8v6iRaXpoPxh0f7ITiqHIanNdvZdMIC68tAdY8V02S2YGAUBV96L h+O4bR8iahyR5qMk1arKCmL0f0V/b2XFTELjUaukh09i//ODvcFfugRwuMCc6uxMnRsu XdyipBS5V5r4m8DOt/frW+JuR9kHyYBgSp8aShK63oJ9qP7rHqezIzsSijBuI+lM00rj F+YmaOi3XWv2Zv9rXZOXDUKK5I+9xE4mStIbSZttR5GMgnAbCxdWE6R0wdtVEDsjxpE2 95pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=c9SAdgNx; 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 t16si14814704pfk.139.2018.12.04.06.27.55; Tue, 04 Dec 2018 06:28:10 -0800 (PST) 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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=c9SAdgNx; 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 S1726590AbeLDOZi (ORCPT + 99 others); Tue, 4 Dec 2018 09:25:38 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:47778 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725956AbeLDOZh (ORCPT ); Tue, 4 Dec 2018 09:25:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=z3uC1vmpTJVoFxYiRbCk3Per90fbpG1AtA+1J7CklsE=; b=c9SAdgNxkPJ+q1AftrqRvETBZ lwtCroYjl6onGKXLUUHYeNtUNNPq7iPpBdX8491dzW0tyF3FcHCpzkefyk6q5N/CyCNap+T8xiUMs cVoN91fochJQ68q/XYJEiH7tobDNl3a+9oHsQID4IcO5MIkfPtWPs1ZQaO2gVieQD/+KqtauD+YvH hxFeqJigOC3+CnLs8JNsKC3pUhiJSBS3fH1lQDIGfoDQyV+JQ4Oiqup//5QOfOEUqHqh9Bg/ePqYj tdCdA5TPoBgjxK8iqAc9T0xIAn5cfkrNhROIOkBoL+U8mRvpGfW08JDUKbismSOLTzLxwyLp+H1bh 1xdvkSegA==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUBdi-0002rA-TS; Tue, 04 Dec 2018 14:25:30 +0000 Date: Tue, 4 Dec 2018 06:25:30 -0800 From: Christoph Hellwig To: Nicolas Boichat Cc: Robin Murphy , Will Deacon , Joerg Roedel , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Christoph Lameter , Vlastimil Babka , Michal Hocko , linux-mm@kvack.org, Yong Wu , Matthias Brugger , Tomasz Figa , yingjoe.chen@mediatek.com, hch@infradead.org, Matthew Wilcox Subject: Re: [PATCH v3, RFC] iommu/io-pgtable-arm-v7s: Use page_frag to request DMA32 memory Message-ID: <20181204142530.GA2917@infradead.org> References: <20181204082300.95106-1-drinkcat@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181204082300.95106-1-drinkcat@chromium.org> User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 04, 2018 at 04:23:00PM +0800, Nicolas Boichat wrote: > IOMMUs using ARMv7 short-descriptor format require page tables > (level 1 and 2) to be allocated within the first 4GB of RAM, even > on 64-bit systems. > > For level 1/2 tables, ensure GFP_DMA32 is used if CONFIG_ZONE_DMA32 > is defined (e.g. on arm64 platforms). > > For level 2 tables (1 KB), we use page_frag to allocate these pages, > as we cannot directly use kmalloc (no slab cache for GFP_DMA32) or > kmem_cache (mm/ code treats GFP_DMA32 as an invalid flag). > > One downside is that we only free the allocated page if all the > 4 fragments (4 IOMMU L2 tables) are freed, but given that we > usually only allocate limited number of IOMMU L2 tables, this > should not have too much impact on memory usage: In the absolute > worst case (4096 L2 page tables, each on their own 4K page), > we would use 16 MB of memory for 4 MB of L2 tables. I think this needs to be documemented in the code. That is move the explanation about into a comment in the code.