Re: [PATCH 4/9] staging: ion: remove struct ion_page_pool_item

2014-05-26 Thread Heesub Shin

Hello,

On 05/26/2014 07:04 PM, Heesub Shin wrote:

Now that the order information is held on struct page itself, we do not
need to use extra data structure. This commit reduces unnecessary slab
usage for allocating small objects.



Oops. I need to amend changelog above and resend this patchset.

regards,
Heesub
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/9] staging: ion: remove struct ion_page_pool_item

2014-05-26 Thread Heesub Shin
Now that the order information is held on struct page itself, we do not
need to use extra data structure. This commit reduces unnecessary slab
usage for allocating small objects.

Signed-off-by: Heesub Shin 
---
 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 0141b3b..c1cea42b 100644
--- a/drivers/staging/android/ion/ion_page_pool.c
+++ b/drivers/staging/android/ion/ion_page_pool.c
@@ -23,11 +23,6 @@
 #include 
 #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(>mutex);
-   item->page = page;
if (PageHighMem(page)) {
-   list_add_tail(>list, >high_items);
+   list_add_tail(>lru, >high_items);
pool->high_count++;
} else {
-   list_add_tail(>list, >low_items);
+   list_add_tail(>lru, >low_items);
pool->low_count++;
}
mutex_unlock(>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(>high_items,
-   struct ion_page_pool_item, list);
+   page = list_first_entry(>high_items, struct page, lru);
pool->high_count--;
} else {
BUG_ON(!pool->low_count);
-   item = list_first_entry(>low_items,
-   struct ion_page_pool_item, list);
+   page = list_first_entry(>low_items, struct page, lru);
pool->low_count--;
}
 
-   list_del(>list);
-   page = item->page;
-   kfree(item);
+   list_del(>lru);
return page;
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/9] staging: ion: remove struct ion_page_pool_item

2014-05-26 Thread Heesub Shin
Now that the order information is held on struct page itself, we do not
need to use extra data structure. This commit reduces unnecessary slab
usage for allocating small objects.

Signed-off-by: Heesub Shin heesub.s...@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 0141b3b..c1cea42b 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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 4/9] staging: ion: remove struct ion_page_pool_item

2014-05-26 Thread Heesub Shin

Hello,

On 05/26/2014 07:04 PM, Heesub Shin wrote:

Now that the order information is held on struct page itself, we do not
need to use extra data structure. This commit reduces unnecessary slab
usage for allocating small objects.



Oops. I need to amend changelog above and resend this patchset.

regards,
Heesub
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/