All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jichao Zou <zoujc@motorola.com>
To: Robin Murphy <robin.murphy@arm.com>,
	David Hildenbrand <david@redhat.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"minchan@kernel.org" <minchan@kernel.org>,
	"song.bao.hua@hisilicon.com" <song.bao.hua@hisilicon.com>,
	"hch@lst.de" <hch@lst.de>,
	"m.szyprowski@samsung.com" <m.szyprowski@samsung.com>,
	"iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	JianQi Yang <yangj@motorola.com>,
	Yanjune Tian <tianyje@motorola.com>
Subject: 回复: 回复: 回复: [External]Re: An cma optimization patch is used for cma_[alloc|free].
Date: Fri, 13 Aug 2021 11:26:06 +0000	[thread overview]
Message-ID: <HK0PR03MB417715BB2424508E24836E08D5FA9@HK0PR03MB4177.apcprd03.prod.outlook.com> (raw)
In-Reply-To: <52c0b1fd-d60f-5d7d-0b47-b3569678ebf6@arm.com>

Hi Robin, David
	Thank you for your guidance very much, we'll go ahead and see if some heap drivers can use carveout heap instead.

Thanks.

Best Regards,

-----邮件原件-----
发件人: Robin Murphy <robin.murphy@arm.com> 
发送时间: 2021年8月13日 18:08
收件人: Jichao Zou <zoujc@motorola.com>; David Hildenbrand <david@redhat.com>; akpm@linux-foundation.org; linux-kernel@vger.kernel.org; linux-mm@kvack.org; minchan@kernel.org; song.bao.hua@hisilicon.com; hch@lst.de; m.szyprowski@samsung.com; iommu@lists.linux-foundation.org; JianQi Yang <yangj@motorola.com>; Yanjune Tian <tianyje@motorola.com>
主题: Re: 回复: 回复: [External]Re: An cma optimization patch is used for cma_[alloc|free].

On 2021-08-13 10:46, Jichao Zou wrote:
> I got it, but in kernel that we used version, many heap drivers that in drivers/dma-buf/ are based on CMA, not DMA carveout!
> If this patch is not accepted, we cancel it!!!

If you just want dma_alloc_coherent() to work automatically from a carveout in the same manner as CMA, without having to stick
of_reserved_mem_device_init() calls everywhere to make drivers aware of per-device carveouts, then [1] is probably what you want.

If it's specifically dma-buf heaps that you're interested in, then hacking the common CMA code to make the CMA heap behave like a carveout heap is definitely the wrong approach - just implement a carveout heap properly. It seems the only reason that hasn't ported over from ION is that nobody's needed it yet[2].

Robin.

[1] https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flinux-iommu%2F20210712061704.4162464-1-hch%40lst.de%2F&amp;data=04%7C01%7Czoujc%40motorola.com%7C9fca069e1915449946cb08d95e424546%7C5c7d0b28bdf8410caa934df372b16203%7C1%7C0%7C637644461066004509%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=OXFP48WvObcBZX%2FwKWiPtQPNwzcWHxaKaIr5MAvaq5g%3D&amp;reserved=0
[2] https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flwn.net%2FArticles%2F801230%2F&amp;data=04%7C01%7Czoujc%40motorola.com%7C9fca069e1915449946cb08d95e424546%7C5c7d0b28bdf8410caa934df372b16203%7C1%7C0%7C637644461066004509%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=N7GnFf4zGMDPzfg1GGOoUvddBI4U4bp7Kib34arwkBI%3D&amp;reserved=0

> 
> Thank you all.
> 
> Best Regards,
> 
> -----邮件原件-----
> 发件人: Robin Murphy <robin.murphy@arm.com>
> 发送时间: 2021年8月13日 17:16
> 收件人: Jichao Zou <zoujc@motorola.com>; David Hildenbrand 
> <david@redhat.com>; akpm@linux-foundation.org; 
> linux-kernel@vger.kernel.org; linux-mm@kvack.org; minchan@kernel.org; 
> song.bao.hua@hisilicon.com; hch@lst.de; m.szyprowski@samsung.com; 
> iommu@lists.linux-foundation.org; JianQi Yang <yangj@motorola.com>; 
> Yanjune Tian <tianyje@motorola.com>
> 主题: Re: 回复: [External]Re: An cma optimization patch is used for cma_[alloc|free].
> 
> On 2021-08-13 09:27, Jichao Zou wrote:
>> Hi David,
>> 	I'll git-send-email patch again.
>> 	Your understanding is exactly right.
>> 	Let me explain the background of Patch, we are developing Android phone, kernel is 5.10.43 LTS, we encounter cma_alloc failed during kernel startup, buddy system is ready,
>> 01-11 14:22:08.650   216   216 E cma     : cma_alloc([216][init]:cma(ffffffff00b50000:total 8192) linux,cma(ffffffe89d084cf0), count 2, align 1 gfp_mask 0xcc0)
>> 01-11 14:22:08.650   216   216 E cma     : cma_alloc(): memory range at ffffffff00b62880 is busy, retrying
>>    
>> 	cma bitmap show memory is free, but alloc_contig_range failed, we checked it out that some drivers cma_alloc are
>> 	"struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, bool no_warn)"
>> 	In 5.10.43, cma_alloc is
>> 	"struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, gfp_t gfp_mask)"
>>    	After change cma_alloc parameter with GFP_KERNEL, issue is fixed, at the same time, we found that preallocate a portion of cma memory for audio&video resulted in better performance and guarantee AV function even under memory pressure, so we try to submit this patch.
> 
> The whole point of CMA is that the memory can be shared by moveable pages while it's not being used for DMA. If you want a dedicated DMA carveout, there are already mechanisms for that.
> 
> Robin.
> 
>>
>> Thanks.
>>
>> Best Regards,
>>
>> Zou Jichao 邹纪超
>> Advisory Engineer, SW BSP
>> MBG ROW SW BJ PF BSP (CN)
>> Motorola Mobility, A Lenovo Company
>> motorola.com
>> M +86 18910860212
>> E zoujc@lenovo.com
>> twitter | facebook | instagram | blog | forums
>>
>>
>>
>>
>> -----邮件原件-----
>> 发件人: David Hildenbrand <david@redhat.com>
>> 发送时间: 2021年8月13日 15:45
>> 收件人: Jichao Zou <zoujc@motorola.com>; akpm@linux-foundation.org; 
>> linux-kernel@vger.kernel.org; linux-mm@kvack.org; minchan@kernel.org; 
>> song.bao.hua@hisilicon.com; hch@lst.de; m.szyprowski@samsung.com; 
>> robin.murphy@arm.com; iommu@lists.linux-foundation.org; JianQi Yang 
>> <yangj@motorola.com>; Yanjune Tian <tianyje@motorola.com>
>> 主题: [External]Re: An cma optimization patch is used for cma_[alloc|free].
>>
>> On 13.08.21 09:00, Jichao Zou wrote:
>>> Pre-allocate CMA memory that configured in device tree, this greatly 
>>> improves the CMA memory allocation efficiency, cma_[alloc|free] is 
>>> less than 1ms, old way is took a few ms to tens or hundreds ms.
>>>
>>
>> Please send patches as proper emails (man git-format-patch; man git-send-email).
>>
>> What you propose is turning cma reservations into something comparable to permanent boottime allocations. From the POV of the buddy, the pages are always allocated and cannot be repurposed for e.g., movable allocations until *actually* allocated via CMA.
>>
>> I don't think we want this behavior upstream.
>>
>> --
>> Thanks,
>>
>> David / dhildenb
>>

WARNING: multiple messages have this Message-ID (diff)
From: Jichao Zou <zoujc@motorola.com>
To: Robin Murphy <robin.murphy@arm.com>,
	David Hildenbrand <david@redhat.com>,
	 "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"minchan@kernel.org" <minchan@kernel.org>,
	"song.bao.hua@hisilicon.com" <song.bao.hua@hisilicon.com>,
	"hch@lst.de" <hch@lst.de>,
	"m.szyprowski@samsung.com" <m.szyprowski@samsung.com>,
	"iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	JianQi Yang <yangj@motorola.com>,
	Yanjune Tian <tianyje@motorola.com>
Subject: 回复: 回复: 回复: [External]Re: An cma optimization patch is used for cma_[alloc|free].
Date: Fri, 13 Aug 2021 11:26:06 +0000	[thread overview]
Message-ID: <HK0PR03MB417715BB2424508E24836E08D5FA9@HK0PR03MB4177.apcprd03.prod.outlook.com> (raw)
In-Reply-To: <52c0b1fd-d60f-5d7d-0b47-b3569678ebf6@arm.com>

Hi Robin, David
	Thank you for your guidance very much, we'll go ahead and see if some heap drivers can use carveout heap instead.

Thanks.

Best Regards,

-----邮件原件-----
发件人: Robin Murphy <robin.murphy@arm.com> 
发送时间: 2021年8月13日 18:08
收件人: Jichao Zou <zoujc@motorola.com>; David Hildenbrand <david@redhat.com>; akpm@linux-foundation.org; linux-kernel@vger.kernel.org; linux-mm@kvack.org; minchan@kernel.org; song.bao.hua@hisilicon.com; hch@lst.de; m.szyprowski@samsung.com; iommu@lists.linux-foundation.org; JianQi Yang <yangj@motorola.com>; Yanjune Tian <tianyje@motorola.com>
主题: Re: 回复: 回复: [External]Re: An cma optimization patch is used for cma_[alloc|free].

On 2021-08-13 10:46, Jichao Zou wrote:
> I got it, but in kernel that we used version, many heap drivers that in drivers/dma-buf/ are based on CMA, not DMA carveout!
> If this patch is not accepted, we cancel it!!!

If you just want dma_alloc_coherent() to work automatically from a carveout in the same manner as CMA, without having to stick
of_reserved_mem_device_init() calls everywhere to make drivers aware of per-device carveouts, then [1] is probably what you want.

If it's specifically dma-buf heaps that you're interested in, then hacking the common CMA code to make the CMA heap behave like a carveout heap is definitely the wrong approach - just implement a carveout heap properly. It seems the only reason that hasn't ported over from ION is that nobody's needed it yet[2].

Robin.

[1] https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flinux-iommu%2F20210712061704.4162464-1-hch%40lst.de%2F&amp;data=04%7C01%7Czoujc%40motorola.com%7C9fca069e1915449946cb08d95e424546%7C5c7d0b28bdf8410caa934df372b16203%7C1%7C0%7C637644461066004509%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=OXFP48WvObcBZX%2FwKWiPtQPNwzcWHxaKaIr5MAvaq5g%3D&amp;reserved=0
[2] https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flwn.net%2FArticles%2F801230%2F&amp;data=04%7C01%7Czoujc%40motorola.com%7C9fca069e1915449946cb08d95e424546%7C5c7d0b28bdf8410caa934df372b16203%7C1%7C0%7C637644461066004509%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=N7GnFf4zGMDPzfg1GGOoUvddBI4U4bp7Kib34arwkBI%3D&amp;reserved=0

> 
> Thank you all.
> 
> Best Regards,
> 
> -----邮件原件-----
> 发件人: Robin Murphy <robin.murphy@arm.com>
> 发送时间: 2021年8月13日 17:16
> 收件人: Jichao Zou <zoujc@motorola.com>; David Hildenbrand 
> <david@redhat.com>; akpm@linux-foundation.org; 
> linux-kernel@vger.kernel.org; linux-mm@kvack.org; minchan@kernel.org; 
> song.bao.hua@hisilicon.com; hch@lst.de; m.szyprowski@samsung.com; 
> iommu@lists.linux-foundation.org; JianQi Yang <yangj@motorola.com>; 
> Yanjune Tian <tianyje@motorola.com>
> 主题: Re: 回复: [External]Re: An cma optimization patch is used for cma_[alloc|free].
> 
> On 2021-08-13 09:27, Jichao Zou wrote:
>> Hi David,
>> 	I'll git-send-email patch again.
>> 	Your understanding is exactly right.
>> 	Let me explain the background of Patch, we are developing Android phone, kernel is 5.10.43 LTS, we encounter cma_alloc failed during kernel startup, buddy system is ready,
>> 01-11 14:22:08.650   216   216 E cma     : cma_alloc([216][init]:cma(ffffffff00b50000:total 8192) linux,cma(ffffffe89d084cf0), count 2, align 1 gfp_mask 0xcc0)
>> 01-11 14:22:08.650   216   216 E cma     : cma_alloc(): memory range at ffffffff00b62880 is busy, retrying
>>    
>> 	cma bitmap show memory is free, but alloc_contig_range failed, we checked it out that some drivers cma_alloc are
>> 	"struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, bool no_warn)"
>> 	In 5.10.43, cma_alloc is
>> 	"struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, gfp_t gfp_mask)"
>>    	After change cma_alloc parameter with GFP_KERNEL, issue is fixed, at the same time, we found that preallocate a portion of cma memory for audio&video resulted in better performance and guarantee AV function even under memory pressure, so we try to submit this patch.
> 
> The whole point of CMA is that the memory can be shared by moveable pages while it's not being used for DMA. If you want a dedicated DMA carveout, there are already mechanisms for that.
> 
> Robin.
> 
>>
>> Thanks.
>>
>> Best Regards,
>>
>> Zou Jichao 邹纪超
>> Advisory Engineer, SW BSP
>> MBG ROW SW BJ PF BSP (CN)
>> Motorola Mobility, A Lenovo Company
>> motorola.com
>> M +86 18910860212
>> E zoujc@lenovo.com
>> twitter | facebook | instagram | blog | forums
>>
>>
>>
>>
>> -----邮件原件-----
>> 发件人: David Hildenbrand <david@redhat.com>
>> 发送时间: 2021年8月13日 15:45
>> 收件人: Jichao Zou <zoujc@motorola.com>; akpm@linux-foundation.org; 
>> linux-kernel@vger.kernel.org; linux-mm@kvack.org; minchan@kernel.org; 
>> song.bao.hua@hisilicon.com; hch@lst.de; m.szyprowski@samsung.com; 
>> robin.murphy@arm.com; iommu@lists.linux-foundation.org; JianQi Yang 
>> <yangj@motorola.com>; Yanjune Tian <tianyje@motorola.com>
>> 主题: [External]Re: An cma optimization patch is used for cma_[alloc|free].
>>
>> On 13.08.21 09:00, Jichao Zou wrote:
>>> Pre-allocate CMA memory that configured in device tree, this greatly 
>>> improves the CMA memory allocation efficiency, cma_[alloc|free] is 
>>> less than 1ms, old way is took a few ms to tens or hundreds ms.
>>>
>>
>> Please send patches as proper emails (man git-format-patch; man git-send-email).
>>
>> What you propose is turning cma reservations into something comparable to permanent boottime allocations. From the POV of the buddy, the pages are always allocated and cannot be repurposed for e.g., movable allocations until *actually* allocated via CMA.
>>
>> I don't think we want this behavior upstream.
>>
>> --
>> Thanks,
>>
>> David / dhildenb
>>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2021-08-13 11:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13  7:00 An cma optimization patch is used for cma_[alloc|free] Jichao Zou
2021-08-13  7:00 ` Jichao Zou
2021-08-13  7:45 ` David Hildenbrand
2021-08-13  7:45   ` David Hildenbrand
2021-08-13  8:27   ` 回复: [External]Re: " Jichao Zou
2021-08-13  8:27     ` Jichao Zou
2021-08-13  9:15     ` Robin Murphy
2021-08-13  9:15       ` Robin Murphy
2021-08-13  9:46       ` 回复: " Jichao Zou
2021-08-13  9:46         ` Jichao Zou
2021-08-13 10:08         ` Robin Murphy
2021-08-13 10:08           ` Robin Murphy
2021-08-13 11:26           ` Jichao Zou [this message]
2021-08-13 11:26             ` 回复: " Jichao Zou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=HK0PR03MB417715BB2424508E24836E08D5FA9@HK0PR03MB4177.apcprd03.prod.outlook.com \
    --to=zoujc@motorola.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=m.szyprowski@samsung.com \
    --cc=minchan@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=song.bao.hua@hisilicon.com \
    --cc=tianyje@motorola.com \
    --cc=yangj@motorola.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.