From patchwork Wed Jan 13 01:21:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 12015537 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 07ACEC433DB for ; Wed, 13 Jan 2021 01:21:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 76E322311B for ; Wed, 13 Jan 2021 01:21:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 76E322311B 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 903A86B00F4; Tue, 12 Jan 2021 20:21:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B34D6B00F6; Tue, 12 Jan 2021 20:21:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77AFC6B00FF; Tue, 12 Jan 2021 20:21:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0217.hostedemail.com [216.40.44.217]) by kanga.kvack.org (Postfix) with ESMTP id 62C996B00F4 for ; Tue, 12 Jan 2021 20:21:55 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2F937824556B for ; Wed, 13 Jan 2021 01:21:55 +0000 (UTC) X-FDA: 77699000190.16.end69_0b0c7bf2751a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 10A5D100E690B for ; Wed, 13 Jan 2021 01:21:55 +0000 (UTC) X-HE-Tag: end69_0b0c7bf2751a X-Filterd-Recvd-Size: 5993 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Jan 2021 01:21:54 +0000 (UTC) Received: by mail-pg1-f170.google.com with SMTP id i5so430873pgo.1 for ; Tue, 12 Jan 2021 17:21:54 -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=OF1vzKHCoB9FbkveX0jDIMlRTwuLz60PQrD10fcsFvo=; b=UH6sv5ytYE04PK0iHS7mRqn5lcCiexxf2Xe/PoK4fkM38pimasFBp9BCAd/TmTSoS9 Y4fVpf/+DWDnHW5kmP6xjFsK6xAfA0q5HreB3l3g4q9VKhRRf+pccwYFmP56UvofNi1G 3b0+4KQFMRB32GMMzMyUlx8kc30ezji0D8deRhI+tWRphT+7hx4Sj9EUc0E5GcaekxJw td6bgRnXqduBYHBGBdHIdCtFeAnohT6yU4EvXnGXShnNj53hjVxDAfoO8lMKPjL3wTnT 4iQecTf1TQq/T/ElIygy0BI8zamN3WGw9kxQuoUjcQB8/HMNai/6Gc6O9tzrT38Eq2EY cq2A== 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=OF1vzKHCoB9FbkveX0jDIMlRTwuLz60PQrD10fcsFvo=; b=gBBbwJn+02VIzVoxHfVWmOZxFUNwVRFMR61aoWGW/IaSKEnPgVtHyAMHNZ6oMRU40F toShB4A08vmJ6YEKjRjO+rWtfMDr5dSEVcq3NomUsJ1oLCGKxVYUPDt/5whpG0c+H6Sd dBTq65qOhbVOaiLOVDZOh+Ig/VinLPoTIiCYh3uEE9di7G4KcqAdxSfB9NNiEGjVB7zw n3lgpFsB7sk9ISaxrG/B2d8J9GrPkaKMoAo8m288NQTmEtbtxBeKy4hk+ZIiY7AQT0sw mUFgBnlZOSw+Tz2Yl0omMeiOnVLmDs24oT3QtH5y+uIhS/appJK3Y4xQSxfqdjrfmJwI UPuA== X-Gm-Message-State: AOAM532hiGtbFiy8K+VEobwgeRIz6Nu8GxOQzYTub2bSAiRw3qLApSB+ GoRkivugbi7cGbiShKLnO4U= X-Google-Smtp-Source: ABdhPJzYrt3TdM44/itCkvsZ36dDJ69idE7ohZq5unbjsjwFA2k+bmee0Jqg9Tmdb+3ZMwABk51ytA== X-Received: by 2002:aa7:95aa:0:b029:1ad:d810:42be with SMTP id a10-20020aa795aa0000b02901add81042bemr2009988pfk.51.1610500913498; Tue, 12 Jan 2021 17:21:53 -0800 (PST) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:201:7220:84ff:fe09:5e58]) by smtp.gmail.com with ESMTPSA id b2sm355197pff.79.2021.01.12.17.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 17:21:52 -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 v3 0/4] Chunk Heap Support on DMA-HEAP Date: Tue, 12 Jan 2021 17:21:39 -0800 Message-Id: <20210113012143.1201105-1-minchan@kernel.org> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-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 v2 - * introduce gfp_mask with __GFP_NORETRY on cma_alloc - mhocko * 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 | 58 +++ drivers/dma-buf/heaps/Kconfig | 8 + drivers/dma-buf/heaps/Makefile | 1 + drivers/dma-buf/heaps/chunk_heap.c | 477 ++++++++++++++++++ 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, 568 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