From patchwork Thu Mar 4 23:20:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 393456 Delivered-To: patches@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp386040jai; Thu, 4 Mar 2021 15:20:15 -0800 (PST) X-Received: by 2002:a65:4887:: with SMTP id n7mr5617665pgs.14.1614900015028; Thu, 04 Mar 2021 15:20:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614900015; cv=none; d=google.com; s=arc-20160816; b=sVpgnEHv8p8q67WcWBjkuRHluPC8lMPCbGn8qWhcJL96yiXvR7+4PYGkB68GDMZ7rE Epft21DZeFZJBIgDkGHFnicRlia63goOM1us8bjli1UXsOgUMy5XnzGCumtQy596mzTG qlhzD/R5Bl7MNMOM5bujXtxUS8F4eXAyXswr3PEGS/vmVk8ifMEJHVNX8DjmLI6kXN6h 8Nj4kOfpqu1sJRzkGZNsyw2Dy5tN5itU/IlP8QTZafqQ36O7VSkYLOyG8GyjZ7+W3d6/ aHxRC27VUEW3ZIwrKiSfa5BWIBnGaNefC7qCGSV7Stqht/h/mR9UBzrHGxxQLTHBNFIT 0glQ== 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=+EANd2tRGWvmXdhTmEOwaAXoG0qnppr8pGCskqJFHYs=; b=de5CiJ6V52161RWurvuQ+FFuafKg2lOgxYJ/VlK+PHd34tLN3fJXWJcH+NuaOVF9i+ XUz+s3HBWwY9YJ64U2TpA8DS2oMFqJHhJ32qaxHeXGNfRQU6W0Pzus9k19eP+RpiAxJT pSeUlD98z8Y1oL/y1CfpQJmopdlj5STcI6p8BP1nPTC6oevEQ6W4NJz7W5aUuq0J/4Lu KacfBtXjzNgRPWEElu2tyFh06JFJhGILG/HPKbrbvqbkfloUfjVG/FIGkNzAhz2yeKjX bZzsyDw5GdF4oMhVKhccBjEGd+Ug9/5pRyxSBG00/iQ4arZ7yR9KeFzcwFABQuIKSXTj B4Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZFSDIozV; 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 t5sor356258pjw.3.2021.03.04.15.20.14 for (Google Transport Security); Thu, 04 Mar 2021 15:20:14 -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=ZFSDIozV; 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=+EANd2tRGWvmXdhTmEOwaAXoG0qnppr8pGCskqJFHYs=; b=ZFSDIozVIFv6zCoAj7sUaWo8JzEhkFk809bGmP5eqBhXz8HlO8x0LZku24pJEkIIwa qgfhanKnmUJFgNSBGk1C14aYHEBBZKzjctwEjXkGITD4xGuw3TbvKlFOxMYzIJDKJm/h QWDotQGdW1sMk7JzocHXjrCyYJAZiezCeUV4t4FHKe1HKPx4MLpUrCT8d9kYY5yF4AHp nUqxEWXDL/R9cOZDsS9VDSM7qFj4F3HAEhZmgj5kCjU1mnrcbwMoykRBTQSh0rSPxOdU JpfU73vxxXocX7vZrM8PeGr44WwQ5ZdoiIevN23YeSzijVosUtpwWaJbNlgwoO2KZYwB 4cWw== 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=+EANd2tRGWvmXdhTmEOwaAXoG0qnppr8pGCskqJFHYs=; b=svKyGkVS/I47Hc+MJwIkIP1k02JzVEC+pP+iElFtbUfORjqnIxkmQP294wJACdvpdX rI/Hhp7eATpDyqJv2vuVp7iWUgw2utZ9IrdLqezB0vds0PljxGvNSX0LW32vARlsmkZ6 Xhu33CM8m/U4yY2e5JiXkmJIUj6SywDYJL03igzNk5bfHGNWuE6zX1J9Lt76nAwFUTGl y4jUSmZWTuNB1s7V07a/hVo1raKkTwOh+NDXapf3mXYiX8szDVY8tI50S7fUAEqcHYnO sNP1SUlq33/fvwvGeyN1mzmsx/Dxt1P7iNhWYttVrc6Ai+2OH2qT15n6TDw7CTWEqDeT K/Uw== X-Gm-Message-State: AOAM5327Ll/Gnspp/UD24u7TJnYGdORfG3Lukm9eTOwmNI6zkuMEDjbY POEzDiiw3GWdPACnUg+XAJ+QkMp1 X-Google-Smtp-Source: ABdhPJyoEtjiav4GuVm1KSuipTRUYsjeq30jwUl5tmbEj3jjUn+SWiHYkQhxAf1JtZSw+uVbrfU+dA== X-Received: by 2002:a17:90a:9604:: with SMTP id v4mr6914960pjo.201.1614900014616; Thu, 04 Mar 2021 15:20:14 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id u66sm429290pfc.72.2021.03.04.15.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 15:20:13 -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: [PATCH v8 0/5] Generic page pool & deferred freeing for system dmabuf heap Date: Thu, 4 Mar 2021 23:20:06 +0000 Message-Id: <20210304232011.1479036-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Apologies for letting so much time pass since the last revision! 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 to improve allocation performance. 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 88092722 ns 17618 ns/call ion heap: alloc 4096 bytes 5000 times in 103043547 ns 20608 ns/call dmabuf heap: alloc 1048576 bytes 5000 times in 252416639 ns 50483 ns/call ion heap: alloc 1048576 bytes 5000 times in 358190744 ns 71638 ns/call dmabuf heap: alloc 8388608 bytes 5000 times in 2854351310 ns 570870 ns/call ion heap: alloc 8388608 bytes 5000 times in 3676328905 ns 735265 ns/call dmabuf heap: alloc 33554432 bytes 5000 times in 13208119197 ns 2641623 ns/call ion heap: alloc 33554432 bytes 5000 times in 15306975287 ns 3061395 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, so this series pulls the page pool functionality out of the ttm_pool logic and creates a generic page pool that can be shared. New in v7 (never submitted): * Reworked how I integrated the page pool with the ttm logic to use container of to avoid allocating structures per page. New in v8: * Due to the dual license requirement from Christian König I completely threw away the earlier shared page pool implementation (which had evolved from ion code), and rewrote it using just the ttm_pool logic. My apologies for any previously reviewed issues that I've reintroduced in doing so. 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 (5): drm: Add a sharable drm page-pool implementation 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 | 138 ++++++++++++ drivers/dma-buf/heaps/deferred-free-helper.h | 55 +++++ drivers/dma-buf/heaps/system_heap.c | 47 +++- drivers/gpu/drm/Kconfig | 5 + drivers/gpu/drm/Makefile | 2 + drivers/gpu/drm/page_pool.c | 214 +++++++++++++++++++ drivers/gpu/drm/ttm/ttm_pool.c | 156 +++----------- include/drm/page_pool.h | 65 ++++++ include/drm/ttm/ttm_pool.h | 6 +- 11 files changed, 557 insertions(+), 137 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