From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753257AbcD0O53 (ORCPT ); Wed, 27 Apr 2016 10:57:29 -0400 Received: from outbound-smtp11.blacknight.com ([46.22.139.16]:41354 "EHLO outbound-smtp11.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752371AbcD0O50 (ORCPT ); Wed, 27 Apr 2016 10:57:26 -0400 From: Mel Gorman To: Andrew Morton Cc: Vlastimil Babka , Jesper Dangaard Brouer , Linux-MM , LKML , Mel Gorman Subject: [PATCH 5/6] mm, page_alloc: pull out side effects from free_pages_check Date: Wed, 27 Apr 2016 15:57:22 +0100 Message-Id: <1461769043-28337-6-git-send-email-mgorman@techsingularity.net> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1461769043-28337-1-git-send-email-mgorman@techsingularity.net> References: <1461769043-28337-1-git-send-email-mgorman@techsingularity.net> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Check without side-effects should be easier to maintain. It also removes the duplicated cpupid and flags reset done in !DEBUG_VM variant of both free_pcp_prepare() and then bulkfree_pcp_prepare(). Finally, it enables the next patch. It shouldn't result in new branches, thanks to inlining of the check. !DEBUG_VM bloat-o-meter: add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-27 (-27) function old new delta __free_pages_ok 748 739 -9 free_pcppages_bulk 1403 1385 -18 DEBUG_VM: add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-28 (-28) function old new delta free_pages_prepare 806 778 -28 This is also slightly faster because cpupid information is not set on tail pages so we can avoid resets there. Signed-off-by: Vlastimil Babka Signed-off-by: Mel Gorman --- mm/page_alloc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 97894cbe2fa3..b823f00c275b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -932,11 +932,8 @@ static void free_pages_check_bad(struct page *page) } static inline int free_pages_check(struct page *page) { - if (likely(page_expected_state(page, PAGE_FLAGS_CHECK_AT_FREE))) { - page_cpupid_reset_last(page); - page->flags &= ~PAGE_FLAGS_CHECK_AT_PREP; + if (likely(page_expected_state(page, PAGE_FLAGS_CHECK_AT_FREE))) return 0; - } /* Something has gone sideways, find it */ free_pages_check_bad(page); @@ -1016,7 +1013,11 @@ static bool free_pages_prepare(struct page *page, unsigned int order) for (i = 1; i < (1 << order); i++) { if (compound) bad += free_tail_pages_check(page, page + i); - bad += free_pages_check(page + i); + if (unlikely(free_pages_check(page + i))) { + bad++; + continue; + } + (page + i)->flags &= ~PAGE_FLAGS_CHECK_AT_PREP; } } if (PageAnonHead(page)) @@ -1025,6 +1026,8 @@ static bool free_pages_prepare(struct page *page, unsigned int order) if (bad) return false; + page_cpupid_reset_last(page); + page->flags &= ~PAGE_FLAGS_CHECK_AT_PREP; reset_page_owner(page, order); if (!PageHighMem(page)) { -- 2.6.4