Hello,
This is one more respin of the patches which add support for creating
reserved memory regions defined in device tree. The last attempt
(http://lists.linaro.org/pipermail/linaro-mm-sig/2014-February/003738.html)
ended in merging only half of the code, so right now we have complete
documentation merged and only basic code, which implements a half of it
is written in the documentation. Although the merged patches allow to
reserve memory, there is no way of using it for devices and drivers.
This situation makes CMA rather useless, as the main architecture (ARM),
which used it, has been converted from board-file based system
initialization to device tree. Thus there is no place to use direct
calls to dma_declare_contiguous() and some new solution, which bases on
device tree, is urgently needed.
This patch series fixes this issue. It provides two, already widely
discussed and already present in the kernel, drivers for reserved
memory: first based on DMA-coherent allocator, second using Contiguous
Memory Allocator. The first one nicely implements typical 'carved out'
reserved memory way of allocating contiguous buffers in a kernel-style
way. The memory is used exclusively by devices assigned to the given
memory region. The second one allows to reuse reserved memory for
movable kernel pages (like disk buffers, anonymous memory) and migrates
it out when device to allocates contiguous memory buffer. Both driver
provides memory buffers via standard dma-mapping API.
The patches have been rebased on top of latest CMA and mm changes merged
to akmp kernel tree.
To define a 64MiB CMA region following node is needed:
multimedia_reserved: multimedia_mem_region {
compatible = "shared-dma-pool";
reusable;
size = <0x4000000>;
alignment = <0x400000>;
};
Similarly, one can define 64MiB region with DMA coherent memory:
multimedia_reserved: multimedia_mem_region {
compatible = "shared-dma-pool";
no-map;
size = <0x4000000>;
alignment = <0x400000>;
};
Then the defined region can be assigned to devices:
scaler: scaler@12500000 {
memory-region = <&multimedia_reserved>;
/* ... */
};
codec: codec@12600000 {
memory-region = <&multimedia_reserved>;
/* ... */
};
Best regards
Marek Szyprowski
Samsung R&D Institute Poland
Changes since v1:
(http://www.spinics.net/lists/arm-kernel/msg343702.html)
- fixed possible memory leak in case of reserved memory allocation failure
(thanks to Joonsoo Kim)
Changes since the version posted in '[PATCH v6 00/11] reserved-memory
regions/CMA in devicetree, again' thread
http://lists.linaro.org/pipermail/linaro-mm-sig/2014-February/003738.html:
- rebased on top of '[PATCH v3 -next 0/9] CMA: generalize CMA reserved
area management code' patch series on v3.16-rc3
- improved dma-coherent driver, now it correctly handles assigning more
than one device to the given memory region
Patch summary:
Marek Szyprowski (4):
drivers: of: add automated assignment of reserved regions to client
devices
drivers: of: initialize and assign reserved memory to newly created
devices
drivers: dma-coherent: add initialization from device tree
drivers: dma-contiguous: add initialization from device tree
drivers/base/dma-coherent.c | 40 +++++++++++++++++++++++
drivers/base/dma-contiguous.c | 60 +++++++++++++++++++++++++++++++++++
drivers/of/of_reserved_mem.c | 70 +++++++++++++++++++++++++++++++++++++++++
drivers/of/platform.c | 7 +++++
include/linux/cma.h | 3 ++
include/linux/of_reserved_mem.h | 7 +++++
mm/cma.c | 62 +++++++++++++++++++++++++++++-------
7 files changed, 238 insertions(+), 11 deletions(-)
--
1.9.2
Hello,
(please ignore previous patchset, I've attached wrong version of patches)
This is one more respin of the patches which add support for creating
reserved memory regions defined in device tree. The last attempt
(http://lists.linaro.org/pipermail/linaro-mm-sig/2014-February/003738.html)
ended in merging only half of the code, so right now we have complete
documentation merged and only basic code, which implements a half of it
is written in the documentation. Although the merged patches allow to
reserve memory, there is no way of using it for devices and drivers.
This situation makes CMA rather useless, as the main architecture (ARM),
which used it, has been converted from board-file based system
initialization to device tree. Thus there is no place to use direct
calls to dma_declare_contiguous() and some new solution, which bases on
device tree, is urgently needed.
This patch series fixes this issue. It provides two, already widely
discussed and already present in the kernel, drivers for reserved
memory: first based on DMA-coherent allocator, second using Contiguous
Memory Allocator. The first one nicely implements typical 'carved out'
reserved memory way of allocating contiguous buffers in a kernel-style
way. The memory is used exclusively by devices assigned to the given
memory region. The second one allows to reuse reserved memory for
movable kernel pages (like disk buffers, anonymous memory) and migrates
it out when device to allocates contiguous memory buffer. Both driver
provides memory buffers via standard dma-mapping API.
The patches have been rebased on top of latest CMA and mm changes merged
to akmp kernel tree.
To define a 64MiB CMA region following node is needed:
multimedia_reserved: multimedia_mem_region {
compatible = "shared-dma-pool";
reusable;
size = <0x4000000>;
alignment = <0x400000>;
};
Similarly, one can define 64MiB region with DMA coherent memory:
multimedia_reserved: multimedia_mem_region {
compatible = "shared-dma-pool";
no-map;
size = <0x4000000>;
alignment = <0x400000>;
};
Then the defined region can be assigned to devices:
scaler: scaler@12500000 {
memory-region = <&multimedia_reserved>;
/* ... */
};
codec: codec@12600000 {
memory-region = <&multimedia_reserved>;
/* ... */
};
Best regards
Marek Szyprowski
Samsung R&D Institute Poland
Changes since v1:
(http://www.spinics.net/lists/arm-kernel/msg343702.html)
- fixed possible memory leak in case of reserved memory allocation failure
(thanks to Joonsoo Kim)
Changes since the version posted in '[PATCH v6 00/11] reserved-memory
regions/CMA in devicetree, again' thread
http://lists.linaro.org/pipermail/linaro-mm-sig/2014-February/003738.html:
- rebased on top of '[PATCH v3 -next 0/9] CMA: generalize CMA reserved
area management code' patch series on v3.16-rc3
- improved dma-coherent driver, now it correctly handles assigning more
than one device to the given memory region
Patch summary:
Marek Szyprowski (4):
drivers: of: add automated assignment of reserved regions to client
devices
drivers: of: initialize and assign reserved memory to newly created
devices
drivers: dma-coherent: add initialization from device tree
drivers: dma-contiguous: add initialization from device tree
drivers/base/dma-coherent.c | 137 ++++++++++++++++++++++++++++++++++------
drivers/base/dma-contiguous.c | 67 ++++++++++++++++++++
drivers/of/of_reserved_mem.c | 70 ++++++++++++++++++++
drivers/of/platform.c | 7 ++
include/linux/cma.h | 3 +
include/linux/of_reserved_mem.h | 7 ++
mm/cma.c | 62 ++++++++++++++----
7 files changed, 323 insertions(+), 30 deletions(-)
--
1.9.2
Dear joonsoo kim,
I have your patches for: Aggressively allocate memory from cma ....
We are facing almost similar problem here.
If any of your patches still working for you please let us know here.
I would like to try those approach.
Thank you
Sent from Samsung Mobile
-------- Original message --------
From: PINTU KUMAR <pintu_agarwal(a)yahoo.com>
Date: 09/07/2014 8:41 AM (GMT+09:00)
To: linux-mm@kvack.org,linux-mm@kvack.org,linux-arm-kernel@lists.infradead.org,linaro-mm-sig@lists.linaro.org
Cc: pintu.k@outlook.com,pintu.k@samsung.com,vishu_1385@yahoo.com,m.szyprowski@samsung.com,mina86@mina86.com,ngupta@vflare.org,iqbalblr@gmail.com
Subject: [linux-3.10.17] Could not allocate memory from free CMA areas
Hi,
We are facing one problem on linux 3.10 when we try to use CMA as large as 56MB for 256MB RAM device.
We found that after certain point of time (during boot), min watermark check is failing when "free_pages" and "free_cma_pages" are almost equal and falls below the min level.
system details:
ARM embedded device: RAM: 256MB
Kernel version: 3.10.17
Fixed Reserved memory: ~40MB
Available memory: 217MB
CMA reserved 1 : 56MB
ZRAM configured: 128MB or 64MB
min_free_kbytes: 1625 (default)
Memory controller group enabled (MEMCG)
After boot-up the "free -tm" command shows free memory as: ~50MB
CMA is used for all UI display purposes. CMA used during bootup is close to ~6MB.
Thus most of the free memory is in the form of CMA free memory.
ZRAM getting uses was around ~5MB.
During boot-up itself we observe that the following conditions are met.
if (free_pages - free_cma <= min + lowmem_reserve) {
printk"[PINTU]: __zone_watermark_ok: failed !\n");
return false;
}
Here: free_pages was: 12940, free_cma was: 12380, min: 566, lowmem: 0
Thus is condition is met most of the time.
And because of this watermark failure, Kswapd is waking up frequently.
The /proc/pagetypeinfo reports that most of the higher order pages are from CMA regions.
We also observed that ZRAM is trying to allocate memory from CMA region and failing.
We also tried by decreasing the CMA region to 20MB. With this the watermark failure is not happening in boot time. But if we launch more than 3 apps {Browser, music-player etc}, again the watermark started failing.
Also we tried decreasing the min_free_kbytes=256, and with this also watermark is passed.
Our observation is that ZRAM/zsmalloc trying to allocate memory from CMA areas and failed.
Please let us know if anybody have come across the same problem and how to resolve this issue.
Thank You!
Regards,
Pintu
On Tue, Jul 15, 2014 at 7:53 PM, Bridgman, John <John.Bridgman(a)amd.com> wrote:
[snip away the discussion about hsa device discover, I'm hijacking
this thread just for the event/fence stuff here.]
> ... There's an event mechanism still to come - mostly for communicating fences and shader interrupts back to userspace, but also used for "device change" notifications, so no polling of sysfs.
That could would be interesting. On i915 my plan is to internally use
the recently added struct fence from Maarten. For the external
interface for userspace that wants explicit control over fences I'm
leaning towards polishing the android syncpt stuff (currently in
staging). But in any case I _really_ want to avoid that we end up with
multiple different and incompatible explicit fencing interfaces on
linux.
Adding relevant people.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Hello,
On 2014-07-09 01:41, PINTU KUMAR wrote:
> Hi,
>
> We are facing one problem on linux 3.10 when we try to use CMA as large as 56MB for 256MB RAM device.
> We found that after certain point of time (during boot), min watermark check is failing when "free_pages" and "free_cma_pages" are almost equal and falls below the min level.
>
> system details:
> ARM embedded device: RAM: 256MB
> Kernel version: 3.10.17
> Fixed Reserved memory: ~40MB
> Available memory: 217MB
> CMA reserved 1 : 56MB
> ZRAM configured: 128MB or 64MB
> min_free_kbytes: 1625 (default)
> Memory controller group enabled (MEMCG)
>
>
> After boot-up the "free -tm" command shows free memory as: ~50MB
> CMA is used for all UI display purposes. CMA used during bootup is close to ~6MB.
> Thus most of the free memory is in the form of CMA free memory.
> ZRAM getting uses was around ~5MB.
>
>
> During boot-up itself we observe that the following conditions are met.
>
>
> if (free_pages - free_cma <= min + lowmem_reserve) {
> printk"[PINTU]: __zone_watermark_ok: failed !\n");
>
> return false;
> }
> Here: free_pages was: 12940, free_cma was: 12380, min: 566, lowmem: 0
>
>
> Thus is condition is met most of the time.
> And because of this watermark failure, Kswapd is waking up frequently.
> The /proc/pagetypeinfo reports that most of the higher order pages are from CMA regions.
>
>
> We also observed that ZRAM is trying to allocate memory from CMA region and failing.
>
> We also tried by decreasing the CMA region to 20MB. With this the watermark failure is not happening in boot time. But if we launch more than 3 apps {Browser, music-player etc}, again the watermark started failing.
>
> Also we tried decreasing the min_free_kbytes=256, and with this also watermark is passed.
>
> Our observation is that ZRAM/zsmalloc trying to allocate memory from CMA areas and failed.
>
>
> Please let us know if anybody have come across the same problem and how to resolve this issue.
Frankly I really have no idea what is going on. ZRAM/zsmalloc should not
try to alloc memory from CMA. I don't have access you the mentioned
source code. What flags are passed to alloc_pages() in zram/zsmalloc? It
should get pages from non-movable pool.
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
Hi All,
No reply on the below.
Does anybody came across with the similar issues?
Please let me know if any fixes are already available.
Issues:
1) When free memory pages and CMA free pages are almost equal, min watermark check is failing, resulting in swapping.
2) Almost all the free memory in system is CMA free memory.
3) When ZRAM tries to allocate pages from CMA free areas, the allocation fails.
Please refer below for more details.
Thank you!
Regards,
Pintu
> Date: Tue, 8 Jul 2014 16:41:40 -0700
> From: pintu_agarwal(a)yahoo.com
> Subject: [linux-3.10.17] Could not allocate memory from free CMA areas
> To: linux-mm(a)kvack.org; linux-mm(a)kvack.org; linux-arm-kernel(a)lists.infradead.org; linaro-mm-sig(a)lists.linaro.org
> CC: pintu.k(a)outlook.com; pintu.k(a)samsung.com; vishu_1385(a)yahoo.com; m.szyprowski(a)samsung.com; mina86(a)mina86.com; ngupta(a)vflare.org; iqbalblr(a)gmail.com
>
> Hi,
>
> We are facing one problem on linux 3.10 when we try to use CMA as large as 56MB for 256MB RAM device.
> We found that after certain point of time (during boot), min watermark check is failing when "free_pages" and "free_cma_pages" are almost equal and falls below the min level.
>
> system details:
> ARM embedded device: RAM: 256MB
> Kernel version: 3.10.17
> Fixed Reserved memory: ~40MB
> Available memory: 217MB
> CMA reserved 1 : 56MB
> ZRAM configured: 128MB or 64MB
> min_free_kbytes: 1625 (default)
> Memory controller group enabled (MEMCG)
>
>
> After boot-up the "free -tm" command shows free memory as: ~50MB
> CMA is used for all UI display purposes. CMA used during bootup is close to ~6MB.
> Thus most of the free memory is in the form of CMA free memory.
> ZRAM getting uses was around ~5MB.
>
>
> During boot-up itself we observe that the following conditions are met.
>
>
> if (free_pages - free_cma <= min + lowmem_reserve) {
> printk"[PINTU]: __zone_watermark_ok: failed !\n");
>
> return false;
> }
> Here: free_pages was: 12940, free_cma was: 12380, min: 566, lowmem: 0
>
>
> Thus is condition is met most of the time.
> And because of this watermark failure, Kswapd is waking up frequently.
> The /proc/pagetypeinfo reports that most of the higher order pages are from CMA regions.
>
>
> We also observed that ZRAM is trying to allocate memory from CMA region and failing.
>
> We also tried by decreasing the CMA region to 20MB. With this the watermark failure is not happening in boot time. But if we launch more than 3 apps {Browser, music-player etc}, again the watermark started failing.
>
> Also we tried decreasing the min_free_kbytes=256, and with this also watermark is passed.
>
> Our observation is that ZRAM/zsmalloc trying to allocate memory from CMA areas and failed.
>
>
> Please let us know if anybody have come across the same problem and how to resolve this issue.
>
>
>
>
>
> Thank You!
> Regards,
> Pintu