Skip to contentSkip to conversation

android: binder: use VM_ALLOC to get vm area.

PATCH Superseded Ganesh Mahendran 3 participants 5 messages Sep 1, 2016 – Sep 6, 2016 Android drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 android: binder: use VM_ALLOC to get vm area.

VM_IOREMAP is used to access hardware through a mechanism called I/O mapped memory. Android binder is a IPC machanism which will not access I/O memory.

Also VM_IOREMAP has alignment requiement which may not needed in binder.
----
__get_vm_area_node()
{
...

    if (flags & VM_IOREMAP)
        align = 1ul << clamp_t(int, fls_long(size),
           PAGE_SHIFT, IOREMAP_MAX_ORDER);

...
}
----

This patch use VM_ALLOC to get vm area.

---
 drivers/android/binder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/android/binder.c +1 -1
index 16288e7..3511d5c 100644
@@ -2885,7 +2885,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
 		goto err_already_mapped;
 	}
 
-	area = get_vm_area(vma->vm_end - vma->vm_start, VM_IOREMAP);
+	area = get_vm_area(vma->vm_end - vma->vm_start, VM_ALLOC);
 	if (area == NULL) {
 		ret = -ENOMEM;
 		failure_string = "get_vm_area";
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 29 lines · Ganesh Mahendran

VM_IOREMAP is used to access hardware through a mechanism called I/O mapped memory. Android binder is a IPC machanism which will not access I/O memory.

Also VM_IOREMAP has alignment requiement which may not needed in binder.
----
__get_vm_area_node()
{
...

    if (flags & VM_IOREMAP)
        align = 1ul << clamp_t(int, fls_long(size),
           PAGE_SHIFT, IOREMAP_MAX_ORDER);

...
}
----

This patch use VM_ALLOC to get vm area.

---
 drivers/android/binder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/android/binder.c +0 -0
index 16288e7..3511d5c 100644

drivers/android/binder.c static int binder_mmap(struct file *filp, struct vm_area_struct *vma) · line 2891

Quoted 8 lines
drivers/android/binder.c +1 -1
@@ -2885,7 +2885,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
 		goto err_already_mapped;
 	}
 
-	area = get_vm_area(vma->vm_end - vma->vm_start, VM_IOREMAP);
+	area = get_vm_area(vma->vm_end - vma->vm_start, VM_ALLOC);
 	if (area == NULL) {
 		ret = -ENOMEM;
 		failure_string = "get_vm_area";

What change have you noticed with this patch? Have you tested it? Found that previously reserved iomemory is now free for binder to use where it wasn't? What kind of change does the system now run as because of this?

And are you _sure_ the alignment requirement isn't needed for binder? Have you verified this with the userspace binder library?

This is messy, tricky, stuff, I'm loath to change it without loads of testing having happened...

thanks,

greg k-h

maintainer
#2 lore raw
Quoted 47 lines · Greg KH
Quoted 29 lines · Ganesh Mahendran

VM_IOREMAP is used to access hardware through a mechanism called I/O mapped memory. Android binder is a IPC machanism which will not access I/O memory.

Also VM_IOREMAP has alignment requiement which may not needed in binder.
----
__get_vm_area_node()
{
...

    if (flags & VM_IOREMAP)
        align = 1ul << clamp_t(int, fls_long(size),
           PAGE_SHIFT, IOREMAP_MAX_ORDER);

...
}
----

This patch use VM_ALLOC to get vm area.

---
 drivers/android/binder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/android/binder.c +0 -0
index 16288e7..3511d5c 100644

drivers/android/binder.c static int binder_mmap(struct file *filp, struct vm_area_struct *vma) · line 2891

Quoted 8 lines
drivers/android/binder.c +1 -1
@@ -2885,7 +2885,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
              goto err_already_mapped;
      }
 
-     area = get_vm_area(vma->vm_end - vma->vm_start, VM_IOREMAP);
+     area = get_vm_area(vma->vm_end - vma->vm_start, VM_ALLOC);
      if (area == NULL) {
              ret = -ENOMEM;
              failure_string = "get_vm_area";

What change have you noticed with this patch? Have you tested it? Found that previously reserved iomemory is now free for binder to use where it wasn't? What kind of change does the system now run as because of this?

And are you _sure_ the alignment requirement isn't needed for binder? Have you verified this with the userspace binder library?

Quoted 6 lines

This is messy, tricky, stuff, I'm loath to change it without loads of testing having happened...

thanks,

greg k-h

There is no alignment requirement on this area unless cache_is_vipt_aliasing returns true. In that case the area needs to be aligned with vma->vm_start which is done manually in the code right after this allocation. If there are no other side effects of changing this flag this change should be safe, but please run all the tests at
https://android.googlesource.com/platform/frameworks/native/+/master/libs/binder/tests/
to test it.

Signature · 1 line
Arve Hjønnevåg
#3 lore raw

2016-09-02 3:59 GMT+08:00 Arve Hjønnevåg <[email protected]>:

Quoted 55 lines · Greg KH
Quoted 47 lines · Ganesh Mahendran
Quoted 29 lines

VM_IOREMAP is used to access hardware through a mechanism called I/O mapped memory. Android binder is a IPC machanism which will not access I/O memory.

Also VM_IOREMAP has alignment requiement which may not needed in binder.
----
__get_vm_area_node()
{
...

    if (flags & VM_IOREMAP)
        align = 1ul << clamp_t(int, fls_long(size),
           PAGE_SHIFT, IOREMAP_MAX_ORDER);

...
}
----

This patch use VM_ALLOC to get vm area.

---
 drivers/android/binder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/android/binder.c +0 -0
index 16288e7..3511d5c 100644

drivers/android/binder.c static int binder_mmap(struct file *filp, struct vm_area_struct *vma) · line 2891

Quoted 8 lines
drivers/android/binder.c +1 -1
@@ -2885,7 +2885,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
              goto err_already_mapped;
      }
 
-     area = get_vm_area(vma->vm_end - vma->vm_start, VM_IOREMAP);
+     area = get_vm_area(vma->vm_end - vma->vm_start, VM_ALLOC);
      if (area == NULL) {
              ret = -ENOMEM;
              failure_string = "get_vm_area";

What change have you noticed with this patch? Have you tested it? Found that previously reserved iomemory is now free for binder to use where it wasn't? What kind of change does the system now run as because of this?

And are you _sure_ the alignment requirement isn't needed for binder? Have you verified this with the userspace binder library?

Quoted 6 lines

This is messy, tricky, stuff, I'm loath to change it without loads of testing having happened...

thanks,

greg k-h

Quoted 7 lines

There is no alignment requirement on this area unless cache_is_vipt_aliasing returns true. In that case the area needs to be aligned with vma->vm_start which is done manually in the code right after this allocation. If there are no other side effects of changing this flag this change should be safe, but please run all the tests at
https://android.googlesource.com/platform/frameworks/native/+/master/libs/binder/tests/
to test it.

Thanks for your suggestion.
I only did some android app performance test. I will do more binder test.

Thanks.

Quoted 3 lines

--
Arve Hjønnevåg

#4 lore raw
In reply to Greg KH

Hi, Greg:

2016-09-02 3:02 GMT+08:00 Greg KH <[email protected]>:

Quoted 33 lines · Ganesh Mahendran
Quoted 32 lines

VM_IOREMAP is used to access hardware through a mechanism called I/O mapped memory. Android binder is a IPC machanism which will not access I/O memory.

Also VM_IOREMAP has alignment requiement which may not needed in binder.
----
__get_vm_area_node()
{
...

    if (flags & VM_IOREMAP)
        align = 1ul << clamp_t(int, fls_long(size),
           PAGE_SHIFT, IOREMAP_MAX_ORDER);

...
}
----

This patch use VM_ALLOC to get vm area.

---
 drivers/android/binder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/android/binder.c +0 -0
index 16288e7..3511d5c 100644
@@ -2885,7 +2885,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
              goto err_already_mapped;
      }
 
Quoted 10 lines

drivers/android/binder.c static int binder_mmap(struct file *filp, struct vm_area_struct *vma) · line 2891

Quoted 5 lines
drivers/android/binder.c +1 -1
-     area = get_vm_area(vma->vm_end - vma->vm_start, VM_IOREMAP);
+     area = get_vm_area(vma->vm_end - vma->vm_start, VM_ALLOC);
      if (area == NULL) {
              ret = -ENOMEM;
              failure_string = "get_vm_area";

What change have you noticed with this patch? Have you tested it? Found that previously reserved iomemory is now free for binder to use where it wasn't? What kind of change does the system now run as because of this?

I did some sanity test in Android system. I will do more test using:
https://android.googlesource.com/platform/frameworks/native/+/master/libs/binder/tests/

Quoted 3 lines

And are you _sure_ the alignment requirement isn't needed for binder? Have you verified this with the userspace binder library?

I will do the binder test.

Thanks.

Quoted 7 lines

This is messy, tricky, stuff, I'm loath to change it without loads of testing having happened...

thanks,

greg k-h