Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp584513imu; Fri, 9 Nov 2018 02:44:35 -0800 (PST) X-Google-Smtp-Source: AJdET5cycrVTR5IMIFuUt6IsQ9IdTnRGVZEX/VvxiwQrDPFBtNCtle+Heremm/SX7EWXT5PU7W7S X-Received: by 2002:a63:f515:: with SMTP id w21mr6912822pgh.220.1541760275407; Fri, 09 Nov 2018 02:44:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541760275; cv=none; d=google.com; s=arc-20160816; b=QZWErc7661FiVaOYCAS0OigvL/RRgHshCpMDHw5stjRGSLekamTFSJBEZ9RoymrrM4 3vH+E6C+ZQ9rwW8gUAEOxfdNLkPJQXJdOXb8PvGp5H7RcOMnEdQ2KROk122TYPnnIRGn OdrGct7iaUOal89O7ldsfAY/3uxXYYIwLjePWjTgQrICv2xftYRFpTCqIY3bhekfHK8V ZJJuFsLuXxvU+A7xIjkD+ePE97FaVeG4vPnFnH1WuUjXhxtcIxzvRWJCWO5rR1quwTOw 0BpqXmx4q78BPjGII8omifx1XI1pyqu2q8MzJFltNop9WgvGH49LXrxanmTrYQ+lSpt0 xboA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=OIuQztU1FXHh0QkQS0AlhRNuxdy+lRseeCf5f0nxU30=; b=m7YtuWZlSUT2/W+v/9YnStv+3oAI9t3EOY7WtKDs95M1fUw+8kP4gYN0s0OqQNr3H5 WfrS5Do17f7XHDlVESOfp4XHEGZzapEBUMzDXp9OKex4mxniJF09EYYyp9ZpKqYckaKE SbWnB1flWMD8KyqnPT1NaKQStcHUe1p+U+khmJ4504IiMOtu+VfiYnA4F6a2L8n+tWD6 E10Pu3NqCpKR1N+KJuGQHou0+o9PxVeEYgDti7UtfMyiLUnOh8d5a8iWm+poE4CUuc6Y jdEGI1ykuNkhoJX5Rvj2n9QE28tQJ+jEOgDyZDLAUbiJmUeZXJV8diyzAJw5lfTOWSq/ Rmhw== ARC-Authentication-Results: i=1; mx.google.com; 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 a17-v6si6610635pls.302.2018.11.09.02.44.19; Fri, 09 Nov 2018 02:44: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; 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 S1728199AbeKIUXa (ORCPT + 99 others); Fri, 9 Nov 2018 15:23:30 -0500 Received: from mx2.suse.de ([195.135.220.15]:58164 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727560AbeKIUXa (ORCPT ); Fri, 9 Nov 2018 15:23:30 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4F1BAAF58; Fri, 9 Nov 2018 10:43:26 +0000 (UTC) Subject: Re: [PATCH RFC 1/3] mm: When CONFIG_ZONE_DMA32 is set, use DMA32 for SLAB_CACHE_DMA To: Nicolas Boichat , Robin Murphy Cc: Will Deacon , Joerg Roedel , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , 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 References: <20181109082448.150302-1-drinkcat@chromium.org> <20181109082448.150302-2-drinkcat@chromium.org> From: Vlastimil Babka Openpgp: preference=signencrypt Autocrypt: addr=vbabka@suse.cz; prefer-encrypt=mutual; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej2qx9B75qW2plBs+7+YB 87tMFA+u+L4Z5xAzIimfLD5EKC56kJ1CsXlM8S/LHcmdD9Ctkn3trYDNnat0eoAcfPIP2OZ+ 9oe9IF/R28zmh0ifLXyJQQz5ofdj4bPf8ecEW0rhcqHfTD8k4yK0xxt3xW+6Exqp9n9bydiy tcSAw/TahjW6yrA+6JhSBv1v2tIm+itQc073zjSX8OFL51qQVzRFr7H2UQG33lw2QrvHRXqD Ot7ViKam7v0Ho9wEWiQOOZlHItOOXFphWb2yq3nzrKe45oWoSgkxKb97MVsQ+q2SYjJRBBH4 8qKhphADYxkIP6yut/eaj9ImvRUZZRi0DTc8xfnvHGTjKbJzC2xpFcY0DQbZzuwsIZ8OPJCc LM4S7mT25NE5kUTG/TKQCk922vRdGVMoLA7dIQrgXnRXtyT61sg8PG4wcfOnuWf8577aXP1x 6mzw3/jh3F+oSBHb/GcLC7mvWreJifUL2gEdssGfXhGWBo6zLS3qhgtwjay0Jl+kza1lo+Cv BB2T79D4WGdDuVa4eOrQ02TxqGN7G0Biz5ZLRSFzQSQwLn8fbwARAQABzSFWbGFzdGltaWwg QmFia2EgPHZiYWJrYUBzdXNlLmNvbT7CwZcEEwEKAEECGwMFCwkIBwMFFQoJCAsFFgIDAQAC HgECF4ACGQEWIQSpQNQ0mSwujpkQPVAiT6fnzIKmZAUCWi/zTwUJBbOLuQAKCRAiT6fnzIKm ZIpED/4jRN/6LKZZIT4R2xoou0nJkBGVA3nfb+m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wwFCQPCZwAACgkQIk+n58yCpmQ83g/9Frg1sRMdGPn98zV+ O2eC3h0p5f/oxxQ8MhG5znwHoW4JDG2TuxfcQuz7X7Dd5JWscjlw4VFJ2DD+IrDAGLHwPhCr RyfKalnrbYokvbClM9EuU1oUuh7k+Sg5ECNXEsamW9AiWGCaKWNDdHre3Lf4xl+RJWxghOVW RiUdpLA/a3yDvJNVr6rxkDHQ1P24ZZz/VKDyP+6g8aty2aWEU0YFNjI+rqYZb2OppDx6fdma YnLDcIfDFnkVlDmpznnGCyEqLLyMS3GH52AH13zMT9L9QYgT303+r6QQpKBIxAwn8Jg8dAlV OLhgeHXKr+pOQdFf6iu2sXlUR4MkO/5KWM1K0jFR2ug8Pb3aKOhowVMBT64G0TXhQ/kX4tZ2 ZF0QZLUCHU3Cigvbu4AWWVMNDEOGD/4sn9OoHxm6J04jLUHFUpFKDcjab4NRNWoHLsuLGjve Gdbr2RKO2oJ5qZj81K7os0/5vTAA4qHDP2EETAQcunTn6aPlkUnJ8aw6I1Rwyg7/XsU7gQHF IM/cUMuWWm7OUUPtJeR8loxZiZciU7SMvN1/B9ycPMFs/A6EEzyG+2zKryWry8k7G/pcPrFx O2PkDPy3YmN1RfpIX2HEmnCEFTTCsKgYORangFu/qOcXvM83N+2viXxG4mjLAMiIml1o2lKV cqmP8roqufIAj+Ohhzs= Message-ID: <00afe803-22dd-5a75-70aa-dda0c7752470@suse.cz> Date: Fri, 9 Nov 2018 11:43:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181109082448.150302-2-drinkcat@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/9/18 9:24 AM, Nicolas Boichat wrote: > Some callers, namely iommu/io-pgtable-arm-v7s, expect the physical > address returned by kmem_cache_alloc with GFP_DMA parameter to be > a 32-bit address. > > Instead of adding a separate SLAB_CACHE_DMA32 (and then audit > all the calls to check if they require memory from DMA or DMA32 > zone), we simply allocate SLAB_CACHE_DMA cache in DMA32 region, > if CONFIG_ZONE_DMA32 is set. > > Fixes: ad67f5a6545f ("arm64: replace ZONE_DMA with ZONE_DMA32") > Signed-off-by: Nicolas Boichat > --- > include/linux/slab.h | 13 ++++++++++++- > mm/slab.c | 2 +- > mm/slub.c | 2 +- > 3 files changed, 14 insertions(+), 3 deletions(-) > > diff --git a/include/linux/slab.h b/include/linux/slab.h > index 918f374e7156f4..390afe90c5dec0 100644 > --- a/include/linux/slab.h > +++ b/include/linux/slab.h > @@ -30,7 +30,7 @@ > #define SLAB_POISON ((slab_flags_t __force)0x00000800U) > /* Align objs on cache lines */ > #define SLAB_HWCACHE_ALIGN ((slab_flags_t __force)0x00002000U) > -/* Use GFP_DMA memory */ > +/* Use GFP_DMA or GFP_DMA32 memory */ > #define SLAB_CACHE_DMA ((slab_flags_t __force)0x00004000U) > /* DEBUG: Store the last owner for bug hunting */ > #define SLAB_STORE_USER ((slab_flags_t __force)0x00010000U) > @@ -126,6 +126,17 @@ > #define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \ > (unsigned long)ZERO_SIZE_PTR) > > +/* > + * When ZONE_DMA32 is defined, have SLAB_CACHE_DMA allocate memory with > + * GFP_DMA32 instead of GFP_DMA, as this is what some of the callers > + * require (instead of duplicating cache for DMA and DMA32 zones). > + */ > +#ifdef CONFIG_ZONE_DMA32 > +#define SLAB_CACHE_DMA_GFP GFP_DMA32 > +#else > +#define SLAB_CACHE_DMA_GFP GFP_DMA > +#endif AFAICS this will break e.g. x86 which can have both ZONE_DMA and ZONE_DMA32, and now you would make kmalloc(__GFP_DMA) return objects from ZONE_DMA32 instead of __ZONE_DMA, which can break something. Also I'm probably missing the point of this all. In patch 3 you use __get_dma32_pages() thus __get_free_pages(__GFP_DMA32), which uses alloc_pages, thus the page allocator directly, and there's no slab caches involved. It makes little sense to involve slab for page table allocations anyway, as those tend to be aligned to a page size (or high-order page size). So what am I missing?