Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9327656imu; Wed, 5 Dec 2018 03:02:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/V35Imd/BP7q4yG4DUXnnWyvNTWS4tlDJltPRflrhsVbZ9SeL912KdkGRYg2zRGShcuHC8s X-Received: by 2002:a65:55ca:: with SMTP id k10mr19775450pgs.448.1544007743385; Wed, 05 Dec 2018 03:02:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544007743; cv=none; d=google.com; s=arc-20160816; b=e7yiggcyaW74imBlzuKta3PNknmJIUbSjCX30GUupjGM74AjLyB3RZNFjCeEk2VFbO a5xNkwDjlbfE2QfhyryIaAcAP/y4mCJTJpwgH5tH7/6PhzRBXS5yclREPUocWHncA49Z 0O/UwB9Dhhqov9yL9kibgE8nKHJGBj7rZ5q1XoKTyx9YI/TQs82sgUF9TEIW09Tcoaoy xoyLzgWzEyfPB4dsj8ot40LY+juqb5M0YzQPlZD2EyBROoVGhQg8KomrzL/piiK3IadM D1k45ieVidDkhYyp5zQlDdvJTnUbPCi3yckus6NT7brwPI6XsyHVUzo5HjuklEjm/tHk peRg== 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=fAwxirXvKSBwHD7F87FQNRm1Bs8VUKIJ1ixDohaxvyo=; b=SZlLRZwjtrOUA/HQJIWD8Y0ReDefwQGOEPwLy/r45OJbP4ZO8XsQyFAtg06zxXKjQp Na1PKYLrt50aoAxosh27kdu1Pg9aJix8Py82InxQfm3YK2IMMJZgx/yheDYo5NYpIxCc GVY1xGy/CkzFL19yooL8BImX0wgrqFwq/eNs9Ce4jmbtzpgw2O01EMJReCSPa5tNBpW1 anast1NQr04a6VT77u9VBqg+ZpNof28qGt1Lt5hZdJEZj3aexFWVLDjuHagRPRIZwRtH i5xMmTZMoqktP3WQNModok4cSA/Zo/RE/q2dTuFVZlQph5xNgpK2RY/oc3uG2tDnVOEt YN8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jjp6fPye; 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 41si20160476plf.347.2018.12.05.03.02.08; Wed, 05 Dec 2018 03:02:23 -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=jjp6fPye; 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 S1727704AbeLELBT (ORCPT + 99 others); Wed, 5 Dec 2018 06:01:19 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:37039 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726909AbeLELBS (ORCPT ); Wed, 5 Dec 2018 06:01:18 -0500 Received: by mail-pl1-f193.google.com with SMTP id b5so9906282plr.4 for ; Wed, 05 Dec 2018 03:01:17 -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=fAwxirXvKSBwHD7F87FQNRm1Bs8VUKIJ1ixDohaxvyo=; b=jjp6fPye3+yWNPt145+nY0kGHOOdSMnqumE8d06LeJbKKU+Hxe1vctFtVfz66IomL/ 5tOM6q/6xliyE6EyvrgxxrE7p3kBJmLUBEa+kykNCxYMQDxKc63p/fITVzWhK2lUP5TK U+bbS7es4Etx0I30scYfPfMwtmhXEO9UfNqJs= 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=fAwxirXvKSBwHD7F87FQNRm1Bs8VUKIJ1ixDohaxvyo=; b=tSechjIzq4RvcUK/e6XqE45PREZN4ESlVR9hO+lTI/RsqCfplWzLMeHI13eGhwxn1u QaTIhvSHH2I8Iwt9+z1r5vw6PQE28nxjkFlUZ4Oqlrx3u+8VQ4zuxEXIw46hVtA/B1VW M2rBeMpfO1UIgF9wqGupo7iUMUbzNwQtsJP4oFl2pk16Buxn5bU/7WNJzb/X7NIwXYB5 JHR/3o6FYXOWJdcT4fWIFGYeW1M+KTfU5lE9EI8zHsKubnpKXNdiaomfYWgeEF6DFFNA uTwarpS334m3mE748GONrDEPdrgm0aVnfBJf/fJZd1DZPksZapwAAvzCTVkrivKi9HQt roBQ== X-Gm-Message-State: AA+aEWaSzljQqn1VFpwFdjZnGNyRjYK/4HBbWY40I5J1YXqx7SQSNBUW u6vGeIeYIS4NIuQrXZ1oit31RiTV/Ut8qnU3PRNChQ== X-Received: by 2002:a17:902:820f:: with SMTP id x15mr22731032pln.224.1544007676601; Wed, 05 Dec 2018 03:01:16 -0800 (PST) MIME-Version: 1.0 References: <20181205054828.183476-1-drinkcat@chromium.org> <20181205054828.183476-3-drinkcat@chromium.org> <20181205095557.GE1286@dhcp22.suse.cz> In-Reply-To: <20181205095557.GE1286@dhcp22.suse.cz> From: Nicolas Boichat Date: Wed, 5 Dec 2018 19:01:03 +0800 Message-ID: Subject: Re: [PATCH v4 2/3] mm: Add support for kmem caches in DMA32 zone To: mhocko@kernel.org Cc: Will Deacon , Robin Murphy , Joerg Roedel , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Mel Gorman , Levin Alexander , Huaisheng Ye , Mike Rapoport , linux-arm Mailing List , iommu@lists.linux-foundation.org, lkml , linux-mm@kvack.org, Yong Wu , Matthias Brugger , Tomasz Figa , yingjoe.chen@mediatek.com, hch@infradead.org, Matthew Wilcox 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 5:56 PM Michal Hocko wrote: > > On Wed 05-12-18 13:48:27, Nicolas Boichat wrote: > > In some cases (e.g. IOMMU ARMv7s page allocator), we need to allocate > > data structures smaller than a page with GFP_DMA32 flag. > > > > This change makes it possible to create a custom cache in DMA32 zone > > using kmem_cache_create, then allocate memory using kmem_cache_alloc. > > > > We do not create a DMA32 kmalloc cache array, as there are currently > > no users of kmalloc(..., GFP_DMA32). The new test in check_slab_flags > > ensures that such calls still fail (as they do before this change). > > The changelog should be much more specific about decisions made here. > First of all it would be nice to mention the usecase. Ok, I'll copy most of the cover letter text here (i.e. the fact that IOMMU wants physical memory <4GB for L2 page tables, why it's better than genalloc/page_frag). > Secondly, why do we need a new sysfs file? Who is going to consume it? We have cache_dma, so it seems consistent to add cache_dma32. I wasn't aware of tools/vm/slabinfo.c, so I can add support for cache_dma32 in a follow-up patch. Any other user I should take care of? > Then why do we need SLAB_MERGE_SAME to cover GFP_DMA32 as well? SLAB_MERGE_SAME tells us which flags _need_ to be the same for the slabs to be merged. We don't want slab caches with GFP_DMA32 and ~GFP_DMA32 to be merged, so it should be in there. (https://elixir.bootlin.com/linux/v4.19.6/source/mm/slab_common.c#L342). > I > thought the whole point is to use dedicated slab cache. Who is this > going to merge with? Well, if there was another SLAB cache requiring 1KB GFP_DMA32 elements, then I don't see why we would not merge the caches. This is what happens with this IOMMU L2 tables cache pre-CONFIG_ZONE_DMA32 on arm64 (output on some 3.18 kernel below), and what would happen on arm32 since we still use GFP_DMA. /sys/kernel/slab # ls -l | grep dt-0001024 drwxr-xr-x. 2 root root 0 Dec 5 02:25 :dt-0001024 lrwxrwxrwx. 1 root root 0 Dec 5 02:25 dma-kmalloc-1024 -> :dt-0001024 lrwxrwxrwx. 1 root root 0 Dec 5 02:25 io-pgtable_armv7s_l2 -> :dt-0001024 Thanks! > -- > Michal Hocko > SUSE Labs