Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753913AbbGBSVn (ORCPT ); Thu, 2 Jul 2015 14:21:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58274 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754028AbbGBSVf (ORCPT ); Thu, 2 Jul 2015 14:21:35 -0400 Subject: Re: [PATCHv3 1/2] staging: ion: shrink page-pool by page unit To: Gioh Kim , gregkh@linuxfoundation.org, arve@android.com, riandrews@android.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org References: <1435748578-6400-1-git-send-email-gioh.kim@lge.com> <1435748578-6400-2-git-send-email-gioh.kim@lge.com> From: Laura Abbott Message-ID: <5595812D.7050601@redhat.com> Date: Thu, 2 Jul 2015 11:21:33 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: <1435748578-6400-2-git-send-email-gioh.kim@lge.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3327 Lines: 96 On 07/01/2015 04:02 AM, Gioh Kim wrote: > This patch shrink page-pool by page unit. > > The system shrinker calls ion_heap_shrink_count() to get nr_to_scan, > and pass it to ion_heap_shrink_scan(). > The problem is the return value of ion_heap_shrink_count() is the number > of pages but ion_system_heap_shrink(), which is called by > ion_heap_shrink_scan(), gets the number of chunk. > > The main root of this is that ion_page_pool_shrink() returns page count > via ion_page_pool_total() if it have to check pool size. But it frees > chunks of pages if it have to free pools. > > This patch first fix ion_page_pool_shrink() to count only pages, > not chunks. And then ion_system_heap_shrink() to work on pages. > > Signed-off-by: Gioh Kim Reviewed-by: Laura Abbott > --- > drivers/staging/android/ion/ion_page_pool.c | 5 +++-- > drivers/staging/android/ion/ion_system_heap.c | 16 ++++++++++++++-- > 2 files changed, 17 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c > index 4b88f11..19ad3ab 100644 > --- a/drivers/staging/android/ion/ion_page_pool.c > +++ b/drivers/staging/android/ion/ion_page_pool.c > @@ -116,7 +116,7 @@ static int ion_page_pool_total(struct ion_page_pool *pool, bool high) > int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, > int nr_to_scan) > { > - int freed; > + int freed = 0; > bool high; > > if (current_is_kswapd()) > @@ -127,7 +127,7 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, > if (nr_to_scan == 0) > return ion_page_pool_total(pool, high); > > - for (freed = 0; freed < nr_to_scan; freed++) { > + while (freed < nr_to_scan) { > struct page *page; > > mutex_lock(&pool->mutex); > @@ -141,6 +141,7 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, > } > mutex_unlock(&pool->mutex); > ion_page_pool_free_pages(pool, page); > + freed += (1 << pool->order); > } > > return freed; > diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c > index da2a63c..7a7a9a0 100644 > --- a/drivers/staging/android/ion/ion_system_heap.c > +++ b/drivers/staging/android/ion/ion_system_heap.c > @@ -212,14 +212,26 @@ static int ion_system_heap_shrink(struct ion_heap *heap, gfp_t gfp_mask, > { > struct ion_system_heap *sys_heap; > int nr_total = 0; > - int i; > + int i, nr_freed; > + int only_scan = 0; > > sys_heap = container_of(heap, struct ion_system_heap, heap); > > + if (!nr_to_scan) > + only_scan = 1; > + > for (i = 0; i < num_orders; i++) { > struct ion_page_pool *pool = sys_heap->pools[i]; > > - nr_total += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan); > + nr_freed = ion_page_pool_shrink(pool, gfp_mask, nr_to_scan); > + nr_total += nr_freed; > + > + if (!only_scan) { > + nr_to_scan -= nr_freed; > + /* shrink completed */ > + if (nr_to_scan <= 0) > + break; > + } > } > > return nr_total; > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/