Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp507965imu; Thu, 22 Nov 2018 00:47:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/VZDp02G3npZlauplKkRncs/D2GKLJcaKJp5XEPUubfDmHaGNeRR1DbQBw9LFAJ7ZceLUF0 X-Received: by 2002:a63:f34b:: with SMTP id t11mr9177034pgj.341.1542876444230; Thu, 22 Nov 2018 00:47:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542876444; cv=none; d=google.com; s=arc-20160816; b=ULB9MdZnxDKQMuGcXazpujz1bc7ebWk7z1J3zT0+SqQZAxfGe3OhDIKES0IhxnfT5p M/3mRmhUepWwtgnSssCdz0NOcYi4yrGNDs7v5XvBTF8sVFcv14Xgddc9dIIzYvsFm+NR 6uj42SmjGI2HuzoBcdz9j8tM+KWUdP6Jbxh+aWultTUf6GvifKK6zMmy/14d1FsRQtx0 b1CxhWzekW7RaGR3TapaSEopbDttisQz/zqFyBJLIGEGWLG533a5iZ+6C6C6Yds3Tnbg vAWKg39TUyspV4lTdbe4vDJdXNkCrK/gZMc4mNHYk7G2VjD1QzSC9K0GTseJNr6Ynrvp WMOA== 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=cRlbueyY+SE79sSVXSDyNFhJoIAEAQgj9H3E386hlQQ=; b=GFiTDLsE2xP2zK0gjrBk6GRpvmSm4KMU6Q9OuSkWiWNc6mC34NdV4Xs7cWI3CZ1jg7 PRAO+dYdT+USKj/dGetwxiruF9ZJahYKwZyZ1IfizIedn7EqX3MnFMPqTwnxB33JK39Q ywG3Xyd25NEH88ehpv3VHwWa2Rym9ROQOoZiOQ7QW7e0yhF+wJBkWpYshF1LEEhqzrP1 dFN/vhmEhDrJe1ARyZReTDsDJjQvQ90zA8AFbLTtlhPsFEnOHf4/qLRSkE1m86hQl+wh XMSEQQobyZp3AYraZv7EtCEwxqgKmJxnVF+yp3QMz3onPP7VGq9EE4weCeEHBwvJH1c/ yRSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=t9Z2iURo; 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 j35si32727715pgl.223.2018.11.22.00.47.09; Thu, 22 Nov 2018 00:47:24 -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=t9Z2iURo; 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 S2389796AbeKVIPT (ORCPT + 99 others); Thu, 22 Nov 2018 03:15:19 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:37262 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729727AbeKVIPT (ORCPT ); Thu, 22 Nov 2018 03:15:19 -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=cRlbueyY+SE79sSVXSDyNFhJoIAEAQgj9H3E386hlQQ=; b=t9Z2iURomCrPF4p9zWq4fzQyX FX59HZ3JZc1A0egL9sKHM22a/0lfmM7FkJ+NDWNMYzN9oyiU1X3VJkw0hxrkrOzFXi3k06X01cFrW t95pv2KdHvxloegBLcS+YEC9Nz8fMQi3+C8LPP//Hg6tP+Nr6+kaT45A/2vV/AnDob73/eJLnAgu7 pSM0vQtwJEKPXROU6XK0HPUbEe1RzUZgWGv2l2NIXVfkyIxIbE23pmxOcRG6IYSJ6FZHdttsTG65t 1RhOVpUzBnP0NNjLm5NRfBBc20rDjxsBNQcUk6fDk40rFQAxHfx9PjUeqwbaKJT1HokkgfL1gUIb3 m/gIyzCqw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gPaCz-00019r-PX; Wed, 21 Nov 2018 21:38:53 +0000 Date: Wed, 21 Nov 2018 13:38:53 -0800 From: Matthew Wilcox To: Christopher Lameter Cc: Nicolas Boichat , Robin Murphy , Will Deacon , Joerg Roedel , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Michal Hocko , Mel Gorman , Levin Alexander , Huaisheng Ye , Mike Rapoport , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Yong Wu , Matthias Brugger , Tomasz Figa , yingjoe.chen@mediatek.com Subject: Re: [PATCH v2 0/3] iommu/io-pgtable-arm-v7s: Use DMA32 zone for page tables Message-ID: <20181121213853.GL3065@bombadil.infradead.org> References: <20181111090341.120786-1-drinkcat@chromium.org> <0100016737801f14-84f1265d-4577-4dcf-ad57-90dbc8e0a78f-000000@email.amazonses.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0100016737801f14-84f1265d-4577-4dcf-ad57-90dbc8e0a78f-000000@email.amazonses.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 21, 2018 at 06:20:02PM +0000, Christopher Lameter wrote: > On Sun, 11 Nov 2018, 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. > > Page tables? This means you need a page frame? Why go through the slab > allocators? Because this particular architecture has sub-page-size PMD page tables. We desperately need to hoist page table allocation out of the architectures; there're a bunch of different implementations and they're mostly bad, one way or another. For each level of page table we generally have three cases: 1. single page 2. sub-page, naturally aligned 3. multiple pages, naturally aligned for 1 and 3, the page allocator will do just fine. for 2, we should have a per-MM page_frag allocator. s390 already has something like this, although it's more complicated. ppc also has something a little more complex for the cases when it's configured with a 64k page size but wants to use a 4k page table entry. I'd like x86 to be able to simply do: #define pte_alloc_one(mm, addr) page_alloc_table(mm, addr, 0) #define pmd_alloc_one(mm, addr) page_alloc_table(mm, addr, 0) #define pud_alloc_one(mm, addr) page_alloc_table(mm, addr, 0) #define p4d_alloc_one(mm, addr) page_alloc_table(mm, addr, 0) An architecture with 4k page size and needing a 16k PMD would do: #define pmd_alloc_one(mm, addr) page_alloc_table(mm, addr, 2) while an architecture with a 64k page size needing a 4k PTE would do: #define ARCH_PAGE_TABLE_FRAG #define pte_alloc_one(mm, addr) pagefrag_alloc_table(mm, addr, 4096) I haven't had time to work on this, but perhaps someone with a problem that needs fixing would like to, instead of burying yet another awful implementation away in arch/ somewhere.