From patchwork Thu Jan 21 17:54:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 12037283 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F73DC433E0 for ; Thu, 21 Jan 2021 17:55:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 71C1023A5A for ; Thu, 21 Jan 2021 17:55:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 71C1023A5A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A7CFF6B0006; Thu, 21 Jan 2021 12:55:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A2CCD6B0007; Thu, 21 Jan 2021 12:55:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 919DD6B0008; Thu, 21 Jan 2021 12:55:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id 780C46B0006 for ; Thu, 21 Jan 2021 12:55:10 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3BD8C180AD81F for ; Thu, 21 Jan 2021 17:55:10 +0000 (UTC) X-FDA: 77730533580.18.alarm08_411724427565 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 106E0100EB1D9 for ; Thu, 21 Jan 2021 17:55:10 +0000 (UTC) X-HE-Tag: alarm08_411724427565 X-Filterd-Recvd-Size: 6261 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Thu, 21 Jan 2021 17:55:09 +0000 (UTC) Received: by mail-pg1-f171.google.com with SMTP id n25so1868216pgb.0 for ; Thu, 21 Jan 2021 09:55:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lIeZgxiGCsLILQUzar0fN74yeBikTXjhSQrKP1TVbyY=; b=jS+vKFbZa38LNSPxMW8UUy2WyAZczTi8cqUZ8Vw7R9TKkQGeMLimDs4yHnSciY+ftd Ixya86WbgEW3Df77hJx6pHgYlKeTA3dm3xrC9i5P5ddd6Yi1+Br7KNojGx825Gr+KbHX /mN47KYt9ao1PLRr1vC1A0mUkDYRRA0oSrPQGov1JyHVoekE2avecMMSNw7RlFUoXFkI Yv+s513YWQNaR3bDwo3D5R8nGscWbtMvYop1wJopXj/e+l+SYVwRWp0wcyU2p4pDDZdD pU2+wR148BChhKCpD4OQmWSBs/TmfkqZP4ZkgUzx/M1xr70whN01dPoMnf2kcQ5RCE2M GHSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=lIeZgxiGCsLILQUzar0fN74yeBikTXjhSQrKP1TVbyY=; b=WpEWQP9TXyxTI8gEPyZK0fgQYCw+dv07VXSjJ6jJYxBTl2II40+l5kX4gdTIJ6+DCO sw0Y4x7AImhJXDdYttBr+vRf+2u83q1UCw+gWMrz4JXESRaNn0D+2E2+2LbhIHWJ9sVk /gDAUbSzPso2HcD32TS2ORpVOiSiBqJ3R0xY0EF+UYKnem7/dGkPaaSBwtwMXvLy93ht Nn7H377aTLWDqtTY3kahjCnO/sMLoE0fi9SfiQWWQu2MmuIUXD7iI1pC+mqEPcAlBpoG qX3F4OGhZh7qncTBvaoY2LFDRiDr7lpDpBq356dbm8Ae9rjtMTFNMRiJsNP8LG5GZkm2 lmBQ== X-Gm-Message-State: AOAM531ZdsQOsnjFPoQ0BFbkpE7O9DoJY63VsiKHKIJqXV2m8FV55JfA j9L4sut64NqOVn1LOXMhkGQ= X-Google-Smtp-Source: ABdhPJwtihxfcT7CpRtx34TZuGHZTSg1DELFPxcH324ViojdMpZTcYglQ8vCxZ6nbMkVxVbk2hfbpA== X-Received: by 2002:a05:6a00:15cc:b029:1ba:5282:3ab8 with SMTP id o12-20020a056a0015ccb02901ba52823ab8mr792072pfu.77.1611251708510; Thu, 21 Jan 2021 09:55:08 -0800 (PST) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:201:74d0:bb24:e25e:dc4d]) by smtp.gmail.com with ESMTPSA id t2sm6897317pju.19.2021.01.21.09.55.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jan 2021 09:55:07 -0800 (PST) From: Minchan Kim To: Andrew Morton Cc: linux-mm , LKML , hyesoo.yu@samsung.com, david@redhat.com, mhocko@suse.com, surenb@google.com, pullip.cho@samsung.com, joaodias@google.com, hridya@google.com, john.stultz@linaro.org, sumit.semwal@linaro.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org, hch@infradead.org, robh+dt@kernel.org, linaro-mm-sig@lists.linaro.org, Minchan Kim Subject: [PATCH v4 0/4] Chunk Heap Support on DMA-HEAP Date: Thu, 21 Jan 2021 09:54:58 -0800 Message-Id: <20210121175502.274391-1-minchan@kernel.org> X-Mailer: git-send-email 2.30.0.296.g2bfb1c46d8-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: This patchset introduces a new dma heap, "chunk-heap" that makes it easy to perform the bulk allocation of high order pages. It has been created to help optimize the 4K/8K HDR video playback with secure DRM HW to protect contents on memory. The HW needs physically contiguous memory chunks(e.g, 64K) up to several hundred MB memory. To make such high-order big bulk allocations work, chunk-heap uses CMA area. To avoid CMA allocation long stall on blocking pages(e.g., page writeback and/or page locking), it uses failfast mode of the CMA API(i.e., __GFP_NORETRY) so it will continue to find easy migratable pages in different pageblocks without stalling. At last resort, it will allow the blocking only if it couldn't find the available memory in the end. First two patches introduces the failfast mode as __GFP_NORETRY in alloc_contig_range and the allow to use it from the CMA API. Third patch introduces device tree syntax for chunk-heap to bind the specific CMA area with chunk-heap. Finally, last patch implements chunk-heap as dma-buf heap. * since v3 - https://lore.kernel.org/linux-mm/20210113012143.1201105-1-minchan@kernel.org/ * use prefix for chunk-name - John * fix yamllint error - Rob * add reviewed-by - Suren * since v2 - https://lore.kernel.org/linux-mm/20201201175144.3996569-1-minchan@kernel.org/ * introduce gfp_mask with __GFP_NORETRY on cma_alloc - Michal * do not expoert CMA APIs - Christoph * use compatible string for DT instead of dma-heap specific property - Hridya * Since v1 - https://lore.kernel.org/linux-mm/20201117181935.3613581-1-minchan@kernel.org/ * introduce alloc_contig_mode - David * use default CMA instead of device tree - John Hyesoo Yu (2): dt-bindings: reserved-memory: Make DMA-BUF CMA heap DT-configurable dma-buf: heaps: add chunk heap to dmabuf heaps Minchan Kim (2): mm: cma: introduce gfp flag in cma_alloc instead of no_warn mm: failfast mode with __GFP_NORETRY in alloc_contig_range .../reserved-memory/dma_heap_chunk.yaml | 56 ++ drivers/dma-buf/heaps/Kconfig | 8 + drivers/dma-buf/heaps/Makefile | 1 + drivers/dma-buf/heaps/chunk_heap.c | 492 ++++++++++++++++++ drivers/dma-buf/heaps/cma_heap.c | 2 +- drivers/s390/char/vmcp.c | 2 +- include/linux/cma.h | 2 +- kernel/dma/contiguous.c | 3 +- mm/cma.c | 12 +- mm/cma_debug.c | 2 +- mm/hugetlb.c | 6 +- mm/page_alloc.c | 8 +- mm/secretmem.c | 3 +- 13 files changed, 581 insertions(+), 16 deletions(-) create mode 100644 Documentation/devicetree/bindings/reserved-memory/dma_heap_chunk.yaml create mode 100644 drivers/dma-buf/heaps/chunk_heap.c