Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1309834 > unrolled thread

[PATCH] staging: ion: make the pte default none PTE_RDONLY

Started byChen Feng <puck.chen@hisilicon.com>
First post2016-01-15 03:50 +0100
Last post2016-01-18 04:50 +0100
Articles 4 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] staging: ion: make the pte default none PTE_RDONLY Chen Feng <puck.chen@hisilicon.com> - 2016-01-15 03:50 +0100
    Re: [PATCH] staging: ion: make the pte default none PTE_RDONLY Laura Abbott <labbott@redhat.com> - 2016-01-16 00:10 +0100
      Re: [PATCH] staging: ion: make the pte default none PTE_RDONLY Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-01-16 00:30 +0100
        Re: [PATCH] staging: ion: make the pte default none PTE_RDONLY chenfeng <puck.chen@hisilicon.com> - 2016-01-18 04:50 +0100

#1309834 — [PATCH] staging: ion: make the pte default none PTE_RDONLY

FromChen Feng <puck.chen@hisilicon.com>
Date2016-01-15 03:50 +0100
Subject[PATCH] staging: ion: make the pte default none PTE_RDONLY
Message-ID<qR2CC-81R-7@gated-at.bofh.it>
The page is already alloc at ion_alloc function,
ion_mmap map the alloced pages to user-space.

The default prot can be PTE_RDONLY. Take a look at
here:
set_pte_at()
arch/arm64/include/asm:
		if (pte_dirty(pte) && pte_write(pte))
			pte_val(pte) &= ~PTE_RDONLY;
		else
			pte_val(pte) |= PTE_RDONLY;

So with the dirty bit,it can improve the efficiency
and donnot need to handle memory fault when use access.

Signed-off-by: Chen Feng <puck.chen@hisilicon.com>
Signed-off-by: Wei Dong <weidong2@hisilicon.com>
Reviewed-by: Zhuangluan Su <suzhuangluan@hisilicon.com>
---
 drivers/staging/android/ion/ion.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index e237e9f..dba5942 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -1026,6 +1026,9 @@ static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
 	if (!(buffer->flags & ION_FLAG_CACHED))
 		vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
 
+	/*Default writeable*/
+	vma->vm_page_prot = pte_mkdirty(vma->vm_page_prot);
+
 	mutex_lock(&buffer->lock);
 	/* now map it to userspace */
 	ret = buffer->heap->ops->map_user(buffer->heap, buffer, vma);
-- 
1.9.1

[toc] | [next] | [standalone]


#1310519

FromLaura Abbott <labbott@redhat.com>
Date2016-01-16 00:10 +0100
Message-ID<qRlFf-4qa-1@gated-at.bofh.it>
In reply to#1309834
(adding linux-arm and a few people)

On 01/14/2016 06:42 PM, Chen Feng wrote:
> The page is already alloc at ion_alloc function,
> ion_mmap map the alloced pages to user-space.
>
> The default prot can be PTE_RDONLY. Take a look at
> here:
> set_pte_at()
> arch/arm64/include/asm:
> 		if (pte_dirty(pte) && pte_write(pte))
> 			pte_val(pte) &= ~PTE_RDONLY;
> 		else
> 			pte_val(pte) |= PTE_RDONLY;
>
> So with the dirty bit,it can improve the efficiency
> and donnot need to handle memory fault when use access.
>
> Signed-off-by: Chen Feng <puck.chen@hisilicon.com>
> Signed-off-by: Wei Dong <weidong2@hisilicon.com>
> Reviewed-by: Zhuangluan Su <suzhuangluan@hisilicon.com>
> ---
>   drivers/staging/android/ion/ion.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
> index e237e9f..dba5942 100644
> --- a/drivers/staging/android/ion/ion.c
> +++ b/drivers/staging/android/ion/ion.c
> @@ -1026,6 +1026,9 @@ static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
>   	if (!(buffer->flags & ION_FLAG_CACHED))
>   		vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
>
> +	/*Default writeable*/
> +	vma->vm_page_prot = pte_mkdirty(vma->vm_page_prot);
> +
>   	mutex_lock(&buffer->lock);
>   	/* now map it to userspace */
>   	ret = buffer->heap->ops->map_user(buffer->heap, buffer, vma);
>

The extra fault is unfortunate but I'm skeptical about just setting
pte_mkdirty.

Catalin/Will, do you have any thoughts? Right now it seems like any
range mapped with remap_pfn_range will have this extra fault
behavior. Is marking the range dirty the best solution?

Thanks,
Laura

[toc] | [prev] | [next] | [standalone]


#1310524

FromRussell King - ARM Linux <linux@arm.linux.org.uk>
Date2016-01-16 00:30 +0100
Message-ID<qRlYC-4wi-5@gated-at.bofh.it>
In reply to#1310519
On Fri, Jan 15, 2016 at 03:03:42PM -0800, Laura Abbott wrote:
> (adding linux-arm and a few people)
> 
> On 01/14/2016 06:42 PM, Chen Feng wrote:
> >The page is already alloc at ion_alloc function,
> >ion_mmap map the alloced pages to user-space.
> >
> >The default prot can be PTE_RDONLY. Take a look at
> >here:
> >set_pte_at()
> >arch/arm64/include/asm:
> >		if (pte_dirty(pte) && pte_write(pte))
> >			pte_val(pte) &= ~PTE_RDONLY;
> >		else
> >			pte_val(pte) |= PTE_RDONLY;
> >
> >So with the dirty bit,it can improve the efficiency
> >and donnot need to handle memory fault when use access.
> >
> >Signed-off-by: Chen Feng <puck.chen@hisilicon.com>
> >Signed-off-by: Wei Dong <weidong2@hisilicon.com>
> >Reviewed-by: Zhuangluan Su <suzhuangluan@hisilicon.com>
> >---
> >  drivers/staging/android/ion/ion.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> >diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
> >index e237e9f..dba5942 100644
> >--- a/drivers/staging/android/ion/ion.c
> >+++ b/drivers/staging/android/ion/ion.c
> >@@ -1026,6 +1026,9 @@ static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
> >  	if (!(buffer->flags & ION_FLAG_CACHED))
> >  		vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
> >
> >+	/*Default writeable*/
> >+	vma->vm_page_prot = pte_mkdirty(vma->vm_page_prot);
> >+
> >  	mutex_lock(&buffer->lock);
> >  	/* now map it to userspace */
> >  	ret = buffer->heap->ops->map_user(buffer->heap, buffer, vma);
> >
> 
> The extra fault is unfortunate but I'm skeptical about just setting
> pte_mkdirty.
> 
> Catalin/Will, do you have any thoughts? Right now it seems like any
> range mapped with remap_pfn_range will have this extra fault
> behavior. Is marking the range dirty the best solution?

What happens if the mapping requested was read only - at the very
least, I don't think this should be done unconditionally.

-- 
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

[toc] | [prev] | [next] | [standalone]


#1311296

Fromchenfeng <puck.chen@hisilicon.com>
Date2016-01-18 04:50 +0100
Message-ID<qS8Zj-3pH-3@gated-at.bofh.it>
In reply to#1310524

On 2016/1/16 7:23, Russell King - ARM Linux wrote:
> On Fri, Jan 15, 2016 at 03:03:42PM -0800, Laura Abbott wrote:
>> (adding linux-arm and a few people)
>>
>> On 01/14/2016 06:42 PM, Chen Feng wrote:
>>> The page is already alloc at ion_alloc function,
>>> ion_mmap map the alloced pages to user-space.
>>>
>>> The default prot can be PTE_RDONLY. Take a look at
>>> here:
>>> set_pte_at()
>>> arch/arm64/include/asm:
>>> 		if (pte_dirty(pte) && pte_write(pte))
>>> 			pte_val(pte) &= ~PTE_RDONLY;
>>> 		else
>>> 			pte_val(pte) |= PTE_RDONLY;
>>>
>>> So with the dirty bit,it can improve the efficiency
>>> and donnot need to handle memory fault when use access.
>>>
>>> Signed-off-by: Chen Feng <puck.chen@hisilicon.com>
>>> Signed-off-by: Wei Dong <weidong2@hisilicon.com>
>>> Reviewed-by: Zhuangluan Su <suzhuangluan@hisilicon.com>
>>> ---
>>>  drivers/staging/android/ion/ion.c | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
>>> index e237e9f..dba5942 100644
>>> --- a/drivers/staging/android/ion/ion.c
>>> +++ b/drivers/staging/android/ion/ion.c
>>> @@ -1026,6 +1026,9 @@ static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
>>>  	if (!(buffer->flags & ION_FLAG_CACHED))
>>>  		vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
>>>
>>> +	/*Default writeable*/
>>> +	vma->vm_page_prot = pte_mkdirty(vma->vm_page_prot);
>>> +
>>>  	mutex_lock(&buffer->lock);
>>>  	/* now map it to userspace */
>>>  	ret = buffer->heap->ops->map_user(buffer->heap, buffer, vma);
>>>
>>
>> The extra fault is unfortunate but I'm skeptical about just setting
>> pte_mkdirty.
>>
>> Catalin/Will, do you have any thoughts? Right now it seems like any
>> range mapped with remap_pfn_range will have this extra fault
>> behavior. Is marking the range dirty the best solution?
Laura Abbott,

I agree with you, it seems all the remap_pfn_range have this fault behavior.


> 
> What happens if the mapping requested was read only - at the very
> least, I don't think this should be done unconditionally.
> 
Russell,
I am not sure about doing this unconditionally, but it can waste memory&time
while handling page fault with ion alloced page.

And the page can be used directly.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web