From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753940AbcEJBEO (ORCPT ); Mon, 9 May 2016 21:04:14 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:63705 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752345AbcEJBEN (ORCPT ); Mon, 9 May 2016 21:04:13 -0400 Subject: Re: [RESEND PATCH] ION: Sys_heap: Add cached pool to spead up cached buffer alloc To: Laura Abbott , , , , , , , , References: <1462783054-36053-1-git-send-email-puck.chen@hisilicon.com> <5aef4164-1055-4fca-51ea-3327b9febc10@redhat.com> CC: , , , , From: Chen Feng Message-ID: <57313353.30602@hisilicon.com> Date: Tue, 10 May 2016 09:03:15 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <5aef4164-1055-4fca-51ea-3327b9febc10@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.142.193.64] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.5731335D.00BD,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 2f03b7460c6fcc69db4704772f715a15 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Laura, On 2016/5/10 7:50, Laura Abbott wrote: > On 05/09/2016 01:37 AM, Chen Feng wrote: >> Add ion cached pool in system heap. >> >> Signed-off-by: Chen Feng >> Signed-off-by: Xia Qing >> Reviewed-by: Fu Jun >> --- >> drivers/staging/android/ion/ion_system_heap.c | 145 +++++++++++++++++--------- >> 1 file changed, 95 insertions(+), 50 deletions(-) >> >> diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c >> index b69dfc7..c633252 100644 >> --- a/drivers/staging/android/ion/ion_system_heap.c >> +++ b/drivers/staging/android/ion/ion_system_heap.c >> @@ -49,7 +49,8 @@ static inline unsigned int order_to_size(int order) >> >> struct ion_system_heap { >> struct ion_heap heap; >> - struct ion_page_pool *pools[0]; >> + struct ion_page_pool *uncached_pools[0]; >> + struct ion_page_pool *cached_pools[0]; >> }; >> >> static struct page *alloc_buffer_page(struct ion_system_heap *heap, >> @@ -57,39 +58,36 @@ static struct page *alloc_buffer_page(struct ion_system_heap *heap, >> unsigned long order) >> { >> bool cached = ion_buffer_cached(buffer); >> - struct ion_page_pool *pool = heap->pools[order_to_index(order)]; >> + struct ion_page_pool *pool; >> struct page *page; >> >> - if (!cached) { >> - page = ion_page_pool_alloc(pool); >> - } else { >> - gfp_t gfp_flags = low_order_gfp_flags; >> - >> - if (order > 4) >> - gfp_flags = high_order_gfp_flags; >> - page = alloc_pages(gfp_flags | __GFP_COMP, order); >> - if (!page) >> - return NULL; >> - ion_pages_sync_for_device(NULL, page, PAGE_SIZE << order, >> - DMA_BIDIRECTIONAL); >> - } >> + if (!cached) >> + pool = heap->uncached_pools[order_to_index(order)]; >> + else >> + pool = heap->cached_pools[order_to_index(order)]; >> >> + page = ion_page_pool_alloc(pool); >> return page; >> } >> > > This is a change in behavior. The page is no longer guaranteed to be synced > in the cache. If the page came from the pool (not just freshly allocated) > the cache state is unknown. Do you have a good explanation why we no longer > need to do the cache flush here on every allocation? > Yes, no more explanation here. Please see my v1[1] version. Thanks for review! [1] http://thread.gmane.org/gmane.linux.kernel/2217505 > Thanks, > Laura > > . >