Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8966247imu; Tue, 4 Dec 2018 18:05:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/UH95Ft388hv7TFLh4AKqb0gFZJpbKHpHrUnP3yTe/LWEcMQXPlllFQRCICRYywtKSdrOfZ X-Received: by 2002:a62:528e:: with SMTP id g136mr23603087pfb.111.1543975517265; Tue, 04 Dec 2018 18:05:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543975517; cv=none; d=google.com; s=arc-20160816; b=0iTOdxwZkr9lARmqfRcCzReO9aBdbCQ5xdsePBhLdxz9sWrgyRUU4szqAE8JLACHrD 49psiIWrYjO4kI7Yko/CNgShrpSF2EnW59lyn+O8t/z4kC0eK/ghix3VCr5ADE+tSy0w /P9ujRWbEvUBaitVJi737QILejuJKdDzgz9X1nYTKGqWU6mqXszTA8DU7DPtEbcRtImF G9jtbenSlVxBPN+0fmz1mZ79uxni0WRp0ArFw9r9Fs1D1KOQt6qyMD+o19f4pjQVLWc1 ih1TwyFcfrMGsHYPML8a+3sV3NCr8cukzR9Kqgi49gFPgEHKyO+9VihpzUVf5cD9rDjw zn/Q== 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:dkim-signature; bh=i3JsgtrqAN5H4/62bquhrPpBfGUUSoPEdhvl1dbkYbs=; b=mwvA/btS5917Ng/YSIRYpCmjkox+vtpVnt3/YilsEt90BihQxAo3LMacX4yXQ3kOQm uZAcdxnNZf+MQavK6A1yJFYE5cd421WkHyzi59X+7DR/ZZ9vTq+g6MVZ9Y0rWbXhDbz2 5FI8jUYji0lySZG7/1sFdRbCEVXSiVYR84Srblp9smoa7RWXpG0HYgXsOvrPsVUBTm1R BCerZ20egay2hCVCW3rT6zTJ9XXHFnPrnyv0N8w/Av3D+QasgNUtuR1GJearf7hrS1pm divmQShe3sahi9m4h90Goyl9mMUbbcyqsbqkQ5cFq3uWpT1nfEGzWL+Ts/VepUUxU0Up vgdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=eepc9sIc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r8si16231127pgr.252.2018.12.04.18.05.00; Tue, 04 Dec 2018 18:05:17 -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=pass header.i=@chromium.org header.s=google header.b=eepc9sIc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726840AbeLECEN (ORCPT + 99 others); Tue, 4 Dec 2018 21:04:13 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:37505 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725982AbeLECEM (ORCPT ); Tue, 4 Dec 2018 21:04:12 -0500 Received: by mail-pl1-f196.google.com with SMTP id b5so9257385plr.4 for ; Tue, 04 Dec 2018 18:04:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=i3JsgtrqAN5H4/62bquhrPpBfGUUSoPEdhvl1dbkYbs=; b=eepc9sIcinu14ossbMKi6r5YOGzfTM3eRYX44Tmcrg+WP+3cog+CDlnsHvBF92H0Bv teD19ZRIfdpYf8yGAd0ZcRf7H3jJyym+Bxprtk4Vf21KZhcFOhZkwBKr94o+NaEZDTCS CTeIjO31zPInUobd4PhnZ25h/Z4WMldOfKbbQ= 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=i3JsgtrqAN5H4/62bquhrPpBfGUUSoPEdhvl1dbkYbs=; b=rgKXwkb9CRNvkF74WUpwTy5q1+vvOQSuU2KJ9/AUKjsyOCiVr+BfPttCv3wb/S3PpD 5+tfUbk2i1ECEyUWlpEhw78sLkZj6yKxNcK9qtN8szVA/dm4syZg7Y0liYNOH6V4oI/3 Hgv9WzOYZEJKxtgMme/pv3nnxGlCQ8aUq/yzwOCC+X2u6ZKijGKkEjsaUaV5EAOIebig 1TEK3YRfLeuid+MVWviOKIbP0xEAhW67C8m00lXdNmHEBiUPCiM10LAynuiHiX9BpRzy Di6/oSG2g+n8A74l3FKfvJXLYZal0kOMLjNegbS87x/ax5uWwIYK4tBiQAxes/P9w7d8 6W3A== X-Gm-Message-State: AA+aEWbCxLI208zDPNV4zyp3heY4YDkA3AWedn4+8TJNy2iV/AwmJwKg e16qzuTWfrCjUsljis/D64OgB3Jvusk01NCF7C/REA== X-Received: by 2002:a17:902:2904:: with SMTP id g4mr22170720plb.39.1543975451744; Tue, 04 Dec 2018 18:04:11 -0800 (PST) MIME-Version: 1.0 References: <20181111090341.120786-1-drinkcat@chromium.org> In-Reply-To: From: Nicolas Boichat Date: Wed, 5 Dec 2018 10:04:00 +0800 Message-ID: Subject: Re: [PATCH v2 0/3] iommu/io-pgtable-arm-v7s: Use DMA32 zone for page tables To: Vlastimil Babka Cc: Robin Murphy , Christoph Lameter , Michal Hocko , Matthias Brugger , hch@infradead.org, Matthew Wilcox , Will Deacon , Joerg Roedel , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Mel Gorman , Levin Alexander , Huaisheng Ye , Mike Rapoport , linux-arm Mailing List , iommu@lists.linux-foundation.org, lkml , linux-mm@kvack.org, Yong Wu , Tomasz Figa , yingjoe.chen@mediatek.com, Hsin-Yi Wang , Daniel Kurtz 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, Dec 4, 2018 at 10:35 PM Vlastimil Babka wrote: > > On 12/4/18 10:37 AM, Nicolas Boichat wrote: > > On Sun, Nov 11, 2018 at 5:04 PM Nicolas Boichat wrote: > >> > >> This is a follow-up to the discussion in [1], to make sure that the page > >> tables allocated by iommu/io-pgtable-arm-v7s are contained within 32-bit > >> physical address space. > >> > >> [1] https://lists.linuxfoundation.org/pipermail/iommu/2018-November/030876.html > > > > Hi everyone, > > > > Let's try to summarize here. > > > > First, we confirmed that this is a regression, and IOMMU errors happen > > on 4.19 and linux-next/master on MT8173 (elm, Acer Chromebook R13). > > The issue most likely starts from ad67f5a6545f ("arm64: replace > > ZONE_DMA with ZONE_DMA32"), i.e. 4.15, and presumably breaks a number > > of Mediatek platforms (and maybe others?). > > > > We have a few options here: > > 1. This series [2], that adds support for GFP_DMA32 slab caches, > > _without_ adding kmalloc caches (since there are no users of > > kmalloc(..., GFP_DMA32)). I think I've addressed all the comments on > > the 3 patches, and AFAICT this solution works fine. > > 2. genalloc. That works, but unless we preallocate 4MB for L2 tables > > (which is wasteful as we usually only need a handful of L2 tables), > > we'll need changes in the core (use GFP_ATOMIC) to allow allocating on > > demand, and as it stands we'd have no way to shrink the allocation. > > 3. page_frag [3]. That works fine, and the code is quite simple. One > > drawback is that fragments in partially freed pages cannot be reused > > (from limited experiments, I see that IOMMU L2 tables are rarely > > freed, so it's unlikely a whole page would get freed). But given the > > low number of L2 tables, maybe we can live with that. > > > > I think 2 is out. Any preference between 1 and 3? I think 1 makes > > better use of the memory, so that'd be my preference. But I'm probably > > missing something. > > I would prefer 1 as well. IIRC you already confirmed that alignment > requirements are not broken for custom kmem caches even in presence of > SLUB debug options (and I would say it's a bug to be fixed if they > weren't). > I just asked (and didn't get a reply I think) about your > ability to handle the GFP_ATOMIC allocation failures. They should be > rare when only single page allocations are needed for the kmem cache. > But in case they are not an option, then preallocating would be needed, > thus probably option 2. Oh, sorry, I missed your question. I don't have a full answer, but: - The allocations themselves are rare (I count a few 10s of L2 tables at most on my system, I assume we rarely have >100), and yes, we only need a single page, so the failures should be exceptional. - My change is probably not making anything worse: I assume that even with the current approach using GFP_DMA slab caches on older kernels, failures could potentially happen. I don't think we've seen those. If we are really concerned about this, maybe we'd need to modify mtk_iommu_map to not hold a spinlock (if that's possible), so we don't need to use GFP_ATOMIC. I suggest we just keep an eye on such issues, and address them if they show up (we can even revisit genalloc at that stage). Anyway, I'll clean up patches for 1 (mostly commit message changes based on the comments in the threads) and resend. Thanks, > > [2] https://patchwork.kernel.org/cover/10677529/, 3 patches > > [3] https://patchwork.codeaurora.org/patch/671639/ > > > > Thanks, > > > > Nicolas > > >