From patchwork Fri Feb 5 08:06:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 376885 Delivered-To: patches@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2008247jah; Fri, 5 Feb 2021 00:06:26 -0800 (PST) X-Received: by 2002:a17:902:e812:b029:de:5af2:3d09 with SMTP id u18-20020a170902e812b02900de5af23d09mr3035499plg.33.1612512386052; Fri, 05 Feb 2021 00:06:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612512386; cv=none; d=google.com; s=arc-20160816; b=uqCYElsBSGdUSrhQ4f28sYzvibcfqxU5XI1JxN4O6L3E6QpvYb7YitMBCFl8xAb/4C C4PxJ87zjuUvdC2bg/++UL+8ELhEvQNQCq6wNHflPUVsa4+WNsRpp51J0QOPUhO4tRNm h0wIrLNyiiZaQmjEiDzOt2XImgSO2gndDUZe8skFbP6SM/PA5MG8ZvL90Mtq1vcoYLew 0tuiynYqbqdhoOd0BNRtr7n99pKjRcvaN35L7krsmOJ54Jb8O7bmnh/0Aoyty2ZYJO2C 6CY/ZOyvNIBOI2RzQaszBfsqJEZ/Fb3cX6bmgeNET5n3ueDiKkwdnT8TwhISVcA9fwwz s72A== 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=zKwoaw8bdzrF/FhsWPWtgeGzPvNKHujT195hYCj6ZCs=; b=dA/k415olbFTfYmy8nNWr1VNZD62re2UsMpsyWUzcfduqiQtjxcCQqUdB15CkRVVay DTrxNJ4AlLXmRSj1lpdH2elxTNcfdykNQt638NLhOZKOOfn07kebIsjJdoQ4EliAglrJ 47tHEbQYsMFQDthxLQzNKlThrO6qnC4ePoVAozvR7K3RKs5J81OjWa/Iti3rEGGLL7zC dG8/wKy9o8lDpa+NcyI365FhBHK1RnV1mrqbp9R9iJwON3bL803uAcdbldc36ASI08ne DrEfmMHTcfuaseHru2rtX8TnDxYNiSg5+MppaawSta1WZjIw+99U1qvGm7zqVVLQKQ+5 daeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K0THtBNl; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 24sor4884432pgy.86.2021.02.05.00.06.25 for (Google Transport Security); Fri, 05 Feb 2021 00:06:25 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K0THtBNl; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zKwoaw8bdzrF/FhsWPWtgeGzPvNKHujT195hYCj6ZCs=; b=K0THtBNlTDmpc3F2F9qo3PXiSflivANjFuhFHO0/w0OQkh9BJFI2DLfQCg3umFdPRT 9DU5VNc7SfomsN45a3Kb9J3ZAcxuU/PcFTQaVK8roWSeawag+xcKSAwCs5/MQo8f2H3d viFJJrrovEHFzeIeEu8FqgsGG29CWEPTETHs3GBuUPsPi0L7kJqZ/1FRq6mEPCH/5VDb 6V9juYaeCpzq6xCPRvBkXCRT98zvQdGItcWAQezWayHIaKbLl7aAMecJp3C2A6Upcqfq CHJNQWQRiVgDzfcgpmshCIoa3TqUQKF+dkdYVW/++YTotTS02mqYGn3sGt4SqKPViMJ0 ULZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zKwoaw8bdzrF/FhsWPWtgeGzPvNKHujT195hYCj6ZCs=; b=Q2JbALpSrEtiM0bS//q4uVZQj1xr5CSofmssXU8/bJuiAu4A1klg05B6zuxA6+zzWa dsjyrqj6xUio+ZVcOl3vS957WAQG5PLZqTkKlbH2wxwqPV+PJ7Rjf2WEcLK4boElBgFU Xgi3MWlm4Lw+WDZ6J7p59u165n7cDsqOFk/OkAqV3o6zTaprTJ+ZOSSQpIQ6kbtx9z8p 9u0ZmAOzyEjn6LQk2SMOi4SPX7F7H7p+bZ0gYB7m3X+vWOSWFYGzJ4U39h/NXIIw69Kd 6O/q++OZjFU5IoA+jZVU86Bh12XwvPg63UZwr1sRmieQj447iZHCkg0Rvd/qIMD5I3RX 6X8g== X-Gm-Message-State: AOAM532ofBERH8PO5CoU2ZW9FBitN4Da4kYQoWuPi55Q9e6ZlEIzfZqx t2UIfjqo2kihPZlDirgvwCAGsMuA X-Google-Smtp-Source: ABdhPJyRH2+aPnRrC0zh854reLPDhJihnNvupmtnylhjqPZmslPnqqJCsTysj9OXBE675MNHWcjGGA== X-Received: by 2002:a63:bc02:: with SMTP id q2mr3217163pge.198.1612512385535; Fri, 05 Feb 2021 00:06:25 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id 32sm9520070pgq.80.2021.02.05.00.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 00:06:24 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Daniel Vetter , Christian Koenig , Sumit Semwal , Liam Mark , Chris Goldsworthy , Laura Abbott , Brian Starkey , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , Daniel Mentz , =?utf-8?q?=C3=98rjan_Eide?= , Robin Murphy , Ezequiel Garcia , Simon Ser , James Jones , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [RFC][PATCH v6 0/7] Generic page pool & deferred freeing for system dmabuf heap Date: Fri, 5 Feb 2021 08:06:14 +0000 Message-Id: <20210205080621.3102035-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 This series is starting to get long, so I figured I'd add a short cover letter for context. The point of this series is trying to add both deferred-freeing logic as well as a page pool to the DMA-BUF system heap. This is desired, as the combination of deferred freeing along with the page pool allows us to offload page-zeroing out of the allocation hot path. This was done originally with ION and this patch series allows the DMA-BUF system heap to match ION's system heap allocation performance in a simple microbenchmark [1] (ION re-added to the kernel for comparision, running on an x86 vm image): ./dmabuf-heap-bench -i 0 1 system Testing dmabuf system vs ion heaptype 0 (flags: 0x1) --------------------------------------------- dmabuf heap: alloc 4096 bytes 5000 times in 86572223 ns 17314 ns/call ion heap: alloc 4096 bytes 5000 times in 97442526 ns 19488 ns/call dmabuf heap: alloc 1048576 bytes 5000 times in 196635057 ns 39327 ns/call ion heap: alloc 1048576 bytes 5000 times in 357323629 ns 71464 ns/call dmabuf heap: alloc 8388608 bytes 5000 times in 3165445534 ns 633089 ns/call ion heap: alloc 8388608 bytes 5000 times in 3699591271 ns 739918 ns/call dmabuf heap: alloc 33554432 bytes 5000 times in 13327402517 ns 2665480 ns/call ion heap: alloc 33554432 bytes 5000 times in 15292352796 ns 3058470 ns/call Daniel didn't like earlier attempts to re-use the network page-pool code to achieve this, and suggested the ttm_pool be used instead. This required pulling the fairly tightly knit ttm_pool logic apart, but after many failed attmempts I think I found a workable abstraction to split out shared logic. So this series contains a new generic drm_page_pool helper library, converts the ttm_pool to use it, and then adds the dmabuf deferred freeing and adds support to the dmabuf system heap to use both deferred freeing and the new drm_page_pool. Input would be greatly appreciated. Testing as well, as I don't have any development hardware that utilizes the ttm pool. thanks -john [1] https://android.googlesource.com/platform/system/memory/libdmabufheap/+/refs/heads/master/tests/dmabuf_heap_bench.c Cc: Daniel Vetter Cc: Christian Koenig Cc: Sumit Semwal Cc: Liam Mark Cc: Chris Goldsworthy Cc: Laura Abbott Cc: Brian Starkey Cc: Hridya Valsaraju Cc: Suren Baghdasaryan Cc: Sandeep Patil Cc: Daniel Mentz Cc: Ørjan Eide Cc: Robin Murphy Cc: Ezequiel Garcia Cc: Simon Ser Cc: James Jones Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org John Stultz (7): drm: Add a sharable drm page-pool implementation drm: ttm_pool: Rename the ttm_pool_dma structure to ttm_pool_page_dat drm: ttm_pool: Rework ttm_pool_free_page to allow us to use it as a function pointer drm: ttm_pool: Rework ttm_pool to use drm_page_pool dma-buf: heaps: Add deferred-free-helper library code dma-buf: system_heap: Add drm pagepool support to system heap dma-buf: system_heap: Add deferred freeing to the system heap drivers/dma-buf/heaps/Kconfig | 5 + drivers/dma-buf/heaps/Makefile | 1 + drivers/dma-buf/heaps/deferred-free-helper.c | 145 ++++++++++ drivers/dma-buf/heaps/deferred-free-helper.h | 55 ++++ drivers/dma-buf/heaps/system_heap.c | 77 ++++- drivers/gpu/drm/Kconfig | 5 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/page_pool.c | 220 +++++++++++++++ drivers/gpu/drm/ttm/ttm_pool.c | 278 ++++++------------- include/drm/page_pool.h | 54 ++++ include/drm/ttm/ttm_pool.h | 23 +- 11 files changed, 639 insertions(+), 225 deletions(-) create mode 100644 drivers/dma-buf/heaps/deferred-free-helper.c create mode 100644 drivers/dma-buf/heaps/deferred-free-helper.h create mode 100644 drivers/gpu/drm/page_pool.c create mode 100644 include/drm/page_pool.h -- 2.25.1