CMA in 7.4
CMA in 7.4
Hello,
According to .config:
CONFIG_CMA = y
CONFIG_DMA_CMA : Does not exist
How can I enable CMA in this version ?
I have to allocate a 256MB physically contiguous memory buffer with: dma_alloc_coherent
or __get_free_pages
I managed to allocate only 4MB.
Thank you,
Zvika
According to .config:
CONFIG_CMA = y
CONFIG_DMA_CMA : Does not exist
How can I enable CMA in this version ?
I have to allocate a 256MB physically contiguous memory buffer with: dma_alloc_coherent
or __get_free_pages
I managed to allocate only 4MB.
Thank you,
Zvika
Re: CMA in 7.4
Please don't use 7.4, it's over 2 years old and riddled with security vulnerabilities. The current version is 7.7. Run yum update
Are you passing cma=xx[MG] as per/usr/share/doc/kernel-doc-3.10.0/Documentation/kernel-parameters.txt (part of the kernel-doc package)?
Are you passing cma=xx[MG] as per/usr/share/doc/kernel-doc-3.10.0/Documentation/kernel-parameters.txt (part of the kernel-doc package)?
Code: Select all
cma=nn[MG] [ARM,KNL]
Sets the size of kernel global memory area for contiguous
memory allocations. For more information, see
include/linux/dma-contiguous.h
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Re: CMA in 7.4
Hello,
Thank you for your reply.
I upgraded to centos 8.0.1905
I changed kernel configuration to:
CONFIG_CMA=y
CONFIG_DMA_CMA=y
In kernel boot parameters: cma=32M
When I tried to allocate up to 4MB I got the following output in dmesg:
[ 1462.787121] cma: cma_alloc(cma 000000001c0c6b6b, count 1024, align 8)
[ 1462.790433] cma: cma_alloc(): returned 00000000087f40b7
[ 1462.790434] cma: cma_release(page 00000000087f40b7)[/i]
The allocation succeeded.
Then I tried to allocate 8MB and got:
[ 1588.692877] cma: cma_alloc(cma 000000001c0c6b6b, count 2048, align 8)
[ 1588.695398] cma: cma_alloc(): returned 00000000087f40b7
[ 1588.695399] cma: cma_release(page 00000000087f40b7)
The allocation failed.
dma_alloc_coherent(NULL, 0x800000, &dma_handle, GFP_KERNEL);
returned NULL.
What am I doing wrong ?
Thank you in advance,
Zvika
Thank you for your reply.
I upgraded to centos 8.0.1905
I changed kernel configuration to:
CONFIG_CMA=y
CONFIG_DMA_CMA=y
In kernel boot parameters: cma=32M
When I tried to allocate up to 4MB I got the following output in dmesg:
[ 1462.787121] cma: cma_alloc(cma 000000001c0c6b6b, count 1024, align 8)
[ 1462.790433] cma: cma_alloc(): returned 00000000087f40b7
[ 1462.790434] cma: cma_release(page 00000000087f40b7)[/i]
The allocation succeeded.
Then I tried to allocate 8MB and got:
[ 1588.692877] cma: cma_alloc(cma 000000001c0c6b6b, count 2048, align 8)
[ 1588.695398] cma: cma_alloc(): returned 00000000087f40b7
[ 1588.695399] cma: cma_release(page 00000000087f40b7)
The allocation failed.
dma_alloc_coherent(NULL, 0x800000, &dma_handle, GFP_KERNEL);
returned NULL.
What am I doing wrong ?
Thank you in advance,
Zvika
Re: CMA in 7.4
Hello,
The hardware I'm using is PCIe.
The FPGA will write data by DMA to a physical address.
Is it possible that the reason for the failure is that currently I'm working without this FPGA ?
static void * virtual_adr_ptr;
static int hello_init(void)
{
printk ("-->hello_init\n");
virtual_adr_ptr=dma_alloc_coherent(NULL, BUF_SIZE, &dma_handle, GFP_KERNEL);
if (virtual_adr_ptr == 0)
{
return -1;
}
return 0;
}
Thank you,
Zvika
The hardware I'm using is PCIe.
The FPGA will write data by DMA to a physical address.
Is it possible that the reason for the failure is that currently I'm working without this FPGA ?
static void * virtual_adr_ptr;
static int hello_init(void)
{
printk ("-->hello_init\n");
virtual_adr_ptr=dma_alloc_coherent(NULL, BUF_SIZE, &dma_handle, GFP_KERNEL);
if (virtual_adr_ptr == 0)
{
return -1;
}
return 0;
}
Thank you,
Zvika
Re: CMA in 7.4
No where near a C kind of guy, but I can tell you that the CMA values are published under /proc/meminfo (specfically CmaTotal & CmaFree) - might prove whether it is *actually* enabled or not (and allocation success and failure).
Re: CMA in 7.4
And you don't need to recompile it to change it, it's a kernel parameter passed via the kernel command line.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Re: CMA in 7.4
Hi,
I'm observing similar issues (activation of CMA) in CentOS 7.7.
Any thoughts on this? Anything else I could check?
I'm observing similar issues (activation of CMA) in CentOS 7.7.
Code: Select all
[root@echo ~]# cat /proc/meminfo |grep -i cma
CmaTotal: 0 kB
CmaFree: 0 kB
[root@echo ~]# cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-3.10.0-1062.18.1.el7.x86_64 root=/dev/mapper/vg_root-root ro audit=1 crashkernel=auto rd.md.uuid=48b8c772:531125a4:2455a7da:425a02fa rd.luks.uuid=luks-d8a0cf0c-ead8-477e-a08c-ebdeac40037b rd.lvm.lv=vg_root/root rd.md.uuid=d945efa7:c59debf1:9b56963b:f8d3ca02 rd.lvm.lv=vg_root/swap LANG=en_US.UTF-8 ipv6.disable=1 transparent_hugepage=never cma=4096M
[root@echo ~]# cat /proc/meminfo |grep -i cma
CmaTotal: 0 kB
CmaFree: 0 kB
[root@echo ~]# dmesg|grep -i cma
[ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-1062.18.1.el7.x86_64 root=/dev/mapper/vg_root-root ro audit=1 crashkernel=auto rd.md.uuid=48b8c772:531125a4:2455a7da:425a02fa rd.luks.uuid=luks-d8a0cf0c-ead8-477e-a08c-ebdeac40037b rd.lvm.lv=vg_root/root rd.md.uuid=d945efa7:c59debf1:9b56963b:f8d3ca02 rd.lvm.lv=vg_root/swap LANG=en_US.UTF-8 ipv6.disable=1 transparent_hugepage=never cma=4096M
[ 0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-3.10.0-1062.18.1.el7.x86_64 root=/dev/mapper/vg_root-root ro audit=1 crashkernel=auto rd.md.uuid=48b8c772:531125a4:2455a7da:425a02fa rd.luks.uuid=luks-d8a0cf0c-ead8-477e-a08c-ebdeac40037b rd.lvm.lv=vg_root/root rd.md.uuid=d945efa7:c59debf1:9b56963b:f8d3ca02 rd.lvm.lv=vg_root/swap LANG=en_US.UTF-8 ipv6.disable=1 transparent_hugepage=never cma=4096M
[root@echo ~]#
Re: CMA in 7.4
I suspect that the CMA support is disabled by default in RHEL 7/CentOS7 since version 7.5. Looking at https://access.redhat.com/documentation ... -bug-fixes (yes, I'm aware it says arm-bug-fixes), this comment stands out:
Further, looking at include/linux/dma-contiguous.h, it seems there's a different kernel config parameter that's evaluated (CONFIG_DMA_CMA):The CMA support in the Red Hat Enterprise Linux kernel is now disabled by default for all architectures, and CMA no longer causes OOM.(BZ#1519317)
Code: Select all
[root@echo ~]# grep CONFIG_ /usr/src/kernels/3.10.0-1062.18.1.el7.x86_64/include/linux/dma-contiguous.h
#ifdef CONFIG_DMA_CMA
#define MAX_CMA_AREAS (1 + CONFIG_CMA_AREAS)
[root@echo ~]# grep _CMA /boot/config-3.10.0-1062.18.1.el7.x86_64
CONFIG_CMA=y
# CONFIG_CMA_DEBUG is not set
# CONFIG_INPUT_CMA3000 is not set
CONFIG_CRYPTO_CMAC=m
[root@echo ~]#