Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9105783imu; Tue, 4 Dec 2018 21:53:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/X/SII1puR/4mYyVOpqgD6++TjePKGrFGpEsTiLx0X+3frrGdQwOaqHtxEG26odLx5obywD X-Received: by 2002:a63:5346:: with SMTP id t6mr19767939pgl.40.1543989215252; Tue, 04 Dec 2018 21:53:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543989215; cv=none; d=google.com; s=arc-20160816; b=QsoXogogjbvqH8sQJtvravi2s1HG3JGN8fPFzwuncW5fL71OvPTGA8vxFgAgNbz08s c4BrVfXLDBi4zDDq8TMYLrFo80vGDxXa/FblvYEO15BeA8/6MKZkWQxbB7wSNa8yUurV z40G5UtlJUGRbPxU5YV8IhNGk0TcNSyZ3des0Y3+0ZQdIcExLa5c/MHMe4GsoEr7+PRt MCQMSik+IoWrZOhy1Ui44ZfxiRE/9nL/+8n4w3O5LO5TP82zmHsnO1q/B8ex38SfQNZM DQeOW2H28i87eoJDX2KG5sKKddCIOekxOeirof+9+Rz87HrWhnMqHgGOxhzXoxYnZu2F GDFg== 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=+7B9CTpvYp8u/sULrhl76RfRou0xrjyBsdRlbjKE8Ho=; b=Mnq7if853xjSUEM8GPwosVt3Z7wN2oX4Sr4IgFd7NREUpPVyDQ0RJlDsSzGA335R7y 7Et1aUKQMnMjGDndFUySxxcGC+pyiCVhl4pnpcxJAeGYyCYGwizjU6KE44QvnjoSF0ac kkorOYdt57tfz+wnev+XIPpxZDbAZ/Z6DiPxLHkepNQryFuGEfudpmLNXuRk+MDT8Pcr 7RSs5B5y9NoKgURRx3lwdX8GBx7znnHXPmKPrrKRB5PN0aE5hqxm8UVpTFA8E1nkDpzo V9WwJ7a40x9mGOPHaCUbNICiY9zOWYzEZkeSU9Bic+2N6Q4GINVSXCBymHtYiPgn13pb z5hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CwgbkZCA; 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 n5si19134350plp.294.2018.12.04.21.53.19; Tue, 04 Dec 2018 21:53:35 -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=CwgbkZCA; 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 S1727021AbeLEFv3 (ORCPT + 99 others); Wed, 5 Dec 2018 00:51:29 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42866 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbeLEFv3 (ORCPT ); Wed, 5 Dec 2018 00:51:29 -0500 Received: by mail-pg1-f195.google.com with SMTP id d72so8492560pga.9 for ; Tue, 04 Dec 2018 21:51:28 -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=+7B9CTpvYp8u/sULrhl76RfRou0xrjyBsdRlbjKE8Ho=; b=CwgbkZCAdv5iXvavxspbZTlrvci7haOVEDqSV54ieGnR8NmMDEk5kOiEihAwY2EDXR GslGbiUVCkW9dDlHGAxZFUE9wLWC1s9nS4QR+tXos15jBfJGk2BkGPvNtR7OqbCFfHZQ 9gRsdtV15ckj7dBeNrIZ7mKV3SnEr6Bo9DJvs= 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=+7B9CTpvYp8u/sULrhl76RfRou0xrjyBsdRlbjKE8Ho=; b=d/60u/CHTUpQR+72b8nfmvf/c0S+t8nalrx0WDkP9gGUN4+c3F4S11c5EGUzgVNBPT pjGS3IexTXxBwP3raohMSxs4pvCo5ebRGPZEbwlAHqjxyLLuX8hXEE8DplX+Jx2MVv4d ZW1qphoAL62jNW8u+ZbrCl/et1MzEIYReM+P+TXguUtkxpZ0gJBAl7/XjOAKe+o4FQjT kibFrSidvBnoKo/jphCKzs5uxVcCXVwwrQJCdISwqBoY3u8OMqQ8+Pb27S6gn5sM1S4X E/XIW4YG7ZP46AjfTnNYOXb76EBeSC4Tor4Z5QQAnPG7bgLtRnE2VYzIYc3lo28ctO/4 RM5w== X-Gm-Message-State: AA+aEWY7XDf+0Xy3rOZ/HLQvt0lONI4x4TJ4UjfC4nAyA3ALsW5d1CIT TIb/a0ZF7IFhZf1Q8Z90TQY5B2J1k5qUIUlWoF/jTw== X-Received: by 2002:a63:7cf:: with SMTP id 198mr19694633pgh.129.1543989088019; Tue, 04 Dec 2018 21:51:28 -0800 (PST) MIME-Version: 1.0 References: <20181111090341.120786-1-drinkcat@chromium.org> In-Reply-To: From: Nicolas Boichat Date: Wed, 5 Dec 2018 13:51:16 +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 Wed, Dec 5, 2018 at 10:04 AM Nicolas Boichat wrote: > > 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. Done here: https://patchwork.kernel.org/cover/10713019/ . > Thanks, > > > > [2] https://patchwork.kernel.org/cover/10677529/, 3 patches > > > [3] https://patchwork.codeaurora.org/patch/671639/ > > > > > > Thanks, > > > > > > Nicolas > > > > >