From patchwork Fri Nov 9 08:24:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Boichat X-Patchwork-Id: 10675503 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92C3A5A4 for ; Fri, 9 Nov 2018 08:25:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 831DA28FBA for ; Fri, 9 Nov 2018 08:25:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 761D22E661; Fri, 9 Nov 2018 08:25:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5922A28FBA for ; Fri, 9 Nov 2018 08:25:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF8CE6B06B5; Fri, 9 Nov 2018 03:25:04 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D82206B06B6; Fri, 9 Nov 2018 03:25:04 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C01346B06B7; Fri, 9 Nov 2018 03:25:04 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 77DEF6B06B5 for ; Fri, 9 Nov 2018 03:25:04 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id i19-v6so920878pfi.21 for ; Fri, 09 Nov 2018 00:25:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=InnuhSOGBaveThAeEjWNNfjdxk+ZL+DS5Ky3lmpgzcQ=; b=jSX6WGSerVIWMxNelV3Ny/YUL3tyVen2aEV+xS5Z/IkXWn5U1exFbcwi/tJxngZX4h i4Y68F+vEg+cKlOoEMKmgNI+OM8cZCXhCT7c4rPL+s4bfU2i9Lj/8jyQcyxHV7csdKVZ 9fCQCP1jdNu49m/zJiyUxxE4k8hHAkJpO3bzmptI4L8/2Sv8Jb4kprJWSNhmWeHrSWvE INo0v5syRsMld6bo6Vmx/5aqsG2YYPfb6A1E1KIqoD+al3KmQnmTbUADR2HWePMvtngv z8RaGsMLe+FvzLAhm9KxhH02/BDCEVAR3aMg8G90UFAeW/KnUDe0d3MhD3GbMkluqFLV KHTw== X-Gm-Message-State: AGRZ1gJHMXrn7BpOjo1NBSKNXHF/yriYMEdNkw9sRIAHkKgG19t59+q9 /5bihhrFpkDu8KYk1wXd2hMK86U+qoUjwIPGmROf/mxjiP4UqyJA+wbbhklcGYgNcHPLgjJMpjZ ofOxUZLOVjodkwBlLk6lHfa4Zmrgte22CV9D1VXzqXkNV1w8nr0NpJh0VslqKph8qfN1ce2XVYZ 4gJiWZPJdcX6/UaTgHsVRKXDGOr/x94Ox+Iu/Kb6re1384YnhOH2Pm9aNLNAKDalA/ais6ZqgpU FMVbW31djHGVkgWvf7jjfi3BRsc3XM0AvJnq8cDMiq8OxGOoGBKEOmKgPL+uP7Hynd4YmAF+V9j 218mEMrve6aYxf7TyjJjz9awwTCZem3x4nTKB0ug5KvCHMaFLn5OjZgbJJfBVN7duK5eHgz2cDp a X-Received: by 2002:a17:902:7595:: with SMTP id j21-v6mr6307152pll.191.1541751904134; Fri, 09 Nov 2018 00:25:04 -0800 (PST) X-Received: by 2002:a17:902:7595:: with SMTP id j21-v6mr6307120pll.191.1541751903377; Fri, 09 Nov 2018 00:25:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541751903; cv=none; d=google.com; s=arc-20160816; b=pR0rR5Fk/3QHU8K6XUiiO7f/cp2lnmuvUiTSms59+14/X/2j2IlJOa3YugyXcluiz4 lr751dR2jEGCGoFEnUmmz5xG0VusiCtlqppdfkMJGOdgWbYNMh2KYK66yxIz8y0DKh4u 8hlbHdvNQilFn3p3qVfYPdwHq0R/L8oreAKayxbvNDkt+fa6OHnUJFR4JynJ2997wPBD 41AOIKdvTfrCPdu8MpoQz4RpGdnLaIqLA3NruJsqEzYLqEEYusDWjdfsB8nXx3CGsNkp TBJTH0tx7/BHJVctlHxkldp2yOhblZtYvv/F4IUifUP7poJoTqCOgjweHipNE0x3os+L 38NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=InnuhSOGBaveThAeEjWNNfjdxk+ZL+DS5Ky3lmpgzcQ=; b=Iv9i9os43IGs616dGi0GTH2gEYBsWKhccUxFTaLYjlBtpH5nMY9NMlOIlXjP8zLMrv EheE4k5h9sbprC4vL9bSJlz6RocV48Y238jtVcWYHyBR5S9vJzz8Lw7uBwlocDXyp592 ESGV3bQ/ObM/Kr5gKyoYbGY1zVgg72vgKeBvZxfP54ThUlNS3iAiUBF606PEHUTtRcRp NM0vAo3ddWAqcCUYUtOBXi1TE8H53OYFIZt6ZZUpi5dUz54tIwWa3852iRxGSdUyNbuE 1VH1Ld5inFIz+gp22FcZiV6YiRkXqGMdm0WXAFxdn0S33b6fXRrXYTLY/AhRV78o3oz+ /FdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MAme0Iyr; spf=pass (google.com: domain of drinkcat@chromium.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=drinkcat@chromium.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 81-v6sor8177852pfk.64.2018.11.09.00.25.03 for (Google Transport Security); Fri, 09 Nov 2018 00:25:03 -0800 (PST) Received-SPF: pass (google.com: domain of drinkcat@chromium.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MAme0Iyr; spf=pass (google.com: domain of drinkcat@chromium.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=drinkcat@chromium.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=InnuhSOGBaveThAeEjWNNfjdxk+ZL+DS5Ky3lmpgzcQ=; b=MAme0Iyr8teK/Ki5Pc6avc9NyM1ZACSxW+qUvWNMrPDfd+5+hhO3XR+a7YzIULs9Xw LTuccIQILw7lwgZkGKEYJ8IkgnwH17FFLvdUjMzhtytWGx+RpaPlb9jroe0/Joy2LiKV ehgDDj7Tu9x1mC2VMBhEPgXrCnbFfg6c2FBlk= X-Google-Smtp-Source: AJdET5f+WYjZSeRCglfwtnuJ6P5AzPDF6WiYotJEhF1tiG0JcbiXu7QnCbiBFLT3EFeBo3Z6Nv0E6w== X-Received: by 2002:a62:5e83:: with SMTP id s125-v6mr7944253pfb.232.1541751902866; Fri, 09 Nov 2018 00:25:02 -0800 (PST) Received: from drinkcat2.tpe.corp.google.com ([2401:fa00:1:b:f659:7f17:ea11:4e8e]) by smtp.gmail.com with ESMTPSA id u2-v6sm6415667pfn.50.2018.11.09.00.24.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 00:25:02 -0800 (PST) From: Nicolas Boichat To: Robin Murphy Cc: Will Deacon , Joerg Roedel , Christoph Lameter , 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: [PATCH RFC 1/3] mm: When CONFIG_ZONE_DMA32 is set, use DMA32 for SLAB_CACHE_DMA Date: Fri, 9 Nov 2018 16:24:46 +0800 Message-Id: <20181109082448.150302-2-drinkcat@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog In-Reply-To: <20181109082448.150302-1-drinkcat@chromium.org> References: <20181109082448.150302-1-drinkcat@chromium.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 + #include struct mem_cgroup; diff --git a/mm/slab.c b/mm/slab.c index 2a5654bb3b3ff3..8810daa052dcdc 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -2121,7 +2121,7 @@ int __kmem_cache_create(struct kmem_cache *cachep, slab_flags_t flags) cachep->flags = flags; cachep->allocflags = __GFP_COMP; if (flags & SLAB_CACHE_DMA) - cachep->allocflags |= GFP_DMA; + cachep->allocflags |= SLAB_CACHE_DMA_GFP; if (flags & SLAB_RECLAIM_ACCOUNT) cachep->allocflags |= __GFP_RECLAIMABLE; cachep->size = size; diff --git a/mm/slub.c b/mm/slub.c index e3629cd7aff164..fdd05323e54cbd 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3575,7 +3575,7 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order) s->allocflags |= __GFP_COMP; if (s->flags & SLAB_CACHE_DMA) - s->allocflags |= GFP_DMA; + s->allocflags |= SLAB_CACHE_DMA_GFP; if (s->flags & SLAB_RECLAIM_ACCOUNT) s->allocflags |= __GFP_RECLAIMABLE;