Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3199185imu; Fri, 23 Nov 2018 23:56:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/W6KrtvT5vpgVxmJS7suBfwWOW+tldbkRcZBzjM8bHCppZy+KNt4aOsQJMiLndwAm4F0rPw X-Received: by 2002:a17:902:680f:: with SMTP id h15mr18647057plk.40.1543046194355; Fri, 23 Nov 2018 23:56:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543046194; cv=none; d=google.com; s=arc-20160816; b=x3dy+0LOeD0OurPaT/FEYaI6nhtTqxVG2WjmSajj2TM1kNq6McpqUsBYtEtfryFwJV QRorc+p1K0w1y+RSHLRsSOphn/sZsqW4CElCZdKakAL6nj9SEWurSSDA5ZZb82ehdH20 Mji7pevDjOw8U7BWiur/9tkAqv+I47oy1sScUuEsjWqPJYqOqLMCOyc9FgdLk9Ych7+b m8YFaAHF1aIN5TiO1ujgFrRDvWuLPJqOyqCbdjvp6e8bsvt7EXSKIqE4IuKcpxiRrzFw iFNPcyZJFVzGBIjwb7guGlD5MdXGCCrHiyqFE6n/bftLxGjF17h3KDm9EO0UJaRRdiCO PZZQ== 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=MC8eyd9+40cowj0IGrTrY5vh8damXSWR43TkM3I5PnU=; b=HppVPsXHhNzj/i3BSXBk4d3azZ2C/Cuh3dA4DDWUV2MLf1YDjmnTDf0aVgCNX1/73c 5eCIF51swNTT36VQvvO6Suw8apWCRQiZBT2CGlq31BrMYyurWd17lQfGZG/daiT2DO8l 64K6fO+b4MJsRx4juRYI+8+OUtYSSNUHBfMDPWw4XkIFS+J8LvsQxY3XrCpmFTdH6zal 9+dxDEiN8h7qtQlKMOeD5gSHbDnM1V0aljLPmwi2Hku7Tn0VdsbUPzUy3SSunFNaIUN1 edjnE2VIKzpsId7MoSpruiKATRq45T9w3zruE2LFvPPzgXkuDhXq66jIWrufyXOtQA40 XyAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DfhpuqJ0; 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 f16si20899967pgg.173.2018.11.23.23.56.20; Fri, 23 Nov 2018 23:56:34 -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=DfhpuqJ0; 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 S2393064AbeKWNrI (ORCPT + 99 others); Fri, 23 Nov 2018 08:47:08 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:33008 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731997AbeKWNrI (ORCPT ); Fri, 23 Nov 2018 08:47:08 -0500 Received: by mail-pf1-f194.google.com with SMTP id c123so1992678pfb.0 for ; Thu, 22 Nov 2018 19:04:47 -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=MC8eyd9+40cowj0IGrTrY5vh8damXSWR43TkM3I5PnU=; b=DfhpuqJ0Djtw7qrso3K/tvPnPFx9NmjmCRkK+BpDEzKipyhmBzrKibCCk1D1tEkIGF Sfhrp+UXd5UBfUqgfNDF2Jaus4JvXQ4nEghAlQg70GZaV5pHpfMAZuU5NvsjhrFbu9AR VoUdvUJeItgdoVCbesChfwvlmKUCuTH5qMTq8= 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=MC8eyd9+40cowj0IGrTrY5vh8damXSWR43TkM3I5PnU=; b=qcbEwwCHparF05Zpg0RpIBAeFQGC4bVbuf5mtbh7xFrCNhcknWSvpOI2MP7x3Pp3O+ guGxb9Vn9Avm+B8n4ZbLIbbLoHMQCayyLB0d3Ka9O5gcqAIAzo8Nr8z/xjzTTft3AmUq AIAfQBL7RL7dsmM3mThYMUVj6jjiFqO+/ZLUkdeRQkNeZ3LOQOH4KRDFWyaWq2PiZ+MA HLL3kt0R7U9o+IiDUAUe47RPBXPcDkv5sA2GLVx6jGH4Hkt6jGX2KPA+b5f0R38O2CTA LIhPSLvYFjo+G9t5PFFbZFEf+gxn24sdAdhB3dfH7FFgUEbHgFg684EYSK+nL74qUWd1 acQg== X-Gm-Message-State: AA+aEWbu6bvYn1xp5A8VB1kvFie6iNJ6Y1mO7OS5Hx/L5YDARGzRVmaC gW2ICPH1ErJkXqphzfK2bcIvQjYSIPFYIf15yp81xA== X-Received: by 2002:a63:6645:: with SMTP id a66mr12169337pgc.390.1542942287344; Thu, 22 Nov 2018 19:04:47 -0800 (PST) MIME-Version: 1.0 References: <20181111090341.120786-1-drinkcat@chromium.org> <0100016737801f14-84f1265d-4577-4dcf-ad57-90dbc8e0a78f-000000@email.amazonses.com> <20181121213853.GL3065@bombadil.infradead.org> <20181122082336.GA2049@infradead.org> In-Reply-To: <20181122082336.GA2049@infradead.org> From: Nicolas Boichat Date: Fri, 23 Nov 2018 11:04:36 +0800 Message-ID: Subject: Re: [PATCH v2 0/3] iommu/io-pgtable-arm-v7s: Use DMA32 zone for page tables To: hch@infradead.org Cc: Robin Murphy , willy@infradead.org, Christoph Lameter , Levin Alexander , Mike Rapoport , Huaisheng Ye , Tomasz Figa , Will Deacon , lkml , Pekka Enberg , linux-mm@kvack.org, iommu@lists.linux-foundation.org, Michal Hocko , linux-arm Mailing List , David Rientjes , Matthias Brugger , yingjoe.chen@mediatek.com, Joonsoo Kim , Mel Gorman , Andrew Morton , Vlastimil Babka 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 Thu, Nov 22, 2018 at 4:23 PM Christoph Hellwig wrote: > > On Wed, Nov 21, 2018 at 10:26:26PM +0000, Robin Murphy wrote: > > TBH, if this DMA32 stuff is going to be contentious we could possibly just > > rip out the offending kmem_cache - it seemed like good practice for the > > use-case, but provided kzalloc(SZ_1K, gfp | GFP_DMA32) can be relied upon to > > give the same 1KB alignment and chance of succeeding as the equivalent > > kmem_cache_alloc(), then we could quite easily make do with that instead. > > Neither is the slab support for kmalloc, not do kmalloc allocations > have useful alignment apparently (at least if you use slub debug). > > But I do agree with the sentiment of not wanting to spread GFP_DMA32 > futher into the slab allocator. > > I think you want a simple genalloc allocator for this rather special > use case. So I had a look at genalloc, we'd need to add pre-allocated memory using gen_pool_add [1]. There can be up to 4096 L2 page tables, so we may need to pre-allocate 4MB of memory (1KB per L2 page table). We could add chunks on demand, but then it'd be difficult to free them up (genalloc does not have a "gen_pool_remove" call). So basically if the full 4MB end up being requested, we'd be stuck with that until the iommu domain is freed (on the arm64 Mediatek platforms I looked at, there is only one iommu domain, and it never gets freed). page_frag would at least have a chance to reclaim those pages (if I understand Christoph's statement correctly) Robin: Do you have some ideas of the lifetime/usage of L2 tables? If they are usually few of them, or if they don't get reclaimed easily, some on demand genalloc allocation would be ok (or even 4MB allocation on init, if we're willing to take that hit). If they get allocated and freed together, maybe page_frag is a better option? Thanks, [1] https://www.kernel.org/doc/html/v4.19/core-api/genalloc.html