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: 11801109 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2031616BC for ; Sat, 26 Sep 2020 04:25:01 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C5DA32080A for ; Sat, 26 Sep 2020 04:25:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mVKL30wy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5DA32080A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8157D6E122; Sat, 26 Sep 2020 04:24:58 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1B4976E122 for ; Sat, 26 Sep 2020 04:24:57 +0000 (UTC) Received: by mail-pl1-x644.google.com with SMTP id x5so185037plo.6 for ; Fri, 25 Sep 2020 21:24:57 -0700 (PDT) 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=Wf58Hv6UUA8CHr/OI/ktdkALvxyUHuse1RNgDIOoTMO6plUVr8L9IPSTqDl0gMv/ut DJ+cgxzZYJ9bzWjan4ZrZ43epLps3cyIDW2JkXS6ZuiS/vaUmfonKoFWhOIOHUQ0V5w2 IreDFfeMGpUwLsAbM3CD+4S9s7AbsYRuC/BqhLXJ6VBF6ggUVViYhVmDG6CcltjxnTb8 LX1/uI/mehy3pcU3hx0xEMFxZF8nbmHbbakTozPqd/YUSzLWlCwKip04ay30DI2I7s9A DYxSc/++HYexIpgSPSAeqzsOf85WtrJXbNaqKr79nOWpkXoW7iFm9+w1qrVXppBlYvc4 at/Q== X-Gm-Message-State: AOAM533npBjsOXdulst+NusGuRSM9iW7sdwYCusY75G/G1xcDQHz6Ab2 GHtdTNxH4C53KtieNbe1WoVJOw== 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) 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sandeep Patil , dri-devel@lists.freedesktop.org, Ezequiel Garcia , Robin Murphy , James Jones , Liam Mark , Laura Abbott , Hridya Valsaraju , =?utf-8?q?=C3=98rjan_Eide?= , Suren Baghdasaryan , linux-media@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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