From patchwork Thu Oct 29 00:16:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 319294 Delivered-To: patches@linaro.org Received: by 2002:a17:906:3bd4:0:0:0:0 with SMTP id v20csp25911ejf; Wed, 28 Oct 2020 17:16:29 -0700 (PDT) X-Received: by 2002:a17:90a:6882:: with SMTP id a2mr10354pjd.110.1603930589542; Wed, 28 Oct 2020 17:16:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603930589; cv=none; d=google.com; s=arc-20160816; b=pnivE0pqRKBrZKXA6f+7JR5WM3GzUWvCPeDZwpATxi0icPMUsKqzkbbJ+VEZkRD7tK 7UTCAENmb+np1RCQoyi1NulERiyUCfCxhv7fGbHCQglue+KZ9HlVo9IjFJm+xe2h24m0 0XkOxCySCIuEHpsWFTg7AH4BWm3dBJmxK+q69JaqvLMg4Wd3Xn9t0Eqyo2lCK54AgqeG BrvpiLzpO7HnU7SDGrVuwRcS2N4vJs7yIaEg3zhXoy63gzJsl9dzxnpYVm1ioxqkhHzH ANXqlsoobmuuE8GSDnhRNdKvI56TCAQiGh95ZFzSxQEZGZ0+rwY/PP+y9ro4h5doeG8X rLiQ== 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=jowbCdzh73K/7cntCmnI6UArO+IIJYfiMSLMhZBHvp8=; b=o6ZHw8ybLJOsCkGiKNiLnYc0jlRY6/vbD6WWo5jVD8+VicH3rmR1Unz+2v3CO/4WML AwY0rz1sf/P4cB9PMq5eJHco0neDfo5nlt1MZZkVsFJKfeGVOYb6GGxxxoqeoIuzxmOf 0l73+KPmUKFvv5cxKd641c1eUtevUNfmms4+H7mnNwi8kRBjgJhkaz5tZg6TcQYSs786 CLq4BSU18BApbqnJTHJesn9hDK8Qhf+N+vWgaz3RNZWRW/3QbgU+ePl8uFTatG+5ALD8 bGAo3xR1KzsFqESvDWgfXCdPPdmyhoaTRBVaRghB3QQEZYli0nhU8adTeQDsEbTvJycm sLjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BhBEwWL6; 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 s206sor458650pfs.80.2020.10.28.17.16.29 for (Google Transport Security); Wed, 28 Oct 2020 17:16:29 -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=BhBEwWL6; 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=jowbCdzh73K/7cntCmnI6UArO+IIJYfiMSLMhZBHvp8=; b=BhBEwWL6wnxQTQbk7XBsIYPue0uFzes+fPtIQB7xcgYEdWtbnUqHI0JJfzeSMqfp53 QQJPgRVUAyouYlKSNbFhUUHCoOM2N5GdD5cvFqQ9CfXyFf/AioCK0ntpEA4wkNe+/EoA qA6eQ2a5t3kySA9KX96S2N/ORq+IoDiNidx8wrSL6Zp76DL/k392dVFgNdL5Mo2oPFlr W0i8ZBp4ZCCXJmZZJpkhooUGWLscqy+pgS3OGNa0Qd/fQapyli4cuB2jdQI17lpLqArL 9AWCUZSOLPBFK6S2YfAqYbApt0YABB6tB6x4wnXlE1vxmf1+2wFBtgb9O0Mw12OTjwM3 +wWw== 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=jowbCdzh73K/7cntCmnI6UArO+IIJYfiMSLMhZBHvp8=; b=ENGgkh6ehmfNX7mNB+5Jt0Ia//up1KkGDzyvvWGiW6AaGxixSgo9I1nTdbDF0SP5we 9reQBh0vVIEsKx3+S4TK/AheM3aN/7w4lC9sFKHlKfMKk71HIgQGNOqkQUOexUs8NGYD 6R2BVEkwMz7iS0UTOG5DgNp767lMznC+eDIFj68gYHID9ZYpgSNL6B5eLDyPmTQLKpNy T2feOrH9ay83gQZxMmIwI29nhV54ntsordad49O2LMQgmLZFrOlRi2Me1Gbu14nZPepN d9PXTozFGttV3ipdWLws86lQjWW+MyOlxoEMFIY6Xt70fPxjM4htGZTAgV66ozzx8L8h YeAw== X-Gm-Message-State: AOAM530OexOBdUfVmDbd6o5w3UfJVRJUMAOECNJlF4z45/Y6ApPJI8OX grMlQ+y/kitna7OU3sVyUkkKMScU X-Google-Smtp-Source: ABdhPJzj43umkzeNqJmTU/ETb7Ac//OIRSrCtAnyXmttJ54tWbfb9z0CPz1oRqMSlVD5VTFmQgLrSg== X-Received: by 2002:a63:e006:: with SMTP id e6mr1669122pgh.51.1603930588810; Wed, 28 Oct 2020 17:16:28 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id u13sm727407pfl.162.2020.10.28.17.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 17:16:27 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Sumit Semwal , Liam Mark , Laura Abbott , Brian Starkey , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , Daniel Mentz , Chris Goldsworthy , =?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: [RESEND][PATCH v4 0/7] dma-buf: Performance improvements for system heap & a system-uncached implementation Date: Thu, 29 Oct 2020 00:16:17 +0000 Message-Id: <20201029001624.17513-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Hey All, So just wanted to resend my last revision of my patch series of performance optimizations to the dma-buf system heap. 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. As more heaps show up I think we'll have a better idea how to best share code, so for now I think this is ok. After this, the series introduces an optimization that Ørjan Eide implemented for ION that avoids calling sync on attachments that don't have a mapping. Next, an optimization to use larger order pages for the system heap. This change brings us closer to the current performance of the ION allocation code (though there still is a gap due to ION using a mix of deferred-freeing and page pools, I'll be looking at integrating those eventually). Finally, a reworked version of my uncached system heap implementation I was submitting a few weeks back. Since it duplicated a lot of the now reworked system heap code, I realized it would be much simpler to add the functionality to the system_heap implementation itself. While not improving the core allocation performance, the uncached heap allocations do result in *much* improved performance on HiKey960 as it avoids a lot of flushing and invalidating buffers that the cpu doesn't touch often. Feedback on these would be great! thanks -john New in v4: * Make sys_heap static (indirectly) Reported-by: kernel test robot * Spelling fixes suggested by BrianS * Make sys_uncached_heap static, as Reported-by: kernel test robot * Fix wrong return value, caught by smatch Reported-by: kernel test robot Reported-by: Dan Carpenter * Ensure we call flush/invalidate_kernel_vmap_range() in the uncached cases to try to address feedback about VIVT caches from Christoph * Reorder a few lines as suggested by BrianS * Avoid holding the initial mapping for the lifetime of the buffer as suggested by BrianS * Fix a unlikely race between allocate and updating the dma_mask that BrianS noticed. Cc: Sumit Semwal Cc: Liam Mark Cc: Laura Abbott Cc: Brian Starkey Cc: Hridya Valsaraju Cc: Suren Baghdasaryan Cc: Sandeep Patil Cc: Daniel Mentz Cc: Chris Goldsworthy 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): 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: heaps: Skip sync if not mapped dma-buf: system_heap: Allocate higher order pages if available dma-buf: dma-heap: Keep track of the heap device struct dma-buf: system_heap: Add a system-uncached heap re-using the system heap drivers/dma-buf/dma-heap.c | 33 +- drivers/dma-buf/heaps/Makefile | 1 - drivers/dma-buf/heaps/cma_heap.c | 324 +++++++++++++++--- drivers/dma-buf/heaps/heap-helpers.c | 270 --------------- drivers/dma-buf/heaps/heap-helpers.h | 53 --- drivers/dma-buf/heaps/system_heap.c | 488 ++++++++++++++++++++++++--- include/linux/dma-heap.h | 9 + 7 files changed, 747 insertions(+), 431 deletions(-) delete mode 100644 drivers/dma-buf/heaps/heap-helpers.c delete mode 100644 drivers/dma-buf/heaps/heap-helpers.h -- 2.17.1