From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758281AbcEFPEH (ORCPT ); Fri, 6 May 2016 11:04:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52319 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757964AbcEFPEE (ORCPT ); Fri, 6 May 2016 11:04:04 -0400 From: Andrea Arcangeli To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Alex Williamson , "Kirill A. Shutemov" Subject: [PATCH 2/3] mm: thp: microoptimize compound_mapcount() Date: Fri, 6 May 2016 17:03:59 +0200 Message-Id: <1462547040-1737-3-git-send-email-aarcange@redhat.com> In-Reply-To: <1462547040-1737-1-git-send-email-aarcange@redhat.com> References: <1462547040-1737-1-git-send-email-aarcange@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org compound_mapcount() is only called after PageCompound() has already been checked by the caller, so there's no point to check it again. Gcc may optimize it away too because it's inline but this will remove the runtime check for sure and add it'll add an assert instead. Signed-off-by: Andrea Arcangeli --- include/linux/mm.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 263f229..726ba80 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -471,8 +471,7 @@ static inline atomic_t *compound_mapcount_ptr(struct page *page) static inline int compound_mapcount(struct page *page) { - if (!PageCompound(page)) - return 0; + VM_BUG_ON_PAGE(!PageCompound(page), page); page = compound_head(page); return atomic_read(compound_mapcount_ptr(page)) + 1; }