From patchwork Sat Sep 26 04:24:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 313563 Delivered-To: patches@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp1680516ilg; Fri, 25 Sep 2020 21:24:57 -0700 (PDT) X-Received: by 2002:a63:440e:: with SMTP id r14mr1531465pga.277.1601094297126; Fri, 25 Sep 2020 21:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601094297; cv=none; d=google.com; s=arc-20160816; b=WTkyVyFH6DeP7JVNqo15F2xc9DF4IKdKXyAc4cPuNT2hq2GC+NB+gvj+uO90jI4wxh dGtQWl/WV96zwUY8e+cMtkOJdEFHDfUI2GGhsUZAt7UteCIJE7Om7vUIcaHOCWI7/7IP c1dMSTTLJRtavbQXbmbge90pKgEFYbYx9FvRwsLIvQj7G2SC6IT7okD3ndNwiuQwfLeu eJSu8aDAgLjQq4f57iHJv3hl7+5Ar34xNvD2DRFanpDIWrF34xeHOk+rEgW9QHeOYMoG lgQ2cWtvM027+8EHtZrucYeo5Nc968MxyV5qYiOIC/63n8+8LC2YjntK1P+dH6tQ4jYm i2Ng== 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=u7Z9AmMaAX9Vb4Ld53icr/xLpCufMXVRoWb2ypLsc80=; b=ICHLX5jJSGK++s0Xyw/Sghph0CVhiPqtavRhn2J8d0E/IahqBAyOrPPHkcKa26SlSI wq8Y0mLICS3Cd6/7vkR6Foe5xL9WlWK3NW6uASbog6keWkfnmYWLdppNc+5h7FqB7RM1 U3Hp0ArgBJc/pt1cEdZEgA8P0hKrevpYu0mkv4HPKjxWsCP51ELn+QuIMP9QsVDLhz7n 7IhPux+BbSnpSeYS8PmcPj3UNeNP1CrTSjnqnyuyflPT7CDfBvGLTNfwkSowBI5cRsUG YxLEm1r/k/Rx5K2y+EwqEcDZss7RgMtTg6OJEqJjDGAZ7CUUmfWVFccb1LenCp7Dwnbs QbDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mVKL30wy; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id h2sor2884640plt.14.2020.09.25.21.24.56 for (Google Transport Security); Fri, 25 Sep 2020 21:24:57 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mVKL30wy; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 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=u7Z9AmMaAX9Vb4Ld53icr/xLpCufMXVRoWb2ypLsc80=; b=mVKL30wyp8QWxrO/AXPzbqcUkAgUwQ5PQLPtaTkJUo85MCgp0lLqI759YCjmqYCkfo 0vofLOZ+oqHZEyalKS9grgA6QsTsHTLZUVGmcmn4NXUp+sOGw9tqWOL6ubqGxS3Nrc00 q7tnYBkMjfrG4/lWYFeHodZ7QGCewEqSZ6IsvQh/3ZR0RsD03VrR8qY1GpHDuym1lq5x vmaDqZ8UEYL5EXf8Wktjix4s29ercJuTkpkr1blwjS1MwNlPlh5wQKPWzsMsYaIxYeKr psDWBvDxbJDar9sPHmE6joj+ftiS9KY4vzTpm7AdJVQcwhLAOkWQl4oK2hkRKUtga3cW uDPA== 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=u7Z9AmMaAX9Vb4Ld53icr/xLpCufMXVRoWb2ypLsc80=; b=WI5eZ1L2mrNTeqRjxGS3j9wNZeEqbJlBPT36g6NO4NLeTCIEIWh4pkuDNG2WLIKEXe 67rlW9ljPmgb4XNfowqUCavaKUWOj6CZRvGquT8x+JCsNst1bynbfyZmj1DiFM+Lps+E iC7eW5blU0t7vYiqw8KQOauAiAfGN+N3oLf9EFV9w01VEArULvGg7YWhtBca/TOsE+HA uDcRfFi0lb17RMscB8XsHiikDAFFMAEbqk4uS6fPSj8O8Vwriq4BXkxlcOzeu5NEDPJK xBJASZjfVebGum+qynnfo+CFnD7nZgBp0d6cUHNC4oUF7lPtupZAeEGmsOvnXBeeWq83 ml2g== X-Gm-Message-State: AOAM532IkX+TTVI2etq0ASNtmAK/KPkOegrTVcmSsrxDgNz8y446GPFK SGRaVgYZDswMq3QuXJaZ6E7TRFE0 X-Google-Smtp-Source: ABdhPJzK4xRnW4GQ7wUmaWVVtyqAzUaT2hQgL6Vkyx4xR/37YLk5BaJvFuZ7unQ2rLB0zWZJPt03KQ== X-Received: by 2002:a17:902:8347:b029:d1:f365:6fb5 with SMTP id z7-20020a1709028347b02900d1f3656fb5mr2420471pln.61.1601094296568; Fri, 25 Sep 2020 21:24:56 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id a5sm3585886pgk.13.2020.09.25.21.24.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Sep 2020 21:24:55 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Sumit Semwal , Liam Mark , Laura Abbott , Brian Starkey , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , =?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 0/6] dma-buf: Performance improvements for system heap Date: Sat, 26 Sep 2020 04:24:47 +0000 Message-Id: <20200926042453.67517-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Hey All, So this patch series contains a series of performance optimizations to the dma-buf system heap. Unfortunately, in working these up, I realized the heap-helpers infrastructure we tried to add to miniimize code duplication is not as generic as we intended. For some heaps it makes sense to deal with page lists, for other heaps it makes more sense to track things with sgtables. So this series reworks the system heap to use sgtables, and then consolidates the pagelist method from the heap-helpers into the CMA heap. After which the heap-helpers logic is removed (as it is unused). I'd still like to find a better way to avoid some of the logic duplication in implementing the entire dma_buf_ops handlers per heap. But unfortunately that code is tied somewhat to how the buffer's memory is tracked. After this, the series introduces two optimizations to the the system heap, utilizing large order pages, and adding a page-pool (maybe abusing the pagepool logic from the network code, but it seems silly to reimplement it). I implemented a simple allocation microbenchmark to compare dmabuf heaps vs ion: https://git.linaro.org/people/john.stultz/android-dev.git/commit/?h=dev/dma-buf-heap-perf&id=e33aabd34b300f8f8be8d71ec7253dd0abe702f2 With these changes, the allocation path is *much* improved, performing better then ION (though to be fair, the repeated allocating and freeing of the same size buffer is the ideal case for the pagepool logic, so don't read too much into it). I charted some datapoints from the microbenchmark with each of the patches should folks be interested. https://docs.google.com/spreadsheets/d/1-1C8ZQpmkl_0DISkI6z4xelE08MlNAN7oEu34AnO4Ao/edit#gid=0 Finally, a port of a patch that Ørjan Eide implemented for ION that avoids calling sync on attachments that don't have a mapping. Feedback on these would be great! Cc: Sumit Semwal Cc: Liam Mark Cc: Laura Abbott Cc: Brian Starkey Cc: Hridya Valsaraju Cc: Suren Baghdasaryan Cc: Sandeep Patil 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 (6): dma-buf: system_heap: Rework system heap to use sgtables instead of pagelists dma-buf: heaps: Move heap-helper logic into the cma_heap implementation dma-buf: heaps: Remove heap-helpers code dma-buf: system_heap: Allocate higher order pages if available dma-buf: system_heap: Add pagepool support to system heap dma-buf: heaps: Skip sync if not mapped drivers/dma-buf/heaps/Kconfig | 1 + drivers/dma-buf/heaps/Makefile | 1 - drivers/dma-buf/heaps/cma_heap.c | 332 +++++++++++++++++---- drivers/dma-buf/heaps/heap-helpers.c | 271 ----------------- drivers/dma-buf/heaps/heap-helpers.h | 53 ---- drivers/dma-buf/heaps/system_heap.c | 426 ++++++++++++++++++++++++--- 6 files changed, 660 insertions(+), 424 deletions(-) delete mode 100644 drivers/dma-buf/heaps/heap-helpers.c delete mode 100644 drivers/dma-buf/heaps/heap-helpers.h -- 2.17.1