Received: by 10.223.185.116 with SMTP id b49csp1078725wrg; Sun, 11 Feb 2018 04:06:16 -0800 (PST) X-Google-Smtp-Source: AH8x224ozZY1ECESDkCYNPSVWjh1k0jwSaCNmMpcqnlaWm4qYZPDZH/Wd6UBEVwkYv7OJ8SFYtnW X-Received: by 10.101.80.130 with SMTP id r2mr6860917pgp.107.1518350776167; Sun, 11 Feb 2018 04:06:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518350776; cv=none; d=google.com; s=arc-20160816; b=x8TJ4q+WoKKqjX8HKNoohGXE0svgzRXdWv5642KOhMQOShF/jrtOYC4LhU+p19ZIKZ ux+4t0ZTJtWwANEhpNYNPEdNtCN4ThvMitQohoIDLBA5z2f+0oGwmIEAqOi6iFVzK75t 7im/61YGMPD/MUr4MS4/77GJww1VqMu7ElBTNGzGLMUyQfXdLvSX5VLdlOaKiEXM4/hV MNF0Pe69j82R3DPiVnaDrQkfC2PvukP4mzcpv42wuFQKdYTSF94eA4x+SCR/8DLwgBA/ Pqs/HwWR/0VrEc92Wq+ysQRlCDj7fbW2btiNo7J1bpdIRjQk4BbqmZa6RzJGNFoAWI23 okfw== 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:dkim-signature :arc-authentication-results; bh=2FXEktc7g6qWaAHAwptvSQAac5RREhtsSsB2YitK/M4=; b=aJdAsn+U0YaqTomVojD69x86DnWq6e9nWkQHLEhLz6YapWWwy/Iw1QeVwJX6X9YDf5 8JrV2geLr1EhsS5mOSNnh99hyJgKNIdPh4BA4StwE1M8/4xNP89YCWl1pzS1Bv/f3+mN JmWinO/3ANR4uOa9Ujygps1mfKgKKCVbmYflMfPqWMfKC2U+UiWgBJEsBQBiSP7K4+/d YoJOheFtdMKLAuOZnQJ++f5HQiX0pY1NLpl5fiFqY2WFUShW5bRzlebSfZQIqnYBfxFo piBFGteue7N/XEDOT1JRb+K1g5AmBwfWCwbWOf+piPTkVWJqObO51/MGpsGy4dgFS232 L3zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=soHJ7ifw; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=deMEs2az; 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 i4-v6si4501224plk.771.2018.02.11.04.06.00; Sun, 11 Feb 2018 04:06:16 -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=casper.20170209 header.b=soHJ7ifw; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=deMEs2az; 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 S1753276AbeBKMFX (ORCPT + 99 others); Sun, 11 Feb 2018 07:05:23 -0500 Received: from casper.infradead.org ([85.118.1.10]:34550 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752691AbeBKMFV (ORCPT ); Sun, 11 Feb 2018 07:05:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=2FXEktc7g6qWaAHAwptvSQAac5RREhtsSsB2YitK/M4=; b=soHJ7ifwMFfExbyR0NNyjFgoE lhpb+8Q8NqvFvUglW6jrlhaWYgNuIht9T88l2XtLA+EXIsiG5veTY3+FFNqyfEHkYKyffxpIbNpZo PDunhXmANbN56cJ8nPFbV0AQ7YRD3q9b3+lB21EYVfOao7ubF2khy7vG49sXRZgl5IEUcYbSd0WD0 esgW7H+Um5YPuOFS/msA1tDyN/q7vvK8XzXcbMx2oIK/iH5v5ZWvQjNodjkf2olglBJdlzZN4BZCR CVEQKLv4MllumKqfeWDpV2zEne4PuQCPwIyEkYjJaf9NKXogD7uj8KvLzfuEGhw7ezi8Ug2jW64eq RX3FRKvYQ==; Received: from [198.137.202.133] (helo=bombadil.infradead.org) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ekqNh-0005T5-7F; Sun, 11 Feb 2018 12:05:17 +0000 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=2FXEktc7g6qWaAHAwptvSQAac5RREhtsSsB2YitK/M4=; b=deMEs2azTrLfUaIC/2BmYNqy+ 50b3jo1sBoT0C1nMRDcTc3OIPgIFardp7/ooJbyWVGpz7qq3ZTPjlb8i5/ppE4uxM2fMTo3nAgaS/ fKzudQaUUhq1dQ3/m4hW++hItjMqKQwW4xdhVMDNI+0RbtJata2ViJlIK9+A12gFdCSW7LnLi/cZ1 ++iUF2C3d/avFy3cGCxqCW+N6hcBuJrLIuaakTTsG/BzV481hST2St6dk+RTTlUdZNuvYpMRzSn9q cPxlW6JhmvoiUcWbkwFFuL4btaUiNKneItaaxU60vH92D+hL7QCpgUZFfbigrL1JILwV0xitIRW6o n8JzZ0Fiw==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1ekqNf-0006aO-U6; Sun, 11 Feb 2018 12:05:15 +0000 Date: Sun, 11 Feb 2018 04:05:15 -0800 From: Matthew Wilcox To: Michal Hocko Cc: Kai Heng Feng , Laura Abbott , linux-mm@kvack.org, Linux Kernel Mailing List , linux-arch@vger.kernel.org, James.Bottomley@HansenPartnership.com, davem@redhat.com Subject: Re: Regression after commit 19809c2da28a ("mm, vmalloc: use __GFP_HIGHMEM implicitly") Message-ID: <20180211120515.GB4551@bombadil.infradead.org> References: <627DA40A-D0F6-41C1-BB5A-55830FBC9800@canonical.com> <20180208130649.GA15846@bombadil.infradead.org> <20180208232004.GA21027@bombadil.infradead.org> <20180211092652.GV21609@dhcp22.suse.cz> <20180211112808.GA4551@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180211112808.GA4551@bombadil.infradead.org> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 11, 2018 at 03:28:08AM -0800, Matthew Wilcox wrote: > Now, longer-term, perhaps we should do the following: > > #ifdef CONFIG_ZONE_DMA32 > #define OPT_ZONE_DMA32 ZONE_DMA32 > #elif defined(CONFIG_64BIT) > #define OPT_ZONE_DMA OPT_ZONE_DMA > #else > #define OPT_ZONE_DMA32 ZONE_NORMAL > #endif > > Then we wouldn't need the ifdef here and could always use GFP_DMA32 > | GFP_KERNEL. Would need to audit current users and make sure they > wouldn't be broken by such a change. Argh, I forgot to say the most important thing. (For those newly invited to the party, we're talking about drivers/media, in particular drivers/media/common/saa7146/saa7146_core.c, functions saa7146_vmalloc_build_pgtable and vmalloc_to_sg) I think we're missing a function in our DMA API. These drivers don't actually need physical memory below the 4GB mark. They need DMA addresses which are below the 4GB mark. For machines with IOMMUs, this can mean no restrictions on physical memory. If we don't have an IOMMU, then a bounce buffer could be used (but would be slow) -- like the swiotlb. So we should endeavour to allocate memory below the 4GB boundary on systems with no IOMMU, but can allocate memory anywhere on systems with an IOMMU. For consistent / coherent memory, we have an allocation function. But we don't have an allocation function for streaming memory, which is what these drivers want. They also flush the DMA memory and then access the memory through a different virtual mapping, which I'm not sure is going to work well on virtually-indexed caches like SPARC and PA-RISC (maybe not MIPS either?) I think we want something like struct scatterlist *dma_alloc_sg(struct device *dev, int *nents); void dma_free_sg(struct device *dev, struct scatterlist *sg, int nents); That lets individual architectures decide where to allocate, and handle the tradeoff between allocating below 4GB and using bounce buffers. I don't have a good answer to synchronising between device-view of memory and CPU-view-through-vmalloc though. They're already calling dma_sync_*_for_cpu(); do they need to also call a new vflush(void *p, unsigned long len) function which can be a no-op on x86 and flushes the range on SPARC/PA-RISC/... ?