Chunk Heap Support on DMA-HEAP
Subsystems (5)
A message that is not in the archive (sent off-list or not yet received): CGME20200818074547epcas2p21e0c2442873d03800c7bc2c3e76405d6@epcas2p2.samsung.com
cover Chunk Heap Support on DMA-HEAP
These patch series to introduce a new dma heap, chunk heap. That heap is needed for special HW that requires bulk allocation of fixed high order pages. For example, 64MB dma-buf pages are made up to fixed order-4 pages * 1024.
The chunk heap uses alloc_pages_bulk to allocate high order page.
https://lore.kernel.org/linux-mm/[email protected]
The chunk heap is registered by device tree with alignment and memory node of contiguous memory allocator(CMA). Alignment defines chunk page size. For example, alignment 0x1_0000 means chunk page size is 64KB. The phandle to memory node indicates contiguous memory allocator(CMA). If device node doesn't have cma, the registration of chunk heap fails.
The patchset includes the following:
- export dma-heap API to register kernel module dma heap.
- add chunk heap implementation.
- document of device tree to register chunk heap
Hyesoo Yu (3):
dma-buf: add missing EXPORT_SYMBOL_GPL() for dma heaps
dma-buf: heaps: add chunk heap to dmabuf heaps
dma-heap: Devicetree binding for chunk heap
.../devicetree/bindings/dma-buf/chunk_heap.yaml | 46 +++++ drivers/dma-buf/dma-heap.c | 2 + drivers/dma-buf/heaps/Kconfig | 9 + drivers/dma-buf/heaps/Makefile | 1 + drivers/dma-buf/heaps/chunk_heap.c | 222 +++++++++++++++++++++ drivers/dma-buf/heaps/heap-helpers.c | 2 + 6 files changed, 282 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma-buf/chunk_heap.yaml create mode 100644 drivers/dma-buf/heaps/chunk_heap.c
Signature · 1 line
2.7.4
PATCH 1/3 dma-buf: add missing EXPORT_SYMBOL_GPL() for dma heaps
The interface of dma heap is used from kernel module to register dma heaps, otherwize we will get compile error.
--- drivers/dma-buf/dma-heap.c | 2 ++ drivers/dma-buf/heaps/heap-helpers.c | 2 ++ 2 files changed, 4 insertions(+)
drivers/dma-buf/dma-heap.c +2 -0
@@ -189,6 +189,7 @@ void *dma_heap_get_drvdata(struct dma_heap *heap) {return heap->priv; } +EXPORT_SYMBOL_GPL (dma_heap_get_drvdata);struct dma_heap *dma_heap_add (const struct dma_heap_export_info *exp_info) {
@@ -272,6 +273,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)kfree (heap);return err_ret; } +EXPORT_SYMBOL_GPL (dma_heap_add);static char *dma_heap_devnode (struct device *dev,umode_t *mode) {
drivers/dma-buf/heaps/heap-helpers.c +2 -0
@@ -24,6 +24,7 @@ void init_heap_helper_buffer(struct heap_helper_buffer *buffer,INIT_LIST_HEAD (&buffer->attachments); buffer->free = free; } +EXPORT_SYMBOL_GPL (init_heap_helper_buffer);struct dma_buf *heap_helper_export_dmabuf (struct heap_helper_buffer *buffer,int fd_flags)
@@ -37,6 +38,7 @@ struct dma_buf *heap_helper_export_dmabuf(struct heap_helper_buffer *buffer,return dma_buf_export (&exp_info); } +EXPORT_SYMBOL_GPL (heap_helper_export_dmabuf);static void *dma_heap_map_kernel (struct heap_helper_buffer *buffer) {
Signature · 1 line
2.7.4
PATCH 2/3 dma-buf: heaps: add chunk heap to dmabuf heaps
In reply to Hyesoo YuThis patch adds support for a chunk heap that allows for buffers that are made up of a list of fixed size chunks taken from a CMA. Chunk sizes are configuratd when the heaps are created.
--- drivers/dma-buf/heaps/Kconfig | 9 ++ drivers/dma-buf/heaps/Makefile | 1 + drivers/dma-buf/heaps/chunk_heap.c | 222 +++++++++++++++++++++++++++++++++++++ 3 files changed, 232 insertions(+) create mode 100644 drivers/dma-buf/heaps/chunk_heap.c
drivers/dma-buf/heaps/Kconfig +9 -0
@@ -12,3 +12,12 @@ config DMABUF_HEAPS_CMA Choose this option to enable dma-buf CMA heap. This heap is backed by the Contiguous Memory Allocator (CMA). If your system has these regions, you should say Y here. + +config DMABUF_HEAPS_CHUNK + tristate "DMA-BUF CHUNK Heap" + depends on DMABUF_HEAPS && DMA_CMA + help + Choose this option to enable dma-buf CHUNK heap. This heap is backed + by the Contiguous Memory Allocator (CMA) and allocate the buffers that + are made up to a list of fixed size chunks tasken from CMA. Chunk sizes + are configurated when the heaps are created.
drivers/dma-buf/heaps/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-y += heap-helpers.o obj-$(CONFIG_DMABUF_HEAPS_SYSTEM) += system_heap.o obj-$(CONFIG_DMABUF_HEAPS_CMA) += cma_heap.o +obj-$(CONFIG_DMABUF_HEAPS_CHUNK) += chunk_heap.o
drivers/dma-buf/heaps/chunk_heap.c new file +222 -0
222 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH 2/3] dma-buf: heaps: add chunk heap to dmabuf heaps
Quoted 107 lines · Hyesoo Yu
This patch adds support for a chunk heap that allows for buffers that are made up of a list of fixed size chunks taken from a CMA. Chunk sizes are configuratd when the heaps are created.
Signed-off-by Hyesoo Yu <[email protected]>--- drivers/dma-buf/heaps/Kconfig | 9 ++ drivers/dma-buf/heaps/Makefile | 1 + drivers/dma-buf/heaps/chunk_heap.c | 222 +++++++++++++++++++++++++++++++++++++ 3 files changed, 232 insertions(+) create mode 100644 drivers/dma-buf/heaps/chunk_heap.cdrivers/dma-buf/heaps/Kconfig +9
-0@@ -12,3 +12,12 @@ config DMABUF_HEAPS_CMA Choose this option to enable dma-buf CMA heap. This heap is backed by the Contiguous Memory Allocator (CMA). If your system has these regions, you should say Y here. + +config DMABUF_HEAPS_CHUNK + tristate "DMA-BUF CHUNK Heap" + depends on DMABUF_HEAPS && DMA_CMA + help + Choose this option to enable dma-buf CHUNK heap. This heap is backed + by the Contiguous Memory Allocator (CMA) and allocate the buffers that + are made up to a list of fixed size chunks tasken from CMA. Chunk sizes + are configurated when the heaps are created.drivers/dma-buf/heaps/Makefile +1
-0@@ -2,3 +2,4 @@ obj-y += heap-helpers.o obj-$(CONFIG_DMABUF_HEAPS_SYSTEM) += system_heap.o obj-$(CONFIG_DMABUF_HEAPS_CMA) += cma_heap.o +obj-$(CONFIG_DMABUF_HEAPS_CHUNK) += chunk_heap.odrivers/dma-buf/heaps/chunk_heap.c new file +63
-0@@ -0,0 +1,222 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* ION Memory Allocator chunk heap exporter +* +* Copyright (c) 2020 Samsung Electronics Co., Ltd. +* Author: <[email protected]> for Samsung Electronics. +*/ + +#include <linux/platform_device.h> +#include <linux/cma.h> +#include <linux/device.h> +#include <linux/dma-buf.h> +#include <linux/dma-heap.h> +#include <linux/dma-contiguous.h> +#include <linux/err.h> +#include <linux/errno.h> +#include <linux/highmem.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/scatterlist.h> +#include <linux/sched/signal.h> +#include <linux/of_reserved_mem.h> +#include <linux/of.h> + +#include "heap-helpers.h" + +struct chunk_heap { +struct dma_heap *heap; +phys_addr_t base; +phys_addr_t size; +atomic_t cur_pageblock_idx; +unsigned int max_num_pageblocks; +unsigned int order; +}; + +static void chunk_heap_free (struct heap_helper_buffer *buffer) +{ +struct chunk_heap *chunk_heap =dma_heap_get_drvdata (buffer->heap); +pgoff_t pg; + +for (pg =0 ; pg < buffer->pagecount; pg++) +__free_pages (buffer->pages[pg], chunk_heap->order); +kvfree (buffer->pages); +kfree (buffer); +} + +static inline unsigned long chunk_get_next_pfn (struct chunk_heap *chunk_heap) +{ +unsigned long i =atomic_inc_return (&chunk_heap->cur_pageblock_idx) % + chunk_heap->max_num_pageblocks; + +return PHYS_PFN (chunk_heap->base) + i * pageblock_nr_pages; +} + +static int chunk_alloc_pages (struct chunk_heap *chunk_heap,struct page **pages, +unsigned int order,unsigned int count) +{ +unsigned long base; +unsigned int i =0 , nr_block =0 , nr_elem, ret; + +while (count) { +/* +* If the number of scanned page block is the same as max block,
drivers/dma-buf/heaps/chunk_heap.c line 73
Quoted 10 lines
drivers/dma-buf/heaps/chunk_heap.c new file +10
-0+* the tries of allocation fails. +*/ +if (nr_block++ == chunk_heap->max_num_pageblocks) { + ret = -ENOMEM ; + goto err_bulk; + } + base =chunk_get_next_pfn (chunk_heap); + nr_elem = min_t(unsigned int, count, pageblock_nr_pages >> order); + ret =alloc_pages_bulk (base, base + pageblock_nr_pages,MIGRATE_CMA , +GFP_KERNEL , order, nr_elem, pages + i);
So you are bypassing the complete cma allocator here. This all smells like a complete hack to me. No, I don't think this is the right way to support (or rather speed up allocations for) special, weird hardware.
Signature · 8 lines
Thanks, David / dhildenb _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
kernel test robot
build botRe: [PATCH 2/3] dma-buf: heaps: add chunk heap to dmabuf heaps
In reply to Hyesoo YuThank you for the patch! Yet something to improve:
Hi Hyesoo,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.9-rc1 next-20200818]
[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/Hyesoo-Yu/Chunk-Heap-Support-on-DMA-HEAP/20200818-154733 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 06a4ec1d9dc652e17ee3ac2ceb6c7cf6c2b75cdd config: microblaze-randconfig-r016-20200818 (attached as .config) compiler: microblaze-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/dma-buf/heaps/chunk_heap.c: In function 'chunk_alloc_pages':
>> drivers/dma-buf/heaps/chunk_heap.c:72:9: error: implicit declaration of function 'alloc_pages_bulk'; did you mean 'alloc_pages_node'? [-Werror=implicit-function-declaration]
72 | ret = alloc_pages_bulk(base, base + pageblock_nr_pages, MIGRATE_CMA,
| ^~~~~~~~~~~~~~~~
| alloc_pages_nodecc1: some warnings being treated as errors
# https://github.com/0day-ci/linux/commit/6032a6b2cbc0a798f6548d6f58fdd46eccaaf764
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Hyesoo-Yu/Chunk-Heap-Support-on-DMA-HEAP/20200818-154733 git checkout 6032a6b2cbc0a798f6548d6f58fdd46eccaaf764
vim +72 drivers/dma-buf/heaps/chunk_heap.c
54
55 static int chunk_alloc_pages(struct chunk_heap *chunk_heap, struct page **pages,
56 unsigned int order, unsigned int count)
57 {
58 unsigned long base;
59 unsigned int i = 0, nr_block = 0, nr_elem, ret;
60
61 while (count) {
62 /*
63 * If the number of scanned page block is the same as max block,
64 * the tries of allocation fails.
65 */
66 if (nr_block++ == chunk_heap->max_num_pageblocks) {
67 ret = -ENOMEM;
68 goto err_bulk;
69 }
70 base = chunk_get_next_pfn(chunk_heap);
71 nr_elem = min_t(unsigned int, count, pageblock_nr_pages >> order);
> 72 ret = alloc_pages_bulk(base, base + pageblock_nr_pages, MIGRATE_CMA,
73 GFP_KERNEL, order, nr_elem, pages + i);
74 if (ret < 0)
75 goto err_bulk;
76
77 i += ret;
78 count -= ret;
79 }
80
81 return 0;
82
83 err_bulk:
84 while (i-- > 0)
85 __free_pages(pages[i], order);
86
87 return ret;
88 }
89 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 3/3 dma-heap: Devicetree binding for chunk heap
In reply to Hyesoo YuDocument devicetree binding for chunk heap on dma heap framework
--- .../devicetree/bindings/dma-buf/chunk_heap.yaml | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma-buf/chunk_heap.yaml
Documentation/devicetree/bindings/dma-buf/chunk_heap.yaml new file +46 -0
@@ -0,0 +1,46 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma-buf/chunk_heap.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Device tree binding for chunk heap on DMA HEAP FRAMEWORK + +maintainers: + - Sumit Semwal <[email protected]> + +description: | + The chunk heap is backed by the Contiguous Memory Allocator (CMA) and + allocates the buffers that are made up to a list of fixed size chunks + taken from CMA. Chunk sizes are configurated when the heaps are created. + +properties: + compatible: + enum: + - dma_heap,chunk + +required: + - compatible + - memory-region + - alignment + +additionalProperties: false + +examples: + - | + reserved-memory { + #address-cells = <2>; + #size-cells = <1>; + + chunk_memory: chunk_memory { + compatible = "shared-dma-pool"; + reusable; + size = <0x10000000>; + }; + }; + + chunk_default_heap: chunk_default_heap { + compatible = "dma_heap,chunk"; + memory-region = <&chunk_memory>; + alignment = <0x10000>; + };
Signature · 1 line
2.7.4
Rob Herring
maintainerRe: [PATCH 3/3] dma-heap: Devicetree binding for chunk heap
Quoted 8 lines · Hyesoo Yu
Document devicetree binding for chunk heap on dma heap framework
Signed-off-by Hyesoo Yu <[email protected]>--- .../devicetree/bindings/dma-buf/chunk_heap.yaml | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma-buf/chunk_heap.yaml
My bot found errors running 'make dt_binding_check' on your patch:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/dma-buf/chunk_heap.example.dt.yaml: chunk_default_heap: 'alignment', 'memory-region' do not match any of the regexes: 'pinctrl-[0-9]+'
See https://patchwork.ozlabs.org/patch/1346687
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date:
pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade
Please check and re-submit.
Re: [PATCH 3/3] dma-heap: Devicetree binding for chunk heap
Hi,
Quoted 16 lines · Rob Herring
Quoted 8 lines · Hyesoo Yu
Document devicetree binding for chunk heap on dma heap framework
Signed-off-by Hyesoo Yu <[email protected]>--- .../devicetree/bindings/dma-buf/chunk_heap.yaml | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma-buf/chunk_heap.yamlMy bot found errors running 'make
dt_binding_check' on your patch:/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/dma-buf/chunk_heap.example.dt.yaml:
chunk_default_heap: 'alignment', 'memory-region' do not match any of the regexes: 'pinctrl-[0-9]+'
Quoted 10 lines
If you already ran 'make
dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date:pip3 install git+https://protect2.fireeye.com/v1/url?k=c99eded1-945559ef-c99f559e-0cc47a31309a-bcc831610d2ce1c6&q=1&e=d42ef5a6-e7ba-494d-8f6b-faf451118f84&u=https%3A%2F%2Fgithub.com%2Fdevicetree-org%2Fdt-schema.git%40master --upgrade
Please check and re-submit.
Thanks for reply. I missed alignment and memory-region on property. I added and ran dt_binding_check, and all passed.
I will re-submit the patch v2.
Regards.
Hyesoo yu.
Brian Starkey
reviewerHi,
Quoted 5 lines · Hyesoo Yu
These patch series to introduce a new dma heap, chunk heap. That heap is needed for special HW that requires bulk allocation of fixed high order pages. For example, 64MB dma-buf pages are made up to fixed order-4 pages * 1024.
Quoted 8 lines
The chunk heap uses
alloc_pages_bulkto allocate high order page.
https://lore.kernel.org/linux-mm/[email protected]The chunk heap is registered by device tree with alignment and memory node of contiguous memory allocator(CMA). Alignment defines chunk page size. For example, alignment 0x1_0000 means chunk page size is 64KB. The phandle to memory node indicates contiguous memory allocator(CMA). If device node doesn't have cma, the registration of chunk heap fails.
This reminds me of an ion heap developed at Arm several years ago:
https://git.linaro.org/landing-teams/working/arm/kernel.git/tree/drivers/staging/android/ion/ion_compound_page.c
Some more descriptive text here:
https://github.com/ARM-software/CPA
It maintains a pool of high-order pages with a worker thread to attempt compaction and allocation to keep the pool filled, with high and low watermarks to trigger freeing/allocating of chunks. It implements a shrinker to allow the system to reclaim the pool under high memory pressure.
Is maintaining a pool something you considered? From the alloc_pages_bulk thread it sounds like you want to allocate 300M at a time, so I expect if you tuned the pool size to match that it could work quite well.
That implementation isn't using a CMA region, but a similar approach could definitely be applied.
Thanks,
-Brian
Quoted 24 lines
The patchset includes the following:
- export dma-heap API to register kernel module dma heap.
- add chunk heap implementation.
- document of device tree to register chunk heapHyesoo Yu (3):
dma-buf: add missingEXPORT_SYMBOL_GPL()for dma heaps
dma-buf: heaps: add chunk heap to dmabuf heaps
dma-heap: Devicetree binding for chunk heap.../devicetree/bindings/dma-buf/chunk_heap.yaml | 46 +++++ drivers/dma-buf/dma-heap.c | 2 + drivers/dma-buf/heaps/Kconfig | 9 + drivers/dma-buf/heaps/Makefile | 1 + drivers/dma-buf/heaps/chunk_heap.c | 222 +++++++++++++++++++++ drivers/dma-buf/heaps/heap-helpers.c | 2 + 6 files changed, 282 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma-buf/chunk_heap.yaml create mode 100644 drivers/dma-buf/heaps/chunk_heap.cSignature · 1 line
2.7.4
Quoted 29 lines · Brian Starkey
Hi,
Quoted 5 lines · Hyesoo Yu
These patch series to introduce a new dma heap, chunk heap. That heap is needed for special HW that requires bulk allocation of fixed high order pages. For example, 64MB dma-buf pages are made up to fixed order-4 pages * 1024.
Quoted 8 lines
The chunk heap uses
alloc_pages_bulkto allocate high order page.
https://lore.kernel.org/linux-mm/[email protected]The chunk heap is registered by device tree with alignment and memory node of contiguous memory allocator(CMA). Alignment defines chunk page size. For example, alignment 0x1_0000 means chunk page size is 64KB. The phandle to memory node indicates contiguous memory allocator(CMA). If device node doesn't have cma, the registration of chunk heap fails.
This reminds me of an ion heap developed at Arm several years ago:
https://protect2.fireeye.com/v1/url?k=aceed8af-f122140a-acef53e0-0cc47a30d446-0980fa451deb2df6&q=1&e=a58a9bb0-a837-4fc5-970e-907089bfe25e&u=https%3A%2F%2Fgit.linaro.org%2Flanding-teams%2Fworking%2Farm%2Fkernel.git%2Ftree%2Fdrivers%2Fstaging%2Fandroid%2Fion%2Fion_compound_page.cSome more descriptive text here:
https://protect2.fireeye.com/v1/url?k=83dc3e8b-de10f22e-83ddb5c4-0cc47a30d446-a406aa201ca7dddc&q=1&e=a58a9bb0-a837-4fc5-970e-907089bfe25e&u=https%3A%2F%2Fgithub.com%2FARM-software%2FCPAIt maintains a pool of high-order pages with a worker thread to attempt compaction and allocation to keep the pool filled, with high and low watermarks to trigger freeing/allocating of chunks. It implements a shrinker to allow the system to reclaim the pool under high memory pressure.
Quoted 8 lines
Is maintaining a pool something you considered? From the
alloc_pages_bulkthread it sounds like you want to allocate 300M at a time, so I expect if you tuned the pool size to match that it could work quite well.That implementation isn't using a CMA region, but a similar approach could definitely be applied.
I have seriously considered CPA in our product but we developed our own because of the pool in CPA.
The high-order pages are required by some specific users like Netflix app. Moreover required number of bytes are dramatically increasing because of high resolution videos and displays in these days.
Gathering lots of free high-order pages in the background during run-time means reserving that amount of pages from the entier available system memory. Moreover the gathered pages are soon reclaimed whenever the system is sufferring from memory pressure (i.e. camera recording, heavy games). So we had to consider allocating hundreds of megabytes at at time. Of course we don't allocate all buffers by a single call to alloc_pages_bulk(). But still a buffer is very large.
A single frame of 8K HDR video needs 95MB (7680*4320*2*1.5). Even a single frame of HDR 4K video needs 24MB and 4K HDR is now popular in Netflix, YouTube and Google Play video.
Quoted 2 lines
Thanks,
-Brian
Thank you!
KyongHo
Brian Starkey
reviewerHi KyongHo,
Quoted 2 lines · Cho KyongHo
I have seriously considered CPA in our product but we developed our own because of the pool in CPA.
Oh good, I'm glad you considered it :-)
Quoted 9 lines
The high-order pages are required by some specific users like Netflix app. Moreover required number of bytes are dramatically increasing because of high resolution videos and displays in these days.
Gathering lots of free high-order pages in the background during run-time means reserving that amount of pages from the entier available system memory. Moreover the gathered pages are soon reclaimed whenever the system is sufferring from memory pressure (i.e. camera recording, heavy games).
Aren't these two things in contradiction? If they're easily reclaimed then they aren't "reserved" in any detrimental way. And if you don't want them to be reclaimed, then you need them to be reserved...
The approach you have here assigns the chunk of memory as a reserved CMA region which the kernel is going to try not to use too - similar to the CPA pool.
I suppose it's a balance depending on how much you're willing to wait for migration on the allocation path. CPA has the potential to get you faster allocations, but the downside is you need to make it a little more "greedy".
Cheers,
-Brian
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Brain,
Quoted 22 lines · Brian Starkey
Hi KyongHo,
Quoted 2 lines · Cho KyongHo
I have seriously considered CPA in our product but we developed our own because of the pool in CPA.
Oh good, I'm glad you considered it :-)
Quoted 9 lines
The high-order pages are required by some specific users like Netflix app. Moreover required number of bytes are dramatically increasing because of high resolution videos and displays in these days.
Gathering lots of free high-order pages in the background during run-time means reserving that amount of pages from the entier available system memory. Moreover the gathered pages are soon reclaimed whenever the system is sufferring from memory pressure (i.e. camera recording, heavy games).
Aren't these two things in contradiction? If they're easily reclaimed then they aren't "reserved" in any detrimental way. And if you don't want them to be reclaimed, then you need them to be reserved...
Quoted 9 lines
The approach you have here assigns the chunk of memory as a reserved CMA region which the kernel is going to try not to use too - similar to the CPA pool.
I suppose it's a balance depending on how much you're willing to wait for migration on the allocation path. CPA has the potential to get you faster allocations, but the downside is you need to make it a little more "greedy".
I understand why you think it as contradiction. But I don't think so. Kernel page allocator now prefers free pages in CMA when allocating movable pages by commit
https://lore.kernel.org/linux-mm/CAAmzW4P6+3O_RLvgy_QOKD4iXw+Hk3HE7Toc4Ky7kvQbCozCeA@mail.gmail.com/
.
We are trying to reduce unused pages to improve performance. So, unused pages in a pool should be easily reclaimed. That is why we does not secure free pages in a special pool for a specific usecase. Instead we have tried to reduce performance bottle-necks in page migration to allocate large amount memory when the memory is needed.
Quoted 20 lines · Hyesoo Yu
These patch series to introduce a new dma heap, chunk heap. That heap is needed for special HW that requires bulk allocation of fixed high order pages. For example, 64MB dma-buf pages are made up to fixed order-4 pages * 1024.
The chunk heap uses
alloc_pages_bulkto allocate high order page.
https://lore.kernel.org/linux-mm/[email protected]The chunk heap is registered by device tree with alignment and memory node of contiguous memory allocator(CMA). Alignment defines chunk page size. For example, alignment 0x1_0000 means chunk page size is 64KB. The phandle to memory node indicates contiguous memory allocator(CMA). If device node doesn't have cma, the registration of chunk heap fails.
The patchset includes the following:
- export dma-heap API to register kernel module dma heap.
- add chunk heap implementation.
- document of device tree to register chunk heap
Quoted 4 lines
Hyesoo Yu (3):
dma-buf: add missingEXPORT_SYMBOL_GPL()for dma heaps
dma-buf: heaps: add chunk heap to dmabuf heaps
dma-heap: Devicetree binding for chunk heap
Hey! Thanks so much for sending this out! I'm really excited to see these heaps be submitted and reviewed on the list!
The first general concern I have with your series is that it adds a dt binding for the chunk heap, which we've gotten a fair amount of pushback on.
A possible alternative might be something like what Kunihiko Hayashi proposed for non-default CMA heaps:
https://lore.kernel.org/lkml/[email protected]/
This approach would insteal allow a driver to register a CMA area with the chunk heap implementation.
However, (and this was the catch Kunihiko Hayashi's patch) this requires that the driver also be upstream, as we need an in-tree user of such code.
Also, it might be good to provide some further rationale on why this heap is beneficial over the existing CMA heap? In general focusing the commit messages more on the why we might want the patch, rather than what the patch does, is helpful.
"Special hardware" that doesn't have upstream drivers isn't very compelling for most maintainers.
That said, I'm very excited to see these sorts of submissions, as I know lots of vendors have historically had very custom out of tree ION heaps, and I think it would be a great benefit to the community to better understand the experience vendors have in optimizing performance on their devices, so we can create good common solutions upstream. So I look forward to your insights on future revisions of this patch series!
thanks
-john
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel