* [PATCH v2] driver : staging : ion: optimization for decreasing memory fragmentaion
@ 2019-03-20 6:38 Zhaoyang Huang
2019-03-27 14:35 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Zhaoyang Huang @ 2019-03-20 6:38 UTC (permalink / raw)
To: open list:ANDROID ION DRIVER, open list:ANDROID ION DRIVER,
moderated list:ANDROID ION DRIVER, linux-kernel
From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
Two action for this patch:
1. set a batch size for system heap's shrinker, which can have it buffer
reasonable page blocks in pool for future allocation.
2. reverse the order sequence when free page blocks, the purpose is also
to have system heap keep as more big blocks as it can.
By testing on an android system with 2G RAM, the changes with setting
batch = 48MB can help reduce the fragmentation obviously and improve
big block allocation speed for 15%.
Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
drivers/staging/android/ion/ion_heap.c | 16 +++++++++++++++-
drivers/staging/android/ion/ion_system_heap.c | 2 +-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c
index 31db510..0c8d696 100644
--- a/drivers/staging/android/ion/ion_heap.c
+++ b/drivers/staging/android/ion/ion_heap.c
@@ -16,6 +16,8 @@
#include <linux/vmalloc.h>
#include "ion.h"
+static unsigned long ion_heap_batch;
+
void *ion_heap_map_kernel(struct ion_heap *heap,
struct ion_buffer *buffer)
{
@@ -303,7 +305,19 @@ int ion_heap_init_shrinker(struct ion_heap *heap)
heap->shrinker.count_objects = ion_heap_shrink_count;
heap->shrinker.scan_objects = ion_heap_shrink_scan;
heap->shrinker.seeks = DEFAULT_SEEKS;
- heap->shrinker.batch = 0;
+ heap->shrinker.batch = ion_heap_batch;
return register_shrinker(&heap->shrinker);
}
+
+/*
+ * configuring ion_heap_batch as 3 times of the pool's peak value can help
+ * improving allocation speed
+ */
+static int __init ion_system_heap_batch_init(char *arg)
+{
+ ion_heap_batch = memparse(arg, NULL);
+
+ return 0;
+}
+early_param("ion_batch", ion_system_heap_batch_init);
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index 701eb9f..d249f8d 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -182,7 +182,7 @@ static int ion_system_heap_shrink(struct ion_heap *heap, gfp_t gfp_mask,
if (!nr_to_scan)
only_scan = 1;
- for (i = 0; i < NUM_ORDERS; i++) {
+ for (i = NUM_ORDERS - 1; i >= 0; i--) {
pool = sys_heap->pools[i];
if (only_scan) {
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] driver : staging : ion: optimization for decreasing memory fragmentaion
2019-03-20 6:38 [PATCH v2] driver : staging : ion: optimization for decreasing memory fragmentaion Zhaoyang Huang
@ 2019-03-27 14:35 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2019-03-27 14:35 UTC (permalink / raw)
To: Zhaoyang Huang
Cc: open list:ANDROID ION DRIVER, open list:ANDROID ION DRIVER,
moderated list:ANDROID ION DRIVER, linux-kernel
On Wed, Mar 20, 2019 at 02:38:23PM +0800, Zhaoyang Huang wrote:
> From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
>
> Two action for this patch:
> 1. set a batch size for system heap's shrinker, which can have it buffer
> reasonable page blocks in pool for future allocation.
> 2. reverse the order sequence when free page blocks, the purpose is also
> to have system heap keep as more big blocks as it can.
>
> By testing on an android system with 2G RAM, the changes with setting
> batch = 48MB can help reduce the fragmentation obviously and improve
> big block allocation speed for 15%.
>
> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> ---
> drivers/staging/android/ion/ion_heap.c | 16 +++++++++++++++-
> drivers/staging/android/ion/ion_system_heap.c | 2 +-
> 2 files changed, 16 insertions(+), 2 deletions(-)
What changed from v1? Always put that below the --- line as the
documentation asks you to.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-27 18:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-20 6:38 [PATCH v2] driver : staging : ion: optimization for decreasing memory fragmentaion Zhaoyang Huang
2019-03-27 14:35 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox