From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752981AbcFOJwb (ORCPT ); Wed, 15 Jun 2016 05:52:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:44268 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751529AbcFOJwa (ORCPT ); Wed, 15 Jun 2016 05:52:30 -0400 Subject: Re: [PATCH v2] mm/page_alloc: remove unnecessary order check in __alloc_pages_direct_compact To: Balbir Singh , Ganesh Mahendran References: <1465983258-3726-1-git-send-email-opensource.ganesh@gmail.com> Cc: linux-mm , "linux-kernel@vger.kernel.org" , "akpm@linux-foundation.org" , Joonsoo Kim , mhocko@suse.com, mina86@mina86.com, Minchan Kim , Anshuman Khandual From: Vlastimil Babka Message-ID: <16e37ddf-c28d-23ea-1216-d5a9c8a81b58@suse.cz> Date: Wed, 15 Jun 2016 11:52:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/15/2016 11:40 AM, Balbir Singh wrote: > On Wed, Jun 15, 2016 at 7:34 PM, Ganesh Mahendran > wrote: >> In the callee try_to_compact_pages(), the (order == 0) is checked, >> so remove check in __alloc_pages_direct_compact. >> >> Signed-off-by: Ganesh Mahendran >> --- >> v2: >> remove the check in __alloc_pages_direct_compact - Anshuman Khandual >> --- >> mm/page_alloc.c | 3 --- >> 1 file changed, 3 deletions(-) >> >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >> index b9ea618..2f5a82a 100644 >> --- a/mm/page_alloc.c >> +++ b/mm/page_alloc.c >> @@ -3173,9 +3173,6 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, >> struct page *page; >> int contended_compaction; >> >> - if (!order) >> - return NULL; >> - >> current->flags |= PF_MEMALLOC; >> *compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac, >> mode, &contended_compaction); > > What is the benefit of this. Is an if check more expensive than > calling the function and returning from it? I don't feel strongly > about such changes, but its good to audit the overall code for reading > and performance. Agree. The majority of calls should be for order == 0 where the check avoids us from modifying current->flags and calling into compaction.c just to return and modify the flags back. I would argue that we should even check order before calling __alloc_pages_direct_compact() to avoid another potential call, but the compiler might be doing the right thing already. So v1 was better in this aspect. But it wouldn't gain us any measurable performance benefit anyway, so we might as well leave it. > Balbir Singh >