From patchwork Mon Dec 10 01:15:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Boichat X-Patchwork-Id: 10720485 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 A6D3991E for ; Mon, 10 Dec 2018 01:15:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 837A429DB6 for ; Mon, 10 Dec 2018 01:15:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 709E729E16; Mon, 10 Dec 2018 01:15:20 +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 D148429DB6 for ; Mon, 10 Dec 2018 01:15:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C512E8E0003; Sun, 9 Dec 2018 20:15:18 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C015B8E0001; Sun, 9 Dec 2018 20:15:18 -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 AC92D8E0003; Sun, 9 Dec 2018 20:15:18 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 6A0CB8E0001 for ; Sun, 9 Dec 2018 20:15:18 -0500 (EST) Received: by mail-pg1-f197.google.com with SMTP id s27so6444165pgm.4 for ; Sun, 09 Dec 2018 17:15:18 -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:mime-version:content-transfer-encoding; bh=MkSsWMVSAeJSTGMkLIBUq4R1LV61HkOQXyu0ciWvNcA=; b=uDygcyb1t3XQsVU3mSsgen8XuzYaDwjwvOECiAkqixHZvzp2PcNUCXZIgHZrKmRtju cr16ueMu7ksb+6YZdmmXABp+u2ojBttMCqygVqqi69v4Aam58emB6KmXO2snyC6dXNSa XX6mCq1tjsL/6TZ3tn9Hu+ywq4WocM/+/a1iGW54m3RotMNp85e/R43zhbxqENFRZkp6 hsQxqwBYsjn/J7YUT2RkpevoWaKnckyFa0waU58GW7w1mKEihmNWgur7pK/3Pa8BtYES rV6rqdvQG1kbfHurw1L8LYmGBiBrzP4AtD+0c4wpJGxhldwwGJnQUmCBVpSAoSFshIAn p+Dw== X-Gm-Message-State: AA+aEWYZ2aTYCDKn1KmIHX2QymhhGzNs/nidjmGtdVhnuz2Eb8M0AgFo gvjKTHmUvVRZ29lNnnk9fudvd+6ALEbEVEptSpttzRplZvO57jrNfJwOfdG6f24Jo27iDSL70AL 9Uzu2BKyjgpSUl89uGtCcajTYphNekoU71niDeDM58Ut8srcE3ulyqSE0Y/+nMrWDMF0Ak0ewms RBWSURmC8nlrLR48SihSqfHWY7r5LYAE9VYCwmGcQq9HsoAEKfx44zNTfX1KLl9q8914cCPoacC 9zSf4cDOask3H+Ew21jYPTschSC0Fk5W+m/e4MdERl68x7wpPMIGjxZSQBO/TPQCpRlIW2WnRoh nNQPyolhCysDX2xm5R7f8w4hntbiprPS4lCMR29llpXa1GSuZUBX9XpT6WyYRp10llRx1L6wQOz p X-Received: by 2002:a63:1b48:: with SMTP id b8mr9223916pgm.187.1544404518026; Sun, 09 Dec 2018 17:15:18 -0800 (PST) X-Received: by 2002:a63:1b48:: with SMTP id b8mr9223853pgm.187.1544404516861; Sun, 09 Dec 2018 17:15:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544404516; cv=none; d=google.com; s=arc-20160816; b=hBhjgFGU5hvruSuDpO/IJyH1FPb7kr0c/w648IuJl5mVQ5WZbVRC4uXwSkudifbPY8 Gyl+QNILrTq/hW9ooTQjX3pO+FKDC6bXFRN/G4tptOjvMEpizZUy9oIgzmNRtYztE/HY NEBIRWl83Qgdk6Tx1jHq3layZS4wVJonOwk4wYycy7bZTVx9NOYGy3qo7HFDEVKaft/c RopW22NAKb2ymp/rX25IIJDkfSm750bDXhgsTiV8SDgdpjE0/mbzTS0fGqLbeRK1LNet I6Q2QyilehBN4rgH50bhUQeqXKbcYgICZSBX/f5ll0vnJabcSvBhKsuOOS+6oXqKlnQW eWWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=MkSsWMVSAeJSTGMkLIBUq4R1LV61HkOQXyu0ciWvNcA=; b=SSFfA0YeTM887y5oqAAm69yOO7bWQe0LAN0ktionFZy+TKuHTJo+whlzMDxPs54cSU 11HcsIeFuFOqQXfeorPJG0MBtdwbVZhBneoNsZqs765Eyj4bHU0yMyK/nwuyCLLnp5LN WB+ijAoyjWaeTxHcxf1SDSyIaea3fiHOmYgytKWrPpI94rknihETW/sdN023PigvEYpZ H0dZNpo6M/8zN9A92B7uB81kvXTEce5sAM84OBdxjlJUZ5/qzekcZK6UKF0jS75rabC1 E7CLABdBBA6QOrfdUBguY6g6+tP4VrEZXkvyHhiKEh2ZqctE+5itAtZwsMI9v4D4443R M/Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IGakDlDC; 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 e69sor10922306plb.21.2018.12.09.17.15.16 for (Google Transport Security); Sun, 09 Dec 2018 17:15:16 -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=IGakDlDC; 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:mime-version :content-transfer-encoding; bh=MkSsWMVSAeJSTGMkLIBUq4R1LV61HkOQXyu0ciWvNcA=; b=IGakDlDC4jzbyobxgJg+2BtK6pRzujiaHW9b/NlUxa0oN4Q+v0nQbxHrvV6rztYHh8 d3fr24CtYwIkYSO3HiHHaG/leWfyED+lGSqnIV7h/Xbo2OepSP1vmM9e307pfWp5Ne7t 7rnRbEZVNe0rbWbSsRsAUfgBYrhNOmlCsnIq0= X-Google-Smtp-Source: AFSGD/WjUF0Gawkk7vT2zAOu4MoHSXVpXqw+NlA2IDYWtN/771s4IQ/JHyV568QM+ZRV7zANefqpgA== X-Received: by 2002:a17:902:7d90:: with SMTP id a16mr9818780plm.249.1544404516350; Sun, 09 Dec 2018 17:15:16 -0800 (PST) Received: from drinkcat2.tpe.corp.google.com ([2401:fa00:1:b:f659:7f17:ea11:4e8e]) by smtp.gmail.com with ESMTPSA id b10sm16516336pfj.183.2018.12.09.17.15.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Dec 2018 17:15:15 -0800 (PST) From: Nicolas Boichat To: Will Deacon Cc: Robin Murphy , 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, hch@infradead.org, Matthew Wilcox , hsinyi@chromium.org, stable@vger.kernel.org Subject: [PATCH v6 0/3] iommu/io-pgtable-arm-v7s: Use DMA32 zone for page tables Date: Mon, 10 Dec 2018 09:15:01 +0800 Message-Id: <20181210011504.122604-1-drinkcat@chromium.org> X-Mailer: git-send-email 2.20.0.rc2.403.gdbc3b29805-goog 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 This is a follow-up to the discussion in [1], [2]. IOMMUs using ARMv7 short-descriptor format require page tables (level 1 and 2) to be allocated within the first 4GB of RAM, even on 64-bit systems. For L1 tables that are bigger than a page, we can just use __get_free_pages with GFP_DMA32 (on arm64 systems only, arm would still use GFP_DMA). For L2 tables that only take 1KB, it would be a waste to allocate a full page, so we considered 3 approaches: 1. This series, adding support for GFP_DMA32 slab caches. 2. genalloc, which requires pre-allocating the maximum number of L2 page tables (4096, so 4MB of memory). 3. page_frag, which is not very memory-efficient as it is unable to reuse freed fragments until the whole page is freed. [3] This series is the most memory-efficient approach. stable@ note: We confirmed that this is a regression, and IOMMU errors happen on 4.19 and linux-next/master on MT8173 (elm, Acer Chromebook R13). The issue most likely starts from commit ad67f5a6545f ("arm64: replace ZONE_DMA with ZONE_DMA32"), i.e. 4.15, and presumably breaks a number of Mediatek platforms (and maybe others?). [1] https://lists.linuxfoundation.org/pipermail/iommu/2018-November/030876.html [2] https://lists.linuxfoundation.org/pipermail/iommu/2018-December/031696.html [3] https://patchwork.codeaurora.org/patch/671639/ Changes since v1: - Add support for SLAB_CACHE_DMA32 in slab and slub (patches 1/2) - iommu/io-pgtable-arm-v7s (patch 3): - Changed approach to use SLAB_CACHE_DMA32 added by the previous commit. - Use DMA or DMA32 depending on the architecture (DMA for arm, DMA32 for arm64). Changes since v2: - Reworded and expanded commit messages - Added cache_dma32 documentation in PATCH 2/3. v3 used the page_frag approach, see [3]. Changes since v4: - Dropped change that removed GFP_DMA32 from GFP_SLAB_BUG_MASK: instead we can just call kmem_cache_*alloc without GFP_DMA32 parameter. This also means that we can drop PATCH v4 1/3, as we do not make any changes in GFP flag verification. - Dropped hunks that added cache_dma32 sysfs file, and moved the hunks to PATCH v5 3/3, so that maintainer can decide whether to pick the change independently. Changes since v5: - Rename ARM_V7S_TABLE_SLAB_CACHE to ARM_V7S_TABLE_SLAB_FLAGS. - Add stable@ to cc. Nicolas Boichat (3): mm: Add support for kmem caches in DMA32 zone iommu/io-pgtable-arm-v7s: Request DMA32 memory, and improve debugging mm: Add /sys/kernel/slab/cache/cache_dma32 Documentation/ABI/testing/sysfs-kernel-slab | 9 +++++++++ drivers/iommu/io-pgtable-arm-v7s.c | 19 +++++++++++++++---- include/linux/slab.h | 2 ++ mm/slab.c | 2 ++ mm/slab.h | 3 ++- mm/slab_common.c | 2 +- mm/slub.c | 16 ++++++++++++++++ tools/vm/slabinfo.c | 7 ++++++- 8 files changed, 53 insertions(+), 7 deletions(-)