* [PATCH v2 1/9] staging: ion: tidy up a bit
2014-05-28 6:52 ` [PATCH v2 0/9] staging: ion: system heap and page pool fixes Heesub Shin
@ 2014-05-28 6:52 ` Heesub Shin
2014-05-29 20:42 ` Greg Kroah-Hartman
2014-05-28 6:52 ` [PATCH v2 2/9] staging: ion: simplify ion_page_pool_total() Heesub Shin
` (9 subsequent siblings)
10 siblings, 1 reply; 36+ messages in thread
From: Heesub Shin @ 2014-05-28 6:52 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: John Stultz, Rebecca Schultz Zavin, Colin Cross,
Arve Hjønnevåg, Mitchel Humpherys, Daeseok Youn,
Sunghwan Yun, Dongjun Shin, devel, linux-kernel, Heesub Shin
For aesthetics and readability, rename goto labels, remove
useless code lines, and clarify function return type.
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
---
drivers/staging/android/ion/ion_page_pool.c | 2 +-
drivers/staging/android/ion/ion_priv.h | 2 +-
drivers/staging/android/ion/ion_system_heap.c | 57 ++++++++++++---------------
3 files changed, 28 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c
index ecb5fc3..ead4054 100644
--- a/drivers/staging/android/ion/ion_page_pool.c
+++ b/drivers/staging/android/ion/ion_page_pool.c
@@ -89,7 +89,7 @@ static struct page *ion_page_pool_remove(struct ion_page_pool *pool, bool high)
return page;
}
-void *ion_page_pool_alloc(struct ion_page_pool *pool)
+struct page *ion_page_pool_alloc(struct ion_page_pool *pool)
{
struct page *page = NULL;
diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h
index 1eba3f2..365c947 100644
--- a/drivers/staging/android/ion/ion_priv.h
+++ b/drivers/staging/android/ion/ion_priv.h
@@ -377,7 +377,7 @@ struct ion_page_pool {
struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order);
void ion_page_pool_destroy(struct ion_page_pool *);
-void *ion_page_pool_alloc(struct ion_page_pool *);
+struct page *ion_page_pool_alloc(struct ion_page_pool *);
void ion_page_pool_free(struct ion_page_pool *, struct page *);
/** ion_page_pool_shrink - shrinks the size of the memory cached in the pool
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index c923633..b554751 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -41,7 +41,7 @@ static int order_to_index(unsigned int order)
return -1;
}
-static unsigned int order_to_size(int order)
+static inline unsigned int order_to_size(int order)
{
return PAGE_SIZE << order;
}
@@ -78,8 +78,6 @@ static struct page *alloc_buffer_page(struct ion_system_heap *heap,
ion_pages_sync_for_device(NULL, page, PAGE_SIZE << order,
DMA_BIDIRECTIONAL);
}
- if (!page)
- return NULL;
return page;
}
@@ -124,7 +122,6 @@ static struct page_info *alloc_largest_available(struct ion_system_heap *heap,
info->page = page;
info->order = orders[i];
- INIT_LIST_HEAD(&info->list);
return info;
}
kfree(info);
@@ -142,7 +139,6 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
heap);
struct sg_table *table;
struct scatterlist *sg;
- int ret;
struct list_head pages;
struct page_info *info, *tmp_info;
int i = 0;
@@ -160,24 +156,23 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
info = alloc_largest_available(sys_heap, buffer, size_remaining,
max_order);
if (!info)
- goto err;
+ goto free_pages;
list_add_tail(&info->list, &pages);
- size_remaining -= (1 << info->order) * PAGE_SIZE;
+ size_remaining -= PAGE_SIZE << info->order;
max_order = info->order;
i++;
}
table = kzalloc(sizeof(struct sg_table), GFP_KERNEL);
if (!table)
- goto err;
+ goto free_pages;
- ret = sg_alloc_table(table, i, GFP_KERNEL);
- if (ret)
- goto err1;
+ if (sg_alloc_table(table, i, GFP_KERNEL))
+ goto free_table;
sg = table->sgl;
list_for_each_entry_safe(info, tmp_info, &pages, list) {
struct page *page = info->page;
- sg_set_page(sg, page, (1 << info->order) * PAGE_SIZE, 0);
+ sg_set_page(sg, page, PAGE_SIZE << info->order, 0);
sg = sg_next(sg);
list_del(&info->list);
kfree(info);
@@ -185,9 +180,10 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
buffer->priv_virt = table;
return 0;
-err1:
+
+free_table:
kfree(table);
-err:
+free_pages:
list_for_each_entry_safe(info, tmp_info, &pages, list) {
free_buffer_page(sys_heap, buffer, info->page, info->order);
kfree(info);
@@ -197,14 +193,12 @@ err:
static void ion_system_heap_free(struct ion_buffer *buffer)
{
- struct ion_heap *heap = buffer->heap;
- struct ion_system_heap *sys_heap = container_of(heap,
+ struct ion_system_heap *sys_heap = container_of(buffer->heap,
struct ion_system_heap,
heap);
struct sg_table *table = buffer->sg_table;
bool cached = ion_buffer_cached(buffer);
struct scatterlist *sg;
- LIST_HEAD(pages);
int i;
/* uncached pages come from the page pools, zero them before returning
@@ -271,10 +265,10 @@ static int ion_system_heap_debug_show(struct ion_heap *heap, struct seq_file *s,
struct ion_page_pool *pool = sys_heap->pools[i];
seq_printf(s, "%d order %u highmem pages in pool = %lu total\n",
pool->high_count, pool->order,
- (1 << pool->order) * PAGE_SIZE * pool->high_count);
+ (PAGE_SIZE << pool->order) * pool->high_count);
seq_printf(s, "%d order %u lowmem pages in pool = %lu total\n",
pool->low_count, pool->order,
- (1 << pool->order) * PAGE_SIZE * pool->low_count);
+ (PAGE_SIZE << pool->order) * pool->low_count);
}
return 0;
}
@@ -293,7 +287,7 @@ struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused)
heap->pools = kzalloc(sizeof(struct ion_page_pool *) * num_orders,
GFP_KERNEL);
if (!heap->pools)
- goto err_alloc_pools;
+ goto free_heap;
for (i = 0; i < num_orders; i++) {
struct ion_page_pool *pool;
gfp_t gfp_flags = low_order_gfp_flags;
@@ -302,18 +296,18 @@ struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused)
gfp_flags = high_order_gfp_flags;
pool = ion_page_pool_create(gfp_flags, orders[i]);
if (!pool)
- goto err_create_pool;
+ goto destroy_pools;
heap->pools[i] = pool;
}
heap->heap.debug_show = ion_system_heap_debug_show;
return &heap->heap;
-err_create_pool:
- for (i = 0; i < num_orders; i++)
- if (heap->pools[i])
- ion_page_pool_destroy(heap->pools[i]);
+
+destroy_pools:
+ while (i--)
+ ion_page_pool_destroy(heap->pools[i]);
kfree(heap->pools);
-err_alloc_pools:
+free_heap:
kfree(heap);
return ERR_PTR(-ENOMEM);
}
@@ -359,12 +353,12 @@ static int ion_system_contig_heap_allocate(struct ion_heap *heap,
table = kzalloc(sizeof(struct sg_table), GFP_KERNEL);
if (!table) {
ret = -ENOMEM;
- goto out;
+ goto free_pages;
}
ret = sg_alloc_table(table, 1, GFP_KERNEL);
if (ret)
- goto out;
+ goto free_table;
sg_set_page(table->sgl, page, len, 0);
@@ -374,10 +368,12 @@ static int ion_system_contig_heap_allocate(struct ion_heap *heap,
return 0;
-out:
+free_table:
+ kfree(table);
+free_pages:
for (i = 0; i < len >> PAGE_SHIFT; i++)
__free_page(page + i);
- kfree(table);
+
return ret;
}
@@ -443,4 +439,3 @@ void ion_system_contig_heap_destroy(struct ion_heap *heap)
{
kfree(heap);
}
-
--
1.9.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH v2 1/9] staging: ion: tidy up a bit
2014-05-28 6:52 ` [PATCH v2 1/9] staging: ion: tidy up a bit Heesub Shin
@ 2014-05-29 20:42 ` Greg Kroah-Hartman
2014-05-30 1:22 ` Heesub Shin
2014-05-30 1:26 ` [PATCH v2 RESEND 1/4] staging: ion: remove order from struct page_info Heesub Shin
0 siblings, 2 replies; 36+ messages in thread
From: Greg Kroah-Hartman @ 2014-05-29 20:42 UTC (permalink / raw)
To: Heesub Shin
Cc: devel, Sunghwan Yun, Daeseok Youn, linux-kernel,
Arve Hjønnevåg, Dongjun Shin, John Stultz, Colin Cross,
Rebecca Schultz Zavin
On Wed, May 28, 2014 at 03:52:52PM +0900, Heesub Shin wrote:
> For aesthetics and readability, rename goto labels, remove
> useless code lines, and clarify function return type.
>
> Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
> Reviewed-by: Mitchel Humpherys <mitchelh@codeaurora.org>
> Tested-by: John Stultz <john.stultz@linaro.org>
Not all of these would apply to my tree. So I've applied the ones that
did. Please resend the remaining ones, after refreshing them against my
staging-next branch of the staging.git tree.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 1/9] staging: ion: tidy up a bit
2014-05-29 20:42 ` Greg Kroah-Hartman
@ 2014-05-30 1:22 ` Heesub Shin
2014-05-30 1:26 ` [PATCH v2 RESEND 1/4] staging: ion: remove order from struct page_info Heesub Shin
1 sibling, 0 replies; 36+ messages in thread
From: Heesub Shin @ 2014-05-30 1:22 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: devel, Sunghwan Yun, Daeseok Youn, linux-kernel,
Arve Hjønnevåg, Dongjun Shin, John Stultz, Colin Cross,
Rebecca Schultz Zavin
On 05/30/2014 05:42 AM, Greg Kroah-Hartman wrote:
> On Wed, May 28, 2014 at 03:52:52PM +0900, Heesub Shin wrote:
>> For aesthetics and readability, rename goto labels, remove
>> useless code lines, and clarify function return type.
>>
>> Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
>> Reviewed-by: Mitchel Humpherys <mitchelh@codeaurora.org>
>> Tested-by: John Stultz <john.stultz@linaro.org>
>
> Not all of these would apply to my tree. So I've applied the ones that
> did. Please resend the remaining ones, after refreshing them against my
> staging-next branch of the staging.git tree.
Hi KH,
I will rebase them on staging-next and resend soon.
Thanks a lot!
regads,
heesub
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 RESEND 1/4] staging: ion: remove order from struct page_info
2014-05-29 20:42 ` Greg Kroah-Hartman
2014-05-30 1:22 ` Heesub Shin
@ 2014-05-30 1:26 ` Heesub Shin
2014-05-30 1:26 ` [PATCH v2 RESEND 2/4] staging: ion: remove " Heesub Shin
` (2 more replies)
1 sibling, 3 replies; 36+ messages in thread
From: Heesub Shin @ 2014-05-30 1:26 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: John Stultz, Rebecca Schultz Zavin, Colin Cross,
Arve Hjønnevåg, Mitchel Humpherys, Daeseok Youn,
Sunghwan Yun, Dongjun Shin, devel, linux-kernel, Heesub Shin
ION system heap uses an internal data structure, struct page_info, for
tracking down the meta information of the pages allocated from the pool.
Now that the pool returns compound pages, we don't need to store page
order in struct page_info.
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
Reviewed-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Tested-by: John Stultz <john.stultz@linaro.org>
---
drivers/staging/android/ion/ion_system_heap.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index cb7ae08..621b857 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -54,7 +54,6 @@ struct ion_system_heap {
struct page_info {
struct page *page;
- unsigned int order;
struct list_head list;
};
@@ -123,7 +122,6 @@ static struct page_info *alloc_largest_available(struct ion_system_heap *heap,
continue;
info->page = page;
- info->order = orders[i];
return info;
}
kfree(info);
@@ -160,8 +158,8 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
if (!info)
goto free_pages;
list_add_tail(&info->list, &pages);
- size_remaining -= PAGE_SIZE << info->order;
- max_order = info->order;
+ size_remaining -= PAGE_SIZE << compound_order(info->page);
+ max_order = compound_order(info->page);
i++;
}
table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
@@ -174,7 +172,7 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
sg = table->sgl;
list_for_each_entry_safe(info, tmp_info, &pages, list) {
struct page *page = info->page;
- sg_set_page(sg, page, PAGE_SIZE << info->order, 0);
+ sg_set_page(sg, page, PAGE_SIZE << compound_order(page), 0);
sg = sg_next(sg);
list_del(&info->list);
kfree(info);
@@ -187,7 +185,8 @@ free_table:
kfree(table);
free_pages:
list_for_each_entry_safe(info, tmp_info, &pages, list) {
- free_buffer_page(sys_heap, buffer, info->page, info->order);
+ free_buffer_page(sys_heap, buffer, info->page,
+ compound_order(info->page));
kfree(info);
}
return -ENOMEM;
--
1.9.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v2 RESEND 2/4] staging: ion: remove struct page_info
2014-05-30 1:26 ` [PATCH v2 RESEND 1/4] staging: ion: remove order from struct page_info Heesub Shin
@ 2014-05-30 1:26 ` Heesub Shin
2014-05-30 1:26 ` [PATCH v2 RESEND 3/4] staging: ion: remove order argument from free_buffer_page() Heesub Shin
2014-05-30 1:26 ` [PATCH v2 RESEND 4/4] staging: ion: optimize struct ion_system_heap Heesub Shin
2 siblings, 0 replies; 36+ messages in thread
From: Heesub Shin @ 2014-05-30 1:26 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: John Stultz, Rebecca Schultz Zavin, Colin Cross,
Arve Hjønnevåg, Mitchel Humpherys, Daeseok Youn,
Sunghwan Yun, Dongjun Shin, devel, linux-kernel, Heesub Shin
ION system heap creates a temporary list of pages to build
scatter/gather table, introducing an internal data type, page_info. Now
that the order field has been removed from it, we do not need to depend
on such data type anymore.
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
Reviewed-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Tested-by: John Stultz <john.stultz@linaro.org>
---
drivers/staging/android/ion/ion_system_heap.c | 47 +++++++++------------------
1 file changed, 15 insertions(+), 32 deletions(-)
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index 621b857..f3b9008 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -52,11 +52,6 @@ struct ion_system_heap {
struct ion_page_pool **pools;
};
-struct page_info {
- struct page *page;
- struct list_head list;
-};
-
static struct page *alloc_buffer_page(struct ion_system_heap *heap,
struct ion_buffer *buffer,
unsigned long order)
@@ -98,19 +93,14 @@ static void free_buffer_page(struct ion_system_heap *heap,
}
-static struct page_info *alloc_largest_available(struct ion_system_heap *heap,
- struct ion_buffer *buffer,
- unsigned long size,
- unsigned int max_order)
+static struct page *alloc_largest_available(struct ion_system_heap *heap,
+ struct ion_buffer *buffer,
+ unsigned long size,
+ unsigned int max_order)
{
struct page *page;
- struct page_info *info;
int i;
- info = kmalloc(sizeof(struct page_info), GFP_KERNEL);
- if (!info)
- return NULL;
-
for (i = 0; i < num_orders; i++) {
if (size < order_to_size(orders[i]))
continue;
@@ -121,10 +111,8 @@ static struct page_info *alloc_largest_available(struct ion_system_heap *heap,
if (!page)
continue;
- info->page = page;
- return info;
+ return page;
}
- kfree(info);
return NULL;
}
@@ -140,7 +128,7 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
struct sg_table *table;
struct scatterlist *sg;
struct list_head pages;
- struct page_info *info, *tmp_info;
+ struct page *page, *tmp_page;
int i = 0;
unsigned long size_remaining = PAGE_ALIGN(size);
unsigned int max_order = orders[0];
@@ -153,13 +141,13 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
INIT_LIST_HEAD(&pages);
while (size_remaining > 0) {
- info = alloc_largest_available(sys_heap, buffer, size_remaining,
+ page = alloc_largest_available(sys_heap, buffer, size_remaining,
max_order);
- if (!info)
+ if (!page)
goto free_pages;
- list_add_tail(&info->list, &pages);
- size_remaining -= PAGE_SIZE << compound_order(info->page);
- max_order = compound_order(info->page);
+ list_add_tail(&page->lru, &pages);
+ size_remaining -= PAGE_SIZE << compound_order(page);
+ max_order = compound_order(page);
i++;
}
table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
@@ -170,12 +158,10 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
goto free_table;
sg = table->sgl;
- list_for_each_entry_safe(info, tmp_info, &pages, list) {
- struct page *page = info->page;
+ list_for_each_entry_safe(page, tmp_page, &pages, lru) {
sg_set_page(sg, page, PAGE_SIZE << compound_order(page), 0);
sg = sg_next(sg);
- list_del(&info->list);
- kfree(info);
+ list_del(&page->lru);
}
buffer->priv_virt = table;
@@ -184,11 +170,8 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
free_table:
kfree(table);
free_pages:
- list_for_each_entry_safe(info, tmp_info, &pages, list) {
- free_buffer_page(sys_heap, buffer, info->page,
- compound_order(info->page));
- kfree(info);
- }
+ list_for_each_entry_safe(page, tmp_page, &pages, lru)
+ free_buffer_page(sys_heap, buffer, page, compound_order(page));
return -ENOMEM;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v2 RESEND 3/4] staging: ion: remove order argument from free_buffer_page()
2014-05-30 1:26 ` [PATCH v2 RESEND 1/4] staging: ion: remove order from struct page_info Heesub Shin
2014-05-30 1:26 ` [PATCH v2 RESEND 2/4] staging: ion: remove " Heesub Shin
@ 2014-05-30 1:26 ` Heesub Shin
2014-05-30 1:26 ` [PATCH v2 RESEND 4/4] staging: ion: optimize struct ion_system_heap Heesub Shin
2 siblings, 0 replies; 36+ messages in thread
From: Heesub Shin @ 2014-05-30 1:26 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: John Stultz, Rebecca Schultz Zavin, Colin Cross,
Arve Hjønnevåg, Mitchel Humpherys, Daeseok Youn,
Sunghwan Yun, Dongjun Shin, devel, linux-kernel, Heesub Shin
Now that the pages returned from the pool are compound pages, we do not
need to pass the order information to free_buffer_page().
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
Reviewed-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Tested-by: John Stultz <john.stultz@linaro.org>
---
drivers/staging/android/ion/ion_system_heap.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index f3b9008..e0a7e54 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -78,9 +78,9 @@ static struct page *alloc_buffer_page(struct ion_system_heap *heap,
}
static void free_buffer_page(struct ion_system_heap *heap,
- struct ion_buffer *buffer, struct page *page,
- unsigned int order)
+ struct ion_buffer *buffer, struct page *page)
{
+ unsigned int order = compound_order(page);
bool cached = ion_buffer_cached(buffer);
if (!cached && !(buffer->private_flags & ION_PRIV_FLAG_SHRINKER_FREE)) {
@@ -171,7 +171,7 @@ free_table:
kfree(table);
free_pages:
list_for_each_entry_safe(page, tmp_page, &pages, lru)
- free_buffer_page(sys_heap, buffer, page, compound_order(page));
+ free_buffer_page(sys_heap, buffer, page);
return -ENOMEM;
}
@@ -191,8 +191,7 @@ static void ion_system_heap_free(struct ion_buffer *buffer)
ion_heap_buffer_zero(buffer);
for_each_sg(table->sgl, sg, table->nents, i)
- free_buffer_page(sys_heap, buffer, sg_page(sg),
- get_order(sg->length));
+ free_buffer_page(sys_heap, buffer, sg_page(sg));
sg_free_table(table);
kfree(table);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v2 RESEND 4/4] staging: ion: optimize struct ion_system_heap
2014-05-30 1:26 ` [PATCH v2 RESEND 1/4] staging: ion: remove order from struct page_info Heesub Shin
2014-05-30 1:26 ` [PATCH v2 RESEND 2/4] staging: ion: remove " Heesub Shin
2014-05-30 1:26 ` [PATCH v2 RESEND 3/4] staging: ion: remove order argument from free_buffer_page() Heesub Shin
@ 2014-05-30 1:26 ` Heesub Shin
2 siblings, 0 replies; 36+ messages in thread
From: Heesub Shin @ 2014-05-30 1:26 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: John Stultz, Rebecca Schultz Zavin, Colin Cross,
Arve Hjønnevåg, Mitchel Humpherys, Daeseok Youn,
Sunghwan Yun, Dongjun Shin, devel, linux-kernel, Heesub Shin
struct ion_system_heap has an array for storing pointers to page pools
and it is allocated separately from the containing structure. There is
no point in allocating those two small objects individually, bothering
slab allocator. Using a variable length array simplifies code lines and
reduces overhead to the slab.
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
Reviewed-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Tested-by: John Stultz <john.stultz@linaro.org>
---
drivers/staging/android/ion/ion_system_heap.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index e0a7e54..c826b4c 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -49,7 +49,7 @@ static inline unsigned int order_to_size(int order)
struct ion_system_heap {
struct ion_heap heap;
- struct ion_page_pool **pools;
+ struct ion_page_pool *pools[0];
};
static struct page *alloc_buffer_page(struct ion_system_heap *heap,
@@ -264,16 +264,15 @@ struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused)
struct ion_system_heap *heap;
int i;
- heap = kzalloc(sizeof(struct ion_system_heap), GFP_KERNEL);
+ heap = kzalloc(sizeof(struct ion_system_heap) +
+ sizeof(struct ion_page_pool *) * num_orders,
+ GFP_KERNEL);
if (!heap)
return ERR_PTR(-ENOMEM);
heap->heap.ops = &system_heap_ops;
heap->heap.type = ION_HEAP_TYPE_SYSTEM;
heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE;
- heap->pools = kzalloc(sizeof(struct ion_page_pool *) * num_orders,
- GFP_KERNEL);
- if (!heap->pools)
- goto free_heap;
+
for (i = 0; i < num_orders; i++) {
struct ion_page_pool *pool;
gfp_t gfp_flags = low_order_gfp_flags;
@@ -292,8 +291,6 @@ struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused)
destroy_pools:
while (i--)
ion_page_pool_destroy(heap->pools[i]);
- kfree(heap->pools);
-free_heap:
kfree(heap);
return ERR_PTR(-ENOMEM);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 2/9] staging: ion: simplify ion_page_pool_total()
2014-05-28 6:52 ` [PATCH v2 0/9] staging: ion: system heap and page pool fixes Heesub Shin
2014-05-28 6:52 ` [PATCH v2 1/9] staging: ion: tidy up a bit Heesub Shin
@ 2014-05-28 6:52 ` Heesub Shin
2014-05-28 6:52 ` [PATCH v2 3/9] staging: ion: remove struct ion_page_pool_item Heesub Shin
` (8 subsequent siblings)
10 siblings, 0 replies; 36+ messages in thread
From: Heesub Shin @ 2014-05-28 6:52 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: John Stultz, Rebecca Schultz Zavin, Colin Cross,
Arve Hjønnevåg, Mitchel Humpherys, Daeseok Youn,
Sunghwan Yun, Dongjun Shin, devel, linux-kernel, Heesub Shin
ion_page_pool_total() returns the total number of pages in the pool.
Depending on the argument passed, it counts highmem pages in or not.
This commit simplifies the code lines for better readability.
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
---
drivers/staging/android/ion/ion_page_pool.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c
index ead4054..1684780 100644
--- a/drivers/staging/android/ion/ion_page_pool.c
+++ b/drivers/staging/android/ion/ion_page_pool.c
@@ -119,12 +119,12 @@ void ion_page_pool_free(struct ion_page_pool *pool, struct page *page)
static int ion_page_pool_total(struct ion_page_pool *pool, bool high)
{
- int total = 0;
+ int count = pool->low_count;
- total += high ? (pool->high_count + pool->low_count) *
- (1 << pool->order) :
- pool->low_count * (1 << pool->order);
- return total;
+ if (high)
+ count += pool->high_count;
+
+ return count << pool->order;
}
int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask,
--
1.9.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v2 3/9] staging: ion: remove struct ion_page_pool_item
2014-05-28 6:52 ` [PATCH v2 0/9] staging: ion: system heap and page pool fixes Heesub Shin
2014-05-28 6:52 ` [PATCH v2 1/9] staging: ion: tidy up a bit Heesub Shin
2014-05-28 6:52 ` [PATCH v2 2/9] staging: ion: simplify ion_page_pool_total() Heesub Shin
@ 2014-05-28 6:52 ` Heesub Shin
2014-05-28 6:52 ` [PATCH v2 4/9] staging: ion: use compound pages on high order pages for system heap Heesub Shin
` (7 subsequent siblings)
10 siblings, 0 replies; 36+ messages in thread
From: Heesub Shin @ 2014-05-28 6:52 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: John Stultz, Rebecca Schultz Zavin, Colin Cross,
Arve Hjønnevåg, Mitchel Humpherys, Daeseok Youn,
Sunghwan Yun, Dongjun Shin, devel, linux-kernel, Heesub Shin
The page pool uses an internal data structure, ion_page_pool_item, for
wrapping pooled pages and constructing a list. As the struct page
already provides ways for doing exactly the same thing, we do not need
to reinvent the wheel. This commit removes the data structure and slab
allocations for it.
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
---
drivers/staging/android/ion/ion_page_pool.c | 27 +++++----------------------
1 file changed, 5 insertions(+), 22 deletions(-)
diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c
index 1684780..111777c 100644
--- a/drivers/staging/android/ion/ion_page_pool.c
+++ b/drivers/staging/android/ion/ion_page_pool.c
@@ -23,11 +23,6 @@
#include <linux/slab.h>
#include "ion_priv.h"
-struct ion_page_pool_item {
- struct page *page;
- struct list_head list;
-};
-
static void *ion_page_pool_alloc_pages(struct ion_page_pool *pool)
{
struct page *page = alloc_pages(pool->gfp_mask, pool->order);
@@ -47,19 +42,12 @@ static void ion_page_pool_free_pages(struct ion_page_pool *pool,
static int ion_page_pool_add(struct ion_page_pool *pool, struct page *page)
{
- struct ion_page_pool_item *item;
-
- item = kmalloc(sizeof(struct ion_page_pool_item), GFP_KERNEL);
- if (!item)
- return -ENOMEM;
-
mutex_lock(&pool->mutex);
- item->page = page;
if (PageHighMem(page)) {
- list_add_tail(&item->list, &pool->high_items);
+ list_add_tail(&page->lru, &pool->high_items);
pool->high_count++;
} else {
- list_add_tail(&item->list, &pool->low_items);
+ list_add_tail(&page->lru, &pool->low_items);
pool->low_count++;
}
mutex_unlock(&pool->mutex);
@@ -68,24 +56,19 @@ static int ion_page_pool_add(struct ion_page_pool *pool, struct page *page)
static struct page *ion_page_pool_remove(struct ion_page_pool *pool, bool high)
{
- struct ion_page_pool_item *item;
struct page *page;
if (high) {
BUG_ON(!pool->high_count);
- item = list_first_entry(&pool->high_items,
- struct ion_page_pool_item, list);
+ page = list_first_entry(&pool->high_items, struct page, lru);
pool->high_count--;
} else {
BUG_ON(!pool->low_count);
- item = list_first_entry(&pool->low_items,
- struct ion_page_pool_item, list);
+ page = list_first_entry(&pool->low_items, struct page, lru);
pool->low_count--;
}
- list_del(&item->list);
- page = item->page;
- kfree(item);
+ list_del(&page->lru);
return page;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v2 4/9] staging: ion: use compound pages on high order pages for system heap
2014-05-28 6:52 ` [PATCH v2 0/9] staging: ion: system heap and page pool fixes Heesub Shin
` (2 preceding siblings ...)
2014-05-28 6:52 ` [PATCH v2 3/9] staging: ion: remove struct ion_page_pool_item Heesub Shin
@ 2014-05-28 6:52 ` Heesub Shin
2014-05-28 6:52 ` [PATCH v2 5/9] staging: ion: remove order from struct page_info Heesub Shin
` (6 subsequent siblings)
10 siblings, 0 replies; 36+ messages in thread
From: Heesub Shin @ 2014-05-28 6:52 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: John Stultz, Rebecca Schultz Zavin, Colin Cross,
Arve Hjønnevåg, Mitchel Humpherys, Daeseok Youn,
Sunghwan Yun, Dongjun Shin, devel, linux-kernel, Heesub Shin
Using compound pages relieves burden on tracking the meta information
which are currently stored in page_info.
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
---
drivers/staging/android/ion/ion_page_pool.c | 4 +++-
drivers/staging/android/ion/ion_system_heap.c | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c
index 111777c..c1cea42b 100644
--- a/drivers/staging/android/ion/ion_page_pool.c
+++ b/drivers/staging/android/ion/ion_page_pool.c
@@ -95,6 +95,8 @@ void ion_page_pool_free(struct ion_page_pool *pool, struct page *page)
{
int ret;
+ BUG_ON(pool->order != compound_order(page));
+
ret = ion_page_pool_add(pool, page);
if (ret)
ion_page_pool_free_pages(pool, page);
@@ -150,7 +152,7 @@ struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order)
pool->low_count = 0;
INIT_LIST_HEAD(&pool->low_items);
INIT_LIST_HEAD(&pool->high_items);
- pool->gfp_mask = gfp_mask;
+ pool->gfp_mask = gfp_mask | __GFP_COMP;
pool->order = order;
mutex_init(&pool->mutex);
plist_node_init(&pool->list, order);
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index b554751..48e6a58 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -72,7 +72,7 @@ static struct page *alloc_buffer_page(struct ion_system_heap *heap,
if (order > 4)
gfp_flags = high_order_gfp_flags;
- page = alloc_pages(gfp_flags, order);
+ page = alloc_pages(gfp_flags | __GFP_COMP, order);
if (!page)
return NULL;
ion_pages_sync_for_device(NULL, page, PAGE_SIZE << order,
--
1.9.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v2 5/9] staging: ion: remove order from struct page_info
2014-05-28 6:52 ` [PATCH v2 0/9] staging: ion: system heap and page pool fixes Heesub Shin
` (3 preceding siblings ...)
2014-05-28 6:52 ` [PATCH v2 4/9] staging: ion: use compound pages on high order pages for system heap Heesub Shin
@ 2014-05-28 6:52 ` Heesub Shin
2014-05-28 6:52 ` [PATCH v2 6/9] staging: ion: remove " Heesub Shin
` (5 subsequent siblings)
10 siblings, 0 replies; 36+ messages in thread
From: Heesub Shin @ 2014-05-28 6:52 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: John Stultz, Rebecca Schultz Zavin, Colin Cross,
Arve Hjønnevåg, Mitchel Humpherys, Daeseok Youn,
Sunghwan Yun, Dongjun Shin, devel, linux-kernel, Heesub Shin
ION system heap uses an internal data structure, struct page_info, for
tracking down the meta information of the pages allocated from the pool.
Now that the pool returns compound pages, we don't need to store page
order in struct page_info.
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
---
drivers/staging/android/ion/ion_system_heap.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index 48e6a58..73a2e67 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -53,7 +53,6 @@ struct ion_system_heap {
struct page_info {
struct page *page;
- unsigned int order;
struct list_head list;
};
@@ -121,7 +120,6 @@ static struct page_info *alloc_largest_available(struct ion_system_heap *heap,
continue;
info->page = page;
- info->order = orders[i];
return info;
}
kfree(info);
@@ -158,8 +156,8 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
if (!info)
goto free_pages;
list_add_tail(&info->list, &pages);
- size_remaining -= PAGE_SIZE << info->order;
- max_order = info->order;
+ size_remaining -= PAGE_SIZE << compound_order(info->page);
+ max_order = compound_order(info->page);
i++;
}
table = kzalloc(sizeof(struct sg_table), GFP_KERNEL);
@@ -172,7 +170,7 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
sg = table->sgl;
list_for_each_entry_safe(info, tmp_info, &pages, list) {
struct page *page = info->page;
- sg_set_page(sg, page, PAGE_SIZE << info->order, 0);
+ sg_set_page(sg, page, PAGE_SIZE << compound_order(page), 0);
sg = sg_next(sg);
list_del(&info->list);
kfree(info);
@@ -185,7 +183,8 @@ free_table:
kfree(table);
free_pages:
list_for_each_entry_safe(info, tmp_info, &pages, list) {
- free_buffer_page(sys_heap, buffer, info->page, info->order);
+ free_buffer_page(sys_heap, buffer, info->page,
+ compound_order(info->page));
kfree(info);
}
return -ENOMEM;
--
1.9.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v2 6/9] staging: ion: remove struct page_info
2014-05-28 6:52 ` [PATCH v2 0/9] staging: ion: system heap and page pool fixes Heesub Shin
` (4 preceding siblings ...)
2014-05-28 6:52 ` [PATCH v2 5/9] staging: ion: remove order from struct page_info Heesub Shin
@ 2014-05-28 6:52 ` Heesub Shin
2014-05-28 6:52 ` [PATCH v2 7/9] staging: ion: remove order argument from free_buffer_page() Heesub Shin
` (4 subsequent siblings)
10 siblings, 0 replies; 36+ messages in thread
From: Heesub Shin @ 2014-05-28 6:52 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: John Stultz, Rebecca Schultz Zavin, Colin Cross,
Arve Hjønnevåg, Mitchel Humpherys, Daeseok Youn,
Sunghwan Yun, Dongjun Shin, devel, linux-kernel, Heesub Shin
ION system heap creates a temporary list of pages to build
scatter/gather table, introducing an internal data type, page_info. Now
that the order field has been removed from it, we do not need to depend
on such data type anymore.
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
---
drivers/staging/android/ion/ion_system_heap.c | 47 +++++++++------------------
1 file changed, 15 insertions(+), 32 deletions(-)
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index 73a2e67..f0ae210 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -51,11 +51,6 @@ struct ion_system_heap {
struct ion_page_pool **pools;
};
-struct page_info {
- struct page *page;
- struct list_head list;
-};
-
static struct page *alloc_buffer_page(struct ion_system_heap *heap,
struct ion_buffer *buffer,
unsigned long order)
@@ -96,19 +91,14 @@ static void free_buffer_page(struct ion_system_heap *heap,
}
-static struct page_info *alloc_largest_available(struct ion_system_heap *heap,
- struct ion_buffer *buffer,
- unsigned long size,
- unsigned int max_order)
+static struct page *alloc_largest_available(struct ion_system_heap *heap,
+ struct ion_buffer *buffer,
+ unsigned long size,
+ unsigned int max_order)
{
struct page *page;
- struct page_info *info;
int i;
- info = kmalloc(sizeof(struct page_info), GFP_KERNEL);
- if (!info)
- return NULL;
-
for (i = 0; i < num_orders; i++) {
if (size < order_to_size(orders[i]))
continue;
@@ -119,10 +109,8 @@ static struct page_info *alloc_largest_available(struct ion_system_heap *heap,
if (!page)
continue;
- info->page = page;
- return info;
+ return page;
}
- kfree(info);
return NULL;
}
@@ -138,7 +126,7 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
struct sg_table *table;
struct scatterlist *sg;
struct list_head pages;
- struct page_info *info, *tmp_info;
+ struct page *page, *tmp_page;
int i = 0;
unsigned long size_remaining = PAGE_ALIGN(size);
unsigned int max_order = orders[0];
@@ -151,13 +139,13 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
INIT_LIST_HEAD(&pages);
while (size_remaining > 0) {
- info = alloc_largest_available(sys_heap, buffer, size_remaining,
+ page = alloc_largest_available(sys_heap, buffer, size_remaining,
max_order);
- if (!info)
+ if (!page)
goto free_pages;
- list_add_tail(&info->list, &pages);
- size_remaining -= PAGE_SIZE << compound_order(info->page);
- max_order = compound_order(info->page);
+ list_add_tail(&page->lru, &pages);
+ size_remaining -= PAGE_SIZE << compound_order(page);
+ max_order = compound_order(page);
i++;
}
table = kzalloc(sizeof(struct sg_table), GFP_KERNEL);
@@ -168,12 +156,10 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
goto free_table;
sg = table->sgl;
- list_for_each_entry_safe(info, tmp_info, &pages, list) {
- struct page *page = info->page;
+ list_for_each_entry_safe(page, tmp_page, &pages, lru) {
sg_set_page(sg, page, PAGE_SIZE << compound_order(page), 0);
sg = sg_next(sg);
- list_del(&info->list);
- kfree(info);
+ list_del(&page->lru);
}
buffer->priv_virt = table;
@@ -182,11 +168,8 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
free_table:
kfree(table);
free_pages:
- list_for_each_entry_safe(info, tmp_info, &pages, list) {
- free_buffer_page(sys_heap, buffer, info->page,
- compound_order(info->page));
- kfree(info);
- }
+ list_for_each_entry_safe(page, tmp_page, &pages, lru)
+ free_buffer_page(sys_heap, buffer, page, compound_order(page));
return -ENOMEM;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v2 7/9] staging: ion: remove order argument from free_buffer_page()
2014-05-28 6:52 ` [PATCH v2 0/9] staging: ion: system heap and page pool fixes Heesub Shin
` (5 preceding siblings ...)
2014-05-28 6:52 ` [PATCH v2 6/9] staging: ion: remove " Heesub Shin
@ 2014-05-28 6:52 ` Heesub Shin
2014-05-28 6:52 ` [PATCH v2 8/9] staging: ion: shrink highmem pages on kswapd Heesub Shin
` (3 subsequent siblings)
10 siblings, 0 replies; 36+ messages in thread
From: Heesub Shin @ 2014-05-28 6:52 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: John Stultz, Rebecca Schultz Zavin, Colin Cross,
Arve Hjønnevåg, Mitchel Humpherys, Daeseok Youn,
Sunghwan Yun, Dongjun Shin, devel, linux-kernel, Heesub Shin
Now that the pages returned from the pool are compound pages, we do not
need to pass the order information to free_buffer_page().
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
---
drivers/staging/android/ion/ion_system_heap.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index f0ae210..d78d589e 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -77,9 +77,9 @@ static struct page *alloc_buffer_page(struct ion_system_heap *heap,
}
static void free_buffer_page(struct ion_system_heap *heap,
- struct ion_buffer *buffer, struct page *page,
- unsigned int order)
+ struct ion_buffer *buffer, struct page *page)
{
+ unsigned int order = compound_order(page);
bool cached = ion_buffer_cached(buffer);
if (!cached && !(buffer->private_flags & ION_PRIV_FLAG_SHRINKER_FREE)) {
@@ -169,7 +169,7 @@ free_table:
kfree(table);
free_pages:
list_for_each_entry_safe(page, tmp_page, &pages, lru)
- free_buffer_page(sys_heap, buffer, page, compound_order(page));
+ free_buffer_page(sys_heap, buffer, page);
return -ENOMEM;
}
@@ -189,8 +189,7 @@ static void ion_system_heap_free(struct ion_buffer *buffer)
ion_heap_buffer_zero(buffer);
for_each_sg(table->sgl, sg, table->nents, i)
- free_buffer_page(sys_heap, buffer, sg_page(sg),
- get_order(sg->length));
+ free_buffer_page(sys_heap, buffer, sg_page(sg));
sg_free_table(table);
kfree(table);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v2 8/9] staging: ion: shrink highmem pages on kswapd
2014-05-28 6:52 ` [PATCH v2 0/9] staging: ion: system heap and page pool fixes Heesub Shin
` (6 preceding siblings ...)
2014-05-28 6:52 ` [PATCH v2 7/9] staging: ion: remove order argument from free_buffer_page() Heesub Shin
@ 2014-05-28 6:52 ` Heesub Shin
2014-05-28 6:53 ` [PATCH v2 9/9] staging: ion: optimize struct ion_system_heap Heesub Shin
` (2 subsequent siblings)
10 siblings, 0 replies; 36+ messages in thread
From: Heesub Shin @ 2014-05-28 6:52 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: John Stultz, Rebecca Schultz Zavin, Colin Cross,
Arve Hjønnevåg, Mitchel Humpherys, Daeseok Youn,
Sunghwan Yun, Dongjun Shin, devel, linux-kernel, Heesub Shin
ION system heap keeps pages in its pool for better performance. When the
system is under memory pressure, slab shrinker calls the callback
registered and then the pages pooled get freed.
When the shrinker is called, it checks gfp_mask and determines whether
the pages from highmem need to be freed or the pages from lowmem.
Usually, slab shrinker is invoked on kswapd context which gfp_mask is
always GFP_KERNEL, so only lowmem pages are released on kswapd context.
This means that highmem pages in the pool are never reclaimed until
direct reclaim occurs. This can be problematic when the page pool holds
excessive amounts of highmem.
For now, the shrinker callback cannot know exactly which zone should be
targeted for reclamation, as enough information are not passed to. Thus,
it makes sense to shrink both lowmem and highmem zone on kswapd context.
Reported-by: Wonseo Choi <wonseo.choi@samsung.com>
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
---
drivers/staging/android/ion/ion_page_pool.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c
index c1cea42b..5864f3d 100644
--- a/drivers/staging/android/ion/ion_page_pool.c
+++ b/drivers/staging/android/ion/ion_page_pool.c
@@ -21,6 +21,7 @@
#include <linux/list.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/swap.h>
#include "ion_priv.h"
static void *ion_page_pool_alloc_pages(struct ion_page_pool *pool)
@@ -118,7 +119,10 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask,
int freed;
bool high;
- high = !!(gfp_mask & __GFP_HIGHMEM);
+ if (current_is_kswapd())
+ high = 1;
+ else
+ high = !!(gfp_mask & __GFP_HIGHMEM);
if (nr_to_scan == 0)
return ion_page_pool_total(pool, high);
--
1.9.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v2 9/9] staging: ion: optimize struct ion_system_heap
2014-05-28 6:52 ` [PATCH v2 0/9] staging: ion: system heap and page pool fixes Heesub Shin
` (7 preceding siblings ...)
2014-05-28 6:52 ` [PATCH v2 8/9] staging: ion: shrink highmem pages on kswapd Heesub Shin
@ 2014-05-28 6:53 ` Heesub Shin
2014-05-28 16:28 ` [PATCH v2 0/9] staging: ion: system heap and page pool fixes Mitchel Humpherys
2014-05-28 20:01 ` John Stultz
10 siblings, 0 replies; 36+ messages in thread
From: Heesub Shin @ 2014-05-28 6:53 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: John Stultz, Rebecca Schultz Zavin, Colin Cross,
Arve Hjønnevåg, Mitchel Humpherys, Daeseok Youn,
Sunghwan Yun, Dongjun Shin, devel, linux-kernel, Heesub Shin
struct ion_system_heap has an array for storing pointers to page pools
and it is allocated separately from the containing structure. There is
no point in allocating those two small objects individually, bothering
slab allocator. Using a variable length array simplifies code lines and
reduces overhead to the slab.
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
---
drivers/staging/android/ion/ion_system_heap.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index d78d589e..690d866 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -48,7 +48,7 @@ static inline unsigned int order_to_size(int order)
struct ion_system_heap {
struct ion_heap heap;
- struct ion_page_pool **pools;
+ struct ion_page_pool *pools[0];
};
static struct page *alloc_buffer_page(struct ion_system_heap *heap,
@@ -259,16 +259,15 @@ struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused)
struct ion_system_heap *heap;
int i;
- heap = kzalloc(sizeof(struct ion_system_heap), GFP_KERNEL);
+ heap = kzalloc(sizeof(struct ion_system_heap) +
+ sizeof(struct ion_page_pool *) * num_orders,
+ GFP_KERNEL);
if (!heap)
return ERR_PTR(-ENOMEM);
heap->heap.ops = &system_heap_ops;
heap->heap.type = ION_HEAP_TYPE_SYSTEM;
heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE;
- heap->pools = kzalloc(sizeof(struct ion_page_pool *) * num_orders,
- GFP_KERNEL);
- if (!heap->pools)
- goto free_heap;
+
for (i = 0; i < num_orders; i++) {
struct ion_page_pool *pool;
gfp_t gfp_flags = low_order_gfp_flags;
@@ -287,8 +286,6 @@ struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused)
destroy_pools:
while (i--)
ion_page_pool_destroy(heap->pools[i]);
- kfree(heap->pools);
-free_heap:
kfree(heap);
return ERR_PTR(-ENOMEM);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH v2 0/9] staging: ion: system heap and page pool fixes
2014-05-28 6:52 ` [PATCH v2 0/9] staging: ion: system heap and page pool fixes Heesub Shin
` (8 preceding siblings ...)
2014-05-28 6:53 ` [PATCH v2 9/9] staging: ion: optimize struct ion_system_heap Heesub Shin
@ 2014-05-28 16:28 ` Mitchel Humpherys
2014-05-28 20:01 ` John Stultz
10 siblings, 0 replies; 36+ messages in thread
From: Mitchel Humpherys @ 2014-05-28 16:28 UTC (permalink / raw)
To: Heesub Shin
Cc: Greg Kroah-Hartman, John Stultz, Rebecca Schultz Zavin,
Colin Cross, Arve Hjønnevåg, Daeseok Youn, Sunghwan Yun,
Dongjun Shin, devel, linux-kernel
On Tue, May 27 2014 at 11:52:51 PM, Heesub Shin <heesub.shin@samsung.com> wrote:
> Hi,
>
> Here is my patchset with some modification, hoping reviews or comments
> from you guys.
>
> v2:
> o No changes in the code, just reworded changelog
> o Reorder patch
Some very nice cleanup. And I learned a new trick with page.lru :).
Reviewed-by: Mitchel Humpherys <mitchelh@codeaurora.org>
>
> Heesub Shin (9):
> staging: ion: tidy up a bit
> staging: ion: simplify ion_page_pool_total()
> staging: ion: remove struct ion_page_pool_item
> staging: ion: use compound pages on high order pages for system heap
> staging: ion: remove order from struct page_info
> staging: ion: remove struct page_info
> staging: ion: remove order argument from free_buffer_page()
> staging: ion: shrink highmem pages on kswapd
> staging: ion: optimize struct ion_system_heap
>
> drivers/staging/android/ion/ion_page_pool.c | 49 ++++-------
> drivers/staging/android/ion/ion_priv.h | 2 +-
> drivers/staging/android/ion/ion_system_heap.c | 121 ++++++++++----------------
> 3 files changed, 67 insertions(+), 105 deletions(-)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH v2 0/9] staging: ion: system heap and page pool fixes
2014-05-28 6:52 ` [PATCH v2 0/9] staging: ion: system heap and page pool fixes Heesub Shin
` (9 preceding siblings ...)
2014-05-28 16:28 ` [PATCH v2 0/9] staging: ion: system heap and page pool fixes Mitchel Humpherys
@ 2014-05-28 20:01 ` John Stultz
10 siblings, 0 replies; 36+ messages in thread
From: John Stultz @ 2014-05-28 20:01 UTC (permalink / raw)
To: Heesub Shin, Greg Kroah-Hartman
Cc: Rebecca Schultz Zavin, Colin Cross, Arve Hjønnevåg,
Mitchel Humpherys, Daeseok Youn, Sunghwan Yun, Dongjun Shin,
devel, linux-kernel
On 05/27/2014 11:52 PM, Heesub Shin wrote:
> Hi,
>
> Here is my patchset with some modification, hoping reviews or comments
> from you guys.
>
> v2:
> o No changes in the code, just reworded changelog
> o Reorder patch
Ran this through Colin's ion-unit-tests and saw no changes in the
results on x86_64, i386(compat), and arm. So looks ok there.
Would still be good to have Colin's ack, but here's my qualified
tested-by line...
(Basic Unit)Tested-by: John Stultz <john.stultz@linaro.org>
thanks
-john
^ permalink raw reply [flat|nested] 36+ messages in thread