* [PATCH] staging: ion: make the pte default none PTE_RDONLY
@ 2016-01-15 2:42 Chen Feng
2016-01-15 2:58 ` kbuild test robot
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Chen Feng @ 2016-01-15 2:42 UTC (permalink / raw)
To: gregkh, arve, riandrews, paul.gortmaker, labbott, gioh.kim,
tranmanphong, mitchelh, devel, linux-kernel, puck.chen, yudongbin,
saberlily.xia, suzhuangluan, kong.kongxinwei, xuyiping,
z.liuxinliang, weidong2, w.f, puck.chen, shimingxing, oliver.fu,
albert.lubing, chenxiang9, liuzixing, haojian.zhuang
Cc: qijiwen, peter.panshilin, dan.zhao, linuxarm, dev
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] staging: ion: make the pte default none PTE_RDONLY
2016-01-15 2:42 [PATCH] staging: ion: make the pte default none PTE_RDONLY Chen Feng
@ 2016-01-15 2:58 ` kbuild test robot
2016-01-15 3:10 ` kbuild test robot
2016-01-15 23:03 ` Laura Abbott
2 siblings, 0 replies; 9+ messages in thread
From: kbuild test robot @ 2016-01-15 2:58 UTC (permalink / raw)
To: Chen Feng
Cc: kbuild-all, gregkh, arve, riandrews, paul.gortmaker, labbott,
gioh.kim, tranmanphong, mitchelh, devel, linux-kernel, puck.chen,
yudongbin, saberlily.xia, suzhuangluan, kong.kongxinwei, xuyiping,
z.liuxinliang, weidong2, w.f, puck.chen, shimingxing, oliver.fu,
albert.lubing, chenxiang9, liuzixing, haojian.zhuang, qijiwen,
peter.panshilin, dan.zhao, linuxarm, dev
[-- Attachment #1: Type: text/plain, Size: 1709 bytes --]
Hi Chen,
[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.4 next-20160114]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Chen-Feng/staging-ion-make-the-pte-default-none-PTE_RDONLY/20160115-104450
config: x86_64-randconfig-x013-01140842 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
drivers/staging/android/ion/ion.c: In function 'ion_mmap':
>> drivers/staging/android/ion/ion.c:1030:34: error: incompatible type for argument 1 of 'pte_mkdirty'
vma->vm_page_prot = pte_mkdirty(vma->vm_page_prot);
^
In file included from include/linux/mm.h:55:0,
from include/linux/memblock.h:18,
from drivers/staging/android/ion/ion.c:26:
arch/x86/include/asm/pgtable.h:218:21: note: expected 'pte_t {aka struct <anonymous>}' but argument is of type 'pgprot_t {aka struct pgprot}'
static inline pte_t pte_mkdirty(pte_t pte)
^
vim +/pte_mkdirty +1030 drivers/staging/android/ion/ion.c
1024 }
1025
1026 if (!(buffer->flags & ION_FLAG_CACHED))
1027 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
1028
1029 /*Default writeable*/
> 1030 vma->vm_page_prot = pte_mkdirty(vma->vm_page_prot);
1031
1032 mutex_lock(&buffer->lock);
1033 /* now map it to userspace */
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 28435 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] staging: ion: make the pte default none PTE_RDONLY
2016-01-15 2:42 [PATCH] staging: ion: make the pte default none PTE_RDONLY Chen Feng
2016-01-15 2:58 ` kbuild test robot
@ 2016-01-15 3:10 ` kbuild test robot
2016-01-15 23:03 ` Laura Abbott
2 siblings, 0 replies; 9+ messages in thread
From: kbuild test robot @ 2016-01-15 3:10 UTC (permalink / raw)
To: Chen Feng
Cc: kbuild-all, gregkh, arve, riandrews, paul.gortmaker, labbott,
gioh.kim, tranmanphong, mitchelh, devel, linux-kernel, puck.chen,
yudongbin, saberlily.xia, suzhuangluan, kong.kongxinwei, xuyiping,
z.liuxinliang, weidong2, w.f, puck.chen, shimingxing, oliver.fu,
albert.lubing, chenxiang9, liuzixing, haojian.zhuang, qijiwen,
peter.panshilin, dan.zhao, linuxarm, dev
[-- Attachment #1: Type: text/plain, Size: 2878 bytes --]
Hi Chen,
[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.4 next-20160114]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Chen-Feng/staging-ion-make-the-pte-default-none-PTE_RDONLY/20160115-104450
config: ia64-allyesconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64
All error/warnings (new ones prefixed by >>):
In file included from arch/ia64/include/asm/ptrace.h:45:0,
from arch/ia64/include/asm/processor.h:19,
from include/linux/mutex.h:19,
from include/linux/kernfs.h:13,
from include/linux/sysfs.h:15,
from include/linux/kobject.h:21,
from include/linux/device.h:17,
from drivers/staging/android/ion/ion.c:18:
drivers/staging/android/ion/ion.c: In function 'ion_mmap':
>> arch/ia64/include/asm/page.h:183:25: error: 'pgprot_t' has no member named 'pte'
# define pte_val(x) ((x).pte)
^
arch/ia64/include/asm/page.h:191:31: note: in definition of macro '__pte'
# define __pte(x) ((pte_t) { (x) } )
^
>> arch/ia64/include/asm/pgtable.h:311:33: note: in expansion of macro 'pte_val'
#define pte_mkdirty(pte) (__pte(pte_val(pte) | _PAGE_D))
^
>> drivers/staging/android/ion/ion.c:1030:22: note: in expansion of macro 'pte_mkdirty'
vma->vm_page_prot = pte_mkdirty(vma->vm_page_prot);
^
vim +/pte_mkdirty +1030 drivers/staging/android/ion/ion.c
1014 return -EINVAL;
1015 }
1016
1017 if (ion_buffer_fault_user_mappings(buffer)) {
1018 vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND |
1019 VM_DONTDUMP;
1020 vma->vm_private_data = buffer;
1021 vma->vm_ops = &ion_vma_ops;
1022 ion_vm_open(vma);
1023 return 0;
1024 }
1025
1026 if (!(buffer->flags & ION_FLAG_CACHED))
1027 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
1028
1029 /*Default writeable*/
> 1030 vma->vm_page_prot = pte_mkdirty(vma->vm_page_prot);
1031
1032 mutex_lock(&buffer->lock);
1033 /* now map it to userspace */
1034 ret = buffer->heap->ops->map_user(buffer->heap, buffer, vma);
1035 mutex_unlock(&buffer->lock);
1036
1037 if (ret)
1038 pr_err("%s: failure mapping buffer to userspace\n",
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 44528 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] staging: ion: make the pte default none PTE_RDONLY
2016-01-15 2:42 [PATCH] staging: ion: make the pte default none PTE_RDONLY Chen Feng
@ 2016-01-15 23:03 ` Laura Abbott
2016-01-15 3:10 ` kbuild test robot
2016-01-15 23:03 ` Laura Abbott
2 siblings, 0 replies; 9+ messages in thread
From: Laura Abbott @ 2016-01-15 23:03 UTC (permalink / raw)
To: linux-arm-kernel
(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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] staging: ion: make the pte default none PTE_RDONLY
@ 2016-01-15 23:03 ` Laura Abbott
0 siblings, 0 replies; 9+ messages in thread
From: Laura Abbott @ 2016-01-15 23:03 UTC (permalink / raw)
To: Chen Feng, gregkh, arve, riandrews, paul.gortmaker, gioh.kim,
tranmanphong, mitchelh, devel, linux-kernel, yudongbin,
saberlily.xia, suzhuangluan, kong.kongxinwei, xuyiping,
z.liuxinliang, weidong2, w.f, puck.chen, shimingxing, oliver.fu,
albert.lubing, chenxiang9, liuzixing, haojian.zhuang,
Catalin Marinas, Will Deacon
Cc: qijiwen, peter.panshilin, dan.zhao, linuxarm, dev,
linux-arm-kernel
(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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] staging: ion: make the pte default none PTE_RDONLY
2016-01-15 23:03 ` Laura Abbott
@ 2016-01-15 23:23 ` Russell King - ARM Linux
-1 siblings, 0 replies; 9+ messages in thread
From: Russell King - ARM Linux @ 2016-01-15 23:23 UTC (permalink / raw)
To: linux-arm-kernel
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] staging: ion: make the pte default none PTE_RDONLY
@ 2016-01-15 23:23 ` Russell King - ARM Linux
0 siblings, 0 replies; 9+ messages in thread
From: Russell King - ARM Linux @ 2016-01-15 23:23 UTC (permalink / raw)
To: Laura Abbott
Cc: Chen Feng, gregkh, arve, riandrews, paul.gortmaker, gioh.kim,
tranmanphong, mitchelh, devel, linux-kernel, yudongbin,
saberlily.xia, suzhuangluan, kong.kongxinwei, xuyiping,
z.liuxinliang, weidong2, w.f, puck.chen, shimingxing, oliver.fu,
albert.lubing, chenxiang9, liuzixing, haojian.zhuang,
Catalin Marinas, Will Deacon, dan.zhao, peter.panshilin, linuxarm,
dev, qijiwen, linux-arm-kernel
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] staging: ion: make the pte default none PTE_RDONLY
2016-01-15 23:23 ` Russell King - ARM Linux
@ 2016-01-18 3:44 ` chenfeng
-1 siblings, 0 replies; 9+ messages in thread
From: chenfeng @ 2016-01-18 3:44 UTC (permalink / raw)
To: linux-arm-kernel
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] staging: ion: make the pte default none PTE_RDONLY
@ 2016-01-18 3:44 ` chenfeng
0 siblings, 0 replies; 9+ messages in thread
From: chenfeng @ 2016-01-18 3:44 UTC (permalink / raw)
To: Russell King - ARM Linux, Laura Abbott
Cc: gregkh, arve, riandrews, paul.gortmaker, gioh.kim, tranmanphong,
mitchelh, devel, linux-kernel, yudongbin, saberlily.xia,
suzhuangluan, kong.kongxinwei, xuyiping, z.liuxinliang, weidong2,
w.f, puck.chen, shimingxing, oliver.fu, albert.lubing, chenxiang9,
liuzixing, haojian.zhuang, Catalin Marinas, Will Deacon, dan.zhao,
peter.panshilin, linuxarm, dev, qijiwen, linux-arm-kernel
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-01-18 3:45 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-15 2:42 [PATCH] staging: ion: make the pte default none PTE_RDONLY Chen Feng
2016-01-15 2:58 ` kbuild test robot
2016-01-15 3:10 ` kbuild test robot
2016-01-15 23:03 ` Laura Abbott
2016-01-15 23:03 ` Laura Abbott
2016-01-15 23:23 ` Russell King - ARM Linux
2016-01-15 23:23 ` Russell King - ARM Linux
2016-01-18 3:44 ` chenfeng
2016-01-18 3:44 ` chenfeng
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.