All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/7] dma-buf: Performance improvements for system heap & a system-uncached implementation
@ 2020-10-03  4:02 ` John Stultz
  0 siblings, 0 replies; 42+ messages in thread
From: John Stultz @ 2020-10-03  4:02 UTC (permalink / raw)
  To: lkml
  Cc: John Stultz, Sumit Semwal, Liam Mark, Laura Abbott,
	Brian Starkey, Hridya Valsaraju, Suren Baghdasaryan,
	Sandeep Patil, Daniel Mentz, Chris Goldsworthy, Ørjan Eide,
	Robin Murphy, Ezequiel Garcia, Simon Ser, James Jones,
	linux-media, dri-devel

Hey All,
  So this is another revision of my patch series to 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 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 code.

Unfortunately, after submitting the last round, I realized that
part of the reason the page-pooling patch I had included was
providing such great performance numbers, was because the
network page-pool implementation doesn't zero pages that it
pulls from the cache. This is very inappropriate for buffers we
pass to userland and was what gave it an unfair advantage
(almost constant time performance) relative to ION's allocation
performance numbers. I added some patches to zero the buffers
manually similar to how ION does it, but I found this resulted
in basically no performance improvement from the standard page
allocator. Thus I've dropped that patch in this series for now.

Unfortunately this means we still have a performance delta from
the ION system heap as measured by my microbenchmark, and this
delta comes from ION system_heap's use of deferred freeing of
pages. So less work is done in the measured interval of the
microbenchmark. I'll be looking at adding similar code
eventually but I don't want to hold the rest of the patches up
on this, as it is still a good improvement over the current
code.

I've updated the chart I shared earlier with current numbers
(including with the unsubmitted net pagepool implementation, and
with a different unsubmitted pagepool implementation borrowed
from ION) here:
https://docs.google.com/spreadsheets/d/1-1C8ZQpmkl_0DISkI6z4xelE08MlNAN7oEu34AnO4Ao/edit?usp=sharing

I did add to this series 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 implementaiton 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 v3:
* Dropped page-pool patches as after correcting the code to
  zero buffers, they provided no net performance gain.
* Added system-uncached implementation ontop of reworked
  system-heap.
* Use the new sgtable mapping functions, in the system and cma
  code  as Suggested-by: Daniel Mentz <danielmentz@google.com>
* Cleanup: Use page_size() rather then open-coding it



Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Liam Mark <lmark@codeaurora.org>
Cc: Laura Abbott <labbott@kernel.org>
Cc: Brian Starkey <Brian.Starkey@arm.com>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Sandeep Patil <sspatil@google.com>
Cc: Daniel Mentz <danielmentz@google.com>
Cc: Chris Goldsworthy <cgoldswo@codeaurora.org>
Cc: Ørjan Eide <orjan.eide@arm.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Ezequiel Garcia <ezequiel@collabora.com>
Cc: Simon Ser <contact@emersion.fr>
Cc: James Jones <jajones@nvidia.com>
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     | 327 +++++++++++++++---
 drivers/dma-buf/heaps/heap-helpers.c | 271 ---------------
 drivers/dma-buf/heaps/heap-helpers.h |  53 ---
 drivers/dma-buf/heaps/system_heap.c  | 480 ++++++++++++++++++++++++---
 include/linux/dma-heap.h             |   9 +
 7 files changed, 741 insertions(+), 433 deletions(-)
 delete mode 100644 drivers/dma-buf/heaps/heap-helpers.c
 delete mode 100644 drivers/dma-buf/heaps/heap-helpers.h

-- 
2.17.1


^ permalink raw reply	[flat|nested] 42+ messages in thread
* Re: [PATCH v3 7/7] dma-buf: system_heap: Add a system-uncached heap re-using the system heap
@ 2020-10-03  8:24 kernel test robot
  0 siblings, 0 replies; 42+ messages in thread
From: kernel test robot @ 2020-10-03  8:24 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 1976 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20201003040257.62768-8-john.stultz@linaro.org>
References: <20201003040257.62768-8-john.stultz@linaro.org>
TO: John Stultz <john.stultz@linaro.org>
TO: lkml <linux-kernel@vger.kernel.org>
CC: John Stultz <john.stultz@linaro.org>
CC: Sumit Semwal <sumit.semwal@linaro.org>
CC: Liam Mark <lmark@codeaurora.org>
CC: Laura Abbott <labbott@kernel.org>
CC: Brian Starkey <Brian.Starkey@arm.com>
CC: Hridya Valsaraju <hridya@google.com>
CC: Suren Baghdasaryan <surenb@google.com>
CC: Sandeep Patil <sspatil@google.com>
CC: Daniel Mentz <danielmentz@google.com>

Hi John,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on tegra-drm/drm/tegra/for-next linus/master v5.9-rc7]
[cannot apply to next-20201002]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/John-Stultz/dma-buf-Performance-improvements-for-system-heap-a-system-uncached-implementation/20201003-120520
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git bcf876870b95592b52519ed4aafcf9d95999bc9c
:::::: branch date: 4 hours ago
:::::: commit date: 4 hours ago
config: i386-randconfig-c001-20201002 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>

	echo
	echo "coccinelle warnings: (new ones prefixed by >>)"
	echo
>> drivers/dma-buf/heaps/system_heap.c:495:5-11: inconsistent IS_ERR and PTR_ERR on line 496.

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 29576 bytes --]

^ permalink raw reply	[flat|nested] 42+ messages in thread
* Re: [PATCH v3 7/7] dma-buf: system_heap: Add a system-uncached heap re-using the system heap
@ 2020-10-03 17:41 kernel test robot
  0 siblings, 0 replies; 42+ messages in thread
From: kernel test robot @ 2020-10-03 17:41 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 3397 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20201003040257.62768-8-john.stultz@linaro.org>
References: <20201003040257.62768-8-john.stultz@linaro.org>
TO: John Stultz <john.stultz@linaro.org>
TO: lkml <linux-kernel@vger.kernel.org>
CC: John Stultz <john.stultz@linaro.org>
CC: Sumit Semwal <sumit.semwal@linaro.org>
CC: Liam Mark <lmark@codeaurora.org>
CC: Laura Abbott <labbott@kernel.org>
CC: Brian Starkey <Brian.Starkey@arm.com>
CC: Hridya Valsaraju <hridya@google.com>
CC: Suren Baghdasaryan <surenb@google.com>
CC: Sandeep Patil <sspatil@google.com>
CC: Daniel Mentz <danielmentz@google.com>

Hi John,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on tegra-drm/drm/tegra/for-next linus/master v5.9-rc7]
[cannot apply to next-20201002]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/John-Stultz/dma-buf-Performance-improvements-for-system-heap-a-system-uncached-implementation/20201003-120520
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git bcf876870b95592b52519ed4aafcf9d95999bc9c
:::::: branch date: 14 hours ago
:::::: commit date: 14 hours ago
config: i386-randconfig-m021-20201002 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/dma-buf/heaps/system_heap.c:496 system_heap_create() warn: passing zero to 'PTR_ERR'

vim +/PTR_ERR +496 drivers/dma-buf/heaps/system_heap.c

553f4e0fafc5b3b John Stultz     2020-10-03  477  
efa04fefebbd724 John Stultz     2019-12-03  478  static int system_heap_create(void)
efa04fefebbd724 John Stultz     2019-12-03  479  {
efa04fefebbd724 John Stultz     2019-12-03  480  	struct dma_heap_export_info exp_info;
efa04fefebbd724 John Stultz     2019-12-03  481  
263e38f82cbb35b Andrew F. Davis 2019-12-16  482  	exp_info.name = "system";
efa04fefebbd724 John Stultz     2019-12-03  483  	exp_info.ops = &system_heap_ops;
efa04fefebbd724 John Stultz     2019-12-03  484  	exp_info.priv = NULL;
efa04fefebbd724 John Stultz     2019-12-03  485  
efa04fefebbd724 John Stultz     2019-12-03  486  	sys_heap = dma_heap_add(&exp_info);
efa04fefebbd724 John Stultz     2019-12-03  487  	if (IS_ERR(sys_heap))
a2e10cdd2e4d12a John Stultz     2020-10-03  488  		return PTR_ERR(sys_heap);
efa04fefebbd724 John Stultz     2019-12-03  489  
553f4e0fafc5b3b John Stultz     2020-10-03  490  	exp_info.name = "system-uncached";
553f4e0fafc5b3b John Stultz     2020-10-03  491  	exp_info.ops = &system_uncached_heap_ops;
553f4e0fafc5b3b John Stultz     2020-10-03  492  	exp_info.priv = NULL;
553f4e0fafc5b3b John Stultz     2020-10-03  493  
553f4e0fafc5b3b John Stultz     2020-10-03  494  	sys_uncached_heap = dma_heap_add(&exp_info);
553f4e0fafc5b3b John Stultz     2020-10-03  495  	if (IS_ERR(sys_uncached_heap))
553f4e0fafc5b3b John Stultz     2020-10-03 @496  		return PTR_ERR(sys_heap);

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 32558 bytes --]

^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2021-01-29  8:12 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-03  4:02 [PATCH v3 0/7] dma-buf: Performance improvements for system heap & a system-uncached implementation John Stultz
2020-10-03  4:02 ` John Stultz
2020-10-03  4:02 ` [PATCH v3 1/7] dma-buf: system_heap: Rework system heap to use sgtables instead of pagelists John Stultz
2020-10-03  4:02   ` John Stultz
2020-10-03  4:02 ` [PATCH v3 2/7] dma-buf: heaps: Move heap-helper logic into the cma_heap implementation John Stultz
2020-10-03  4:02   ` John Stultz
2020-10-03  4:02 ` [PATCH v3 3/7] dma-buf: heaps: Remove heap-helpers code John Stultz
2020-10-03  4:02   ` John Stultz
2020-10-03  4:02 ` [PATCH v3 4/7] dma-buf: heaps: Skip sync if not mapped John Stultz
2020-10-03  4:02   ` John Stultz
2020-10-03  4:02 ` [PATCH v3 5/7] dma-buf: system_heap: Allocate higher order pages if available John Stultz
2020-10-03  4:02   ` John Stultz
2020-10-03  4:02 ` [PATCH v3 6/7] dma-buf: dma-heap: Keep track of the heap device struct John Stultz
2020-10-03  4:02   ` John Stultz
2020-10-03  4:02 ` [PATCH v3 7/7] dma-buf: system_heap: Add a system-uncached heap re-using the system heap John Stultz
2020-10-03  4:02   ` John Stultz
2020-10-05 13:45   ` Christoph Hellwig
2020-10-08  5:03     ` John Stultz
2020-10-08  5:03       ` John Stultz
2020-10-05 21:21   ` kernel test robot
2020-10-05 21:21     ` kernel test robot
2020-10-05 21:21   ` [RFC PATCH] dma-buf: system_heap: sys_uncached_heap can be static kernel test robot
2020-10-05 21:21     ` kernel test robot
2020-10-07  7:43   ` [PATCH v3 7/7] dma-buf: system_heap: Add a system-uncached heap re-using the system heap Dan Carpenter
2020-10-07  7:43     ` Dan Carpenter
2020-10-07  7:43     ` Dan Carpenter
2020-10-08  5:38     ` John Stultz
2020-10-08  5:38       ` John Stultz
2020-10-08 11:51   ` Brian Starkey
2020-10-08 11:51     ` Brian Starkey
2020-10-16 19:03     ` John Stultz
2020-10-16 19:03       ` John Stultz
2020-10-16 23:15       ` John Stultz
2020-10-16 23:15         ` John Stultz
2021-01-29  1:23       ` Daniel Mentz
2021-01-29  1:23         ` Daniel Mentz
2020-10-08 11:36 ` [PATCH v3 0/7] dma-buf: Performance improvements for system heap & a system-uncached implementation Brian Starkey
2020-10-08 11:36   ` Brian Starkey
2020-10-16 18:47   ` John Stultz
2020-10-16 18:47     ` John Stultz
2020-10-03  8:24 [PATCH v3 7/7] dma-buf: system_heap: Add a system-uncached heap re-using the system heap kernel test robot
2020-10-03 17:41 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.