linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Arcangeli <aarcange@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Alex Williamson <alex.williamson@redhat.com>,
	"Kirill A. Shutemov" <kirill@shutemov.name>
Subject: [PATCH 2/3] mm: thp: microoptimize compound_mapcount()
Date: Fri,  6 May 2016 17:03:59 +0200	[thread overview]
Message-ID: <1462547040-1737-3-git-send-email-aarcange@redhat.com> (raw)
In-Reply-To: <1462547040-1737-1-git-send-email-aarcange@redhat.com>

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 <aarcange@redhat.com>
---
 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;
 }

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2016-05-06 15:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-06 15:03 [PATCH 0/3] mm: thp: mapcount updates Andrea Arcangeli
2016-05-06 15:03 ` [PATCH 1/3] mm: thp: calculate the mapcount correctly for THP pages during WP faults Andrea Arcangeli
2016-05-06 22:10   ` Alex Williamson
2016-05-09 22:26   ` Andrew Morton
2016-05-10 19:21   ` [PATCH 1/1] " Andrea Arcangeli
2016-05-11 21:26     ` [1/1] " Mike Marciniszyn
2016-05-12 16:32     ` [PATCH 1/1] " Andrea Arcangeli
2016-05-12 18:48       ` [1/1] " Mike Marciniszyn
2016-05-06 15:03 ` Andrea Arcangeli [this message]
2016-05-06 17:33   ` [PATCH 2/3] mm: thp: microoptimize compound_mapcount() Kirill A. Shutemov
2016-05-06 15:04 ` [PATCH 3/3] mm: thp: split_huge_pmd_address() comment improvement Andrea Arcangeli
2016-05-06 17:33   ` Kirill A. Shutemov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462547040-1737-3-git-send-email-aarcange@redhat.com \
    --to=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.williamson@redhat.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).