From: Carlos Llamas <cmllamas@google.com>
To: Lei Liu <liulei.rjpt@vivo.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Martijn Coenen" <maco@android.com>,
"Joel Fernandes" <joel@joelfernandes.org>,
"Christian Brauner" <brauner@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
linux-kernel@vger.kernel.org, opensource.kernel@vivo.com
Subject: Re: [PATCH v3] binder_alloc: Replace kcalloc with kvcalloc to mitigate OOM issues
Date: Tue, 18 Jun 2024 04:37:05 +0000 [thread overview]
Message-ID: <ZnEO8X-7pjeTFTur@google.com> (raw)
In-Reply-To: <32e0c2ea-6035-4ec9-b99c-e6b686f04cf3@vivo.com>
On Tue, Jun 18, 2024 at 10:50:17AM +0800, Lei Liu wrote:
>
> On 2024/6/18 2:43, Carlos Llamas wrote:
> > On Mon, Jun 17, 2024 at 12:01:26PM +0800, Lei Liu wrote:
> > > On 6/15/2024 at 2:38, Carlos Llamas wrote:
> > Yes, all this makes sense. What I don't understand is how "performance
> > of kvcalloc is better". This is not supposed to be.
>
> Based on my current understanding:
> 1.kvmalloc may allocate memory faster than kmalloc in cases of memory
> fragmentation, which could potentially improve the performance of binder.
I think there is a misunderstanding of the allocations performed in this
benchmark test. Yes, in general when there is heavy memory pressure it
can be faster to use kvmalloc() and not try too hard to reclaim
contiguous memory.
In the case of binder though, this is the mmap() allocation. This call
is part of the "initial setup". In the test, there should only be two
calls to kvmalloc(), since the benchmark is done across two processes.
That's it.
So the time it takes to allocate this memory is irrelevant to the
performance results. Does this make sense?
> 2.Memory allocated by kvmalloc may not be contiguous, which could
> potentially degrade the data read and write speed of binder.
This _is_ what is being considered in the benchmark test instead. There
are repeated accesses to alloc->pages[n]. Your point is then the reason
why I was expecting "same performance at best".
> Hmm, this is really good news. From the current test results, it seems that
> kvmalloc does not degrade performance for binder.
Yeah, not in the "happy" case anyways. I'm not sure what the numbers
look like under some memory pressure.
> I will retest the data on our phone to see if we reach the same conclusion.
> If kvmalloc still proves to be better, we will provide you with the
> reproduction method.
>
Ok, thanks. I would suggest you do an "adb shell stop" before running
these test. This might help with the noise.
Thanks,
Carlos Llamas
next prev parent reply other threads:[~2024-06-18 4:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-14 4:09 [PATCH v3] binder_alloc: Replace kcalloc with kvcalloc to mitigate OOM issues Lei Liu
2024-06-14 18:38 ` Carlos Llamas
2024-06-17 4:01 ` Lei Liu
2024-06-17 18:43 ` Carlos Llamas
2024-06-18 2:50 ` Lei Liu
2024-06-18 4:37 ` Carlos Llamas [this message]
2024-06-19 8:35 ` Lei Liu
2024-06-19 8:44 ` Lei Liu
2024-06-19 23:41 ` Carlos Llamas
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=ZnEO8X-7pjeTFTur@google.com \
--to=cmllamas@google.com \
--cc=arve@android.com \
--cc=brauner@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liulei.rjpt@vivo.com \
--cc=maco@android.com \
--cc=opensource.kernel@vivo.com \
--cc=surenb@google.com \
--cc=tkjos@android.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox