linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] android: binder: use VM_ALLOC to get vm area
@ 2018-01-10  2:49 Ganesh Mahendran
  2018-01-22 15:54 ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Ganesh Mahendran @ 2018-01-10  2:49 UTC (permalink / raw)
  To: gregkh, maco, tkjos, arve; +Cc: linux-kernel, 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.

And 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 will save some kernel vm area, especially for 32bit os.

In 32bit OS, kernel vm area is only 240MB. We may got below
error when launching a app:

<3>[ 4482.440053] binder_alloc: binder_alloc_mmap_handler: 15728 8ce67000-8cf65000 get_vm_area failed -12
<3>[ 4483.218817] binder_alloc: binder_alloc_mmap_handler: 15745 8ce67000-8cf65000 get_vm_area failed -12

Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
----
V3: update comments
V2: update comments
---
 drivers/android/binder_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 07b866a..5a426c8 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -670,7 +670,7 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
 		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";
-- 
1.9.1

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

* Re: [PATCH v3] android: binder: use VM_ALLOC to get vm area
  2018-01-10  2:49 [PATCH v3] android: binder: use VM_ALLOC to get vm area Ganesh Mahendran
@ 2018-01-22 15:54 ` Greg KH
  2018-01-22 17:02   ` Todd Kjos
  2018-01-24 14:33   ` Martijn Coenen
  0 siblings, 2 replies; 9+ messages in thread
From: Greg KH @ 2018-01-22 15:54 UTC (permalink / raw)
  To: Ganesh Mahendran; +Cc: maco, tkjos, arve, linux-kernel

On Wed, Jan 10, 2018 at 10:49:05AM +0800, Ganesh Mahendran wrote:
> 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.
> 
> And 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 will save some kernel vm area, especially for 32bit os.
> 
> In 32bit OS, kernel vm area is only 240MB. We may got below
> error when launching a app:
> 
> <3>[ 4482.440053] binder_alloc: binder_alloc_mmap_handler: 15728 8ce67000-8cf65000 get_vm_area failed -12
> <3>[ 4483.218817] binder_alloc: binder_alloc_mmap_handler: 15745 8ce67000-8cf65000 get_vm_area failed -12
> 
> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
> ----
> V3: update comments
> V2: update comments
> ---
>  drivers/android/binder_alloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Martijn and Todd, any objections to this patch?

thanks,

greg k-h

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

* Re: [PATCH v3] android: binder: use VM_ALLOC to get vm area
  2018-01-22 15:54 ` Greg KH
@ 2018-01-22 17:02   ` Todd Kjos
  2018-01-22 18:55     ` Arve Hjønnevåg
  2018-01-25  2:06     ` Ganesh Mahendran
  2018-01-24 14:33   ` Martijn Coenen
  1 sibling, 2 replies; 9+ messages in thread
From: Todd Kjos @ 2018-01-22 17:02 UTC (permalink / raw)
  To: Greg KH; +Cc: Ganesh Mahendran, Martijn Coenen, Arve Hjønnevåg, LKML

On Mon, Jan 22, 2018 at 7:54 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Wed, Jan 10, 2018 at 10:49:05AM +0800, Ganesh Mahendran wrote:
>> 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.
>>
>> And 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 will save some kernel vm area, especially for 32bit os.
>>
>> In 32bit OS, kernel vm area is only 240MB. We may got below
>> error when launching a app:
>>
>> <3>[ 4482.440053] binder_alloc: binder_alloc_mmap_handler: 15728 8ce67000-8cf65000 get_vm_area failed -12
>> <3>[ 4483.218817] binder_alloc: binder_alloc_mmap_handler: 15745 8ce67000-8cf65000 get_vm_area failed -12
>>
>> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
>> ----
>> V3: update comments
>> V2: update comments
>> ---
>>  drivers/android/binder_alloc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Martijn and Todd, any objections to this patch?

Looks fine to me. Arve, do you remember the rationale for using VM_IOREMAP?

>
> thanks,
>
> greg k-h

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

* Re: [PATCH v3] android: binder: use VM_ALLOC to get vm area
  2018-01-22 17:02   ` Todd Kjos
@ 2018-01-22 18:55     ` Arve Hjønnevåg
  2018-01-24  5:24       ` Ganesh Mahendran
  2018-01-25  2:06     ` Ganesh Mahendran
  1 sibling, 1 reply; 9+ messages in thread
From: Arve Hjønnevåg @ 2018-01-22 18:55 UTC (permalink / raw)
  To: Todd Kjos; +Cc: Greg KH, Ganesh Mahendran, Martijn Coenen, LKML

On Mon, Jan 22, 2018 at 9:02 AM, Todd Kjos <tkjos@google.com> wrote:
> On Mon, Jan 22, 2018 at 7:54 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
>> On Wed, Jan 10, 2018 at 10:49:05AM +0800, Ganesh Mahendran wrote:
>>> 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.
>>>
>>> And 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 will save some kernel vm area, especially for 32bit os.
>>>
>>> In 32bit OS, kernel vm area is only 240MB. We may got below
>>> error when launching a app:
>>>
>>> <3>[ 4482.440053] binder_alloc: binder_alloc_mmap_handler: 15728 8ce67000-8cf65000 get_vm_area failed -12
>>> <3>[ 4483.218817] binder_alloc: binder_alloc_mmap_handler: 15745 8ce67000-8cf65000 get_vm_area failed -12
>>>
>>> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
>>> ----
>>> V3: update comments
>>> V2: update comments
>>> ---
>>>  drivers/android/binder_alloc.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> Martijn and Todd, any objections to this patch?
>
> Looks fine to me. Arve, do you remember the rationale for using VM_IOREMAP?
>

I don't remember for sure, but I think it used alloc_vm_area at some
point, and that uses VM_IOREMAP.

-- 
Arve Hjønnevåg

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

* Re: [PATCH v3] android: binder: use VM_ALLOC to get vm area
  2018-01-22 18:55     ` Arve Hjønnevåg
@ 2018-01-24  5:24       ` Ganesh Mahendran
  0 siblings, 0 replies; 9+ messages in thread
From: Ganesh Mahendran @ 2018-01-24  5:24 UTC (permalink / raw)
  To: Arve Hjønnevåg; +Cc: Todd Kjos, Greg KH, Martijn Coenen, LKML

Hi, Arve:

2018-01-23 2:55 GMT+08:00 Arve Hjønnevåg <arve@android.com>:
> On Mon, Jan 22, 2018 at 9:02 AM, Todd Kjos <tkjos@google.com> wrote:
>> On Mon, Jan 22, 2018 at 7:54 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
>>> On Wed, Jan 10, 2018 at 10:49:05AM +0800, Ganesh Mahendran wrote:
>>>> 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.
>>>>
>>>> And 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 will save some kernel vm area, especially for 32bit os.
>>>>
>>>> In 32bit OS, kernel vm area is only 240MB. We may got below
>>>> error when launching a app:
>>>>
>>>> <3>[ 4482.440053] binder_alloc: binder_alloc_mmap_handler: 15728 8ce67000-8cf65000 get_vm_area failed -12
>>>> <3>[ 4483.218817] binder_alloc: binder_alloc_mmap_handler: 15745 8ce67000-8cf65000 get_vm_area failed -12
>>>>
>>>> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
>>>> ----
>>>> V3: update comments
>>>> V2: update comments
>>>> ---
>>>>  drivers/android/binder_alloc.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> Martijn and Todd, any objections to this patch?
>>
>> Looks fine to me. Arve, do you remember the rationale for using VM_IOREMAP?
>>
>
> I don't remember for sure, but I think it used alloc_vm_area at some
> point, and that uses VM_IOREMAP.

Yes, in alloc_vm_area(), it uses VM_IOREMAP flag.

In binder, the ~1MB vm area is cut into binder_buffer which is not
even page aligned.
So for binder IPC, there is no need to align vm area(512KB now).
For 64 bit OS, the vm area is very big, but for 32 bit OS, default vm
area is only 240.
The vm area will soon be exhausted, then no app can be launched.

Thanks.

>
> --
> Arve Hjønnevåg

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

* Re: [PATCH v3] android: binder: use VM_ALLOC to get vm area
  2018-01-22 15:54 ` Greg KH
  2018-01-22 17:02   ` Todd Kjos
@ 2018-01-24 14:33   ` Martijn Coenen
  2018-01-25  2:09     ` Ganesh Mahendran
  1 sibling, 1 reply; 9+ messages in thread
From: Martijn Coenen @ 2018-01-24 14:33 UTC (permalink / raw)
  To: Greg KH; +Cc: Ganesh Mahendran, Todd Kjos, Arve Hjønnevåg, LKML

On Mon, Jan 22, 2018 at 4:54 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> Martijn and Todd, any objections to this patch?

Looks good to me.

>
> thanks,
>
> greg k-h

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

* Re: [PATCH v3] android: binder: use VM_ALLOC to get vm area
  2018-01-22 17:02   ` Todd Kjos
  2018-01-22 18:55     ` Arve Hjønnevåg
@ 2018-01-25  2:06     ` Ganesh Mahendran
  1 sibling, 0 replies; 9+ messages in thread
From: Ganesh Mahendran @ 2018-01-25  2:06 UTC (permalink / raw)
  To: Todd Kjos; +Cc: Greg KH, Martijn Coenen, Arve Hjønnevåg, LKML

Hi, Todd:

2018-01-23 1:02 GMT+08:00 Todd Kjos <tkjos@google.com>:
> On Mon, Jan 22, 2018 at 7:54 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
>> On Wed, Jan 10, 2018 at 10:49:05AM +0800, Ganesh Mahendran wrote:
>>> 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.
>>>
>>> And 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 will save some kernel vm area, especially for 32bit os.
>>>
>>> In 32bit OS, kernel vm area is only 240MB. We may got below
>>> error when launching a app:
>>>
>>> <3>[ 4482.440053] binder_alloc: binder_alloc_mmap_handler: 15728 8ce67000-8cf65000 get_vm_area failed -12
>>> <3>[ 4483.218817] binder_alloc: binder_alloc_mmap_handler: 15745 8ce67000-8cf65000 get_vm_area failed -12
>>>
>>> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
>>> ----
>>> V3: update comments
>>> V2: update comments
>>> ---
>>>  drivers/android/binder_alloc.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> Martijn and Todd, any objections to this patch?
>
> Looks fine to me. Arve, do you remember the rationale for using VM_IOREMAP?

Thanks for your review.

>
>>
>> thanks,
>>
>> greg k-h

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

* Re: [PATCH v3] android: binder: use VM_ALLOC to get vm area
  2018-01-24 14:33   ` Martijn Coenen
@ 2018-01-25  2:09     ` Ganesh Mahendran
  2018-01-25  9:51       ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Ganesh Mahendran @ 2018-01-25  2:09 UTC (permalink / raw)
  To: Martijn Coenen; +Cc: Greg KH, Todd Kjos, Arve Hjønnevåg, LKML

Hi, Martijn

2018-01-24 22:33 GMT+08:00 Martijn Coenen <maco@android.com>:
> On Mon, Jan 22, 2018 at 4:54 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
>> Martijn and Todd, any objections to this patch?
>
> Looks good to me.

Thanks for your review.

Should I cherry-pick this change to aosp kernel 3.10/3.18/4.4/4.9 now?

Thanks.

>
>>
>> thanks,
>>
>> greg k-h

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

* Re: [PATCH v3] android: binder: use VM_ALLOC to get vm area
  2018-01-25  2:09     ` Ganesh Mahendran
@ 2018-01-25  9:51       ` Greg KH
  0 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2018-01-25  9:51 UTC (permalink / raw)
  To: Ganesh Mahendran
  Cc: Martijn Coenen, Todd Kjos, Arve Hjønnevåg, LKML

On Thu, Jan 25, 2018 at 10:09:53AM +0800, Ganesh Mahendran wrote:
> Hi, Martijn
> 
> 2018-01-24 22:33 GMT+08:00 Martijn Coenen <maco@android.com>:
> > On Mon, Jan 22, 2018 at 4:54 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> >> Martijn and Todd, any objections to this patch?
> >
> > Looks good to me.
> 
> Thanks for your review.
> 
> Should I cherry-pick this change to aosp kernel 3.10/3.18/4.4/4.9 now?

If you need it "right now", sure.  Otherwise if you can wait 2 weeks, it
will automatically show up in the 3.18/4.4/4.9/4.14 android-common
branches as part of the stable kernel updates.

It's your choice, but either way to get it into 3.10, you will need to
submit it to AOSP.

thanks,

greg k-h

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

end of thread, other threads:[~2018-01-25  9:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-10  2:49 [PATCH v3] android: binder: use VM_ALLOC to get vm area Ganesh Mahendran
2018-01-22 15:54 ` Greg KH
2018-01-22 17:02   ` Todd Kjos
2018-01-22 18:55     ` Arve Hjønnevåg
2018-01-24  5:24       ` Ganesh Mahendran
2018-01-25  2:06     ` Ganesh Mahendran
2018-01-24 14:33   ` Martijn Coenen
2018-01-25  2:09     ` Ganesh Mahendran
2018-01-25  9:51       ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).