linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* dynamic reservation and allocation of physically contiguous memory using CMA
@ 2018-06-18 18:23 ` Amit Chandra (amichand)
  2018-06-19 11:45   ` Marek Szyprowski
  0 siblings, 1 reply; 2+ messages in thread
From: Amit Chandra (amichand) @ 2018-06-18 18:23 UTC (permalink / raw)
  To: m.szyprowski, linux-kernel, linux-arm-kernel, linux-samsung-soc,
	linux-media, linux-mm

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

Hi experts,

I had a question related to CMA. I have been trying to use the CMA infra to reserve and allocate physically contiguous memory dynamically at runtime.
I built a custom kernel based on linux-4.14.47 to invoke the cma initialization apis at runtime from kernel loadable module.
I invoke cma_declare_contiguous() followed by cma_init_reserved_areas().
cma_declare_contiguous throws no surprises and succeeds. The issue happens when cma_init_reserved_areas() is invoked post that.
Here is the kernel log snippet post that call:

Jun 15 03:30:31 ubuntu-quickstart kernel: [  384.593218] cma: cma_declare_contiguous(size 0x0000000200000000, base 0x0000000000000000, limit 0x0000000000000000 alignment 0x0000000000000000)
Jun 15 03:30:31 ubuntu-quickstart kernel: [  384.593228] cma: Reserved 8192 MiB at 0x0000001d4d000000
Jun 15 03:30:31 ubuntu-quickstart kernel: [  384.593345] BUG: Bad page state in process insmod  pfn:1d4d000
Jun 15 03:30:31 ubuntu-quickstart kernel: [  384.595758] page:ffffefc335340000 count:0 mapcount:-127 mapping:          (null) index:0x0
Jun 15 03:30:31 ubuntu-quickstart kernel: [  384.599193] flags: 0x57fffc000000000()
Jun 15 03:30:31 ubuntu-quickstart kernel: [  384.600751] raw: 057fffc000000000 0000000000000000 0000000000000000 00000000ffffff80
Jun 15 03:30:31 ubuntu-quickstart kernel: [  384.603946] raw: ffffefc335330020 ffffefc335350020 000000000000000a 0000000000000000
Jun 15 03:30:31 ubuntu-quickstart kernel: [  384.607152] page dumped because: nonzero mapcount

I am having a hard time trying to understand why the mapcount is less than 0 here. I figured this is happening in the call to __free_pages() from init_cma_reserved_pageblock().
Any pointers here would be really helpful. If I am missing any step for cma reservation, please do let me know.

Thanks in advance.
-Amit

[-- Attachment #2: Type: text/html, Size: 4947 bytes --]

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

* Re: dynamic reservation and allocation of physically contiguous memory using CMA
  2018-06-18 18:23 ` dynamic reservation and allocation of physically contiguous memory using CMA Amit Chandra (amichand)
@ 2018-06-19 11:45   ` Marek Szyprowski
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Szyprowski @ 2018-06-19 11:45 UTC (permalink / raw)
  To: Amit Chandra (amichand),
	linux-kernel, linux-arm-kernel, linux-samsung-soc, linux-media,
	linux-mm

Hi Amit,

On 2018-06-18 20:23, Amit Chandra (amichand) wrote:
>
> Hi experts,
>
> I had a question related to CMA. I have been trying to use the CMA 
> infra to reserve and allocate physically contiguous memory dynamically 
> at runtime.
>
> I built a custom kernel based on linux-4.14.47 to invoke the cma 
> initialization apis at runtime from kernel loadable module.
>
> I invoke cma_declare_contiguous() followed by cma_init_reserved_areas().
>
> cma_declare_contiguous throws no surprises and succeeds. The issue 
> happens when cma_init_reserved_areas() is invoked post that.
>
> Here is the kernel log snippet post that call:
>
> Jun 15 03:30:31 ubuntu-quickstart kernel: [A  384.593218] cma: 
> cma_declare_contiguous(size 0x0000000200000000, base 
> 0x0000000000000000, limit 0x0000000000000000 alignment 0x0000000000000000)
>
> Jun 15 03:30:31 ubuntu-quickstart kernel: [A  384.593228] cma: Reserved 
> 8192 MiB at 0x0000001d4d000000
>
> Jun 15 03:30:31 ubuntu-quickstart kernel: [A  384.593345] BUG: Bad page 
> state in process insmodA  pfn:1d4d000
>
> Jun 15 03:30:31 ubuntu-quickstart kernel: [A  384.595758] 
> page:ffffefc335340000 count:0 mapcount:-127 mapping:A A A A A A A A A  (null) 
> index:0x0
>
> Jun 15 03:30:31 ubuntu-quickstart kernel: [A  384.599193] flags: 
> 0x57fffc000000000()
>
> Jun 15 03:30:31 ubuntu-quickstart kernel: [A  384.600751] raw: 
> 057fffc000000000 0000000000000000 0000000000000000 00000000ffffff80
>
> Jun 15 03:30:31 ubuntu-quickstart kernel: [A  384.603946] raw: 
> ffffefc335330020 ffffefc335350020 000000000000000a 0000000000000000
>
> Jun 15 03:30:31 ubuntu-quickstart kernel: [A  384.607152] page dumped 
> because: nonzero mapcount
>
> I am having a hard time trying to understand why the mapcount is less 
> than 0 here. I figured this is happening in the call to __free_pages() 
> from init_cma_reserved_pageblock().
>
> Any pointers here would be really helpful. If I am missing any step 
> for cma reservation, please do let me know.
>
> Thanks in advance.
>

CMA initialization is possible only on very early boot stage. CMA will 
not work as dynamic module.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

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

end of thread, other threads:[~2018-06-19 11:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20180618182314epcas1p37a2b1ba6db9a829c07abf55ca0d3d50d@epcas1p3.samsung.com>
2018-06-18 18:23 ` dynamic reservation and allocation of physically contiguous memory using CMA Amit Chandra (amichand)
2018-06-19 11:45   ` Marek Szyprowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox