Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1265251

Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting

From "Kirill A. Shutemov" <kirill@shutemov.name>
Newsgroups linux.kernel
Subject Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting
Date 2015-11-09 00:50 +0100
Message-ID <qsHSG-6T7-11@gated-at.bofh.it> (permalink)
References <qqLH4-4sG-31@gated-at.bofh.it> <qqLH5-4sG-47@gated-at.bofh.it> <qrDeq-5Hv-5@gated-at.bofh.it> <qrMrn-3f3-1@gated-at.bofh.it> <qrXPP-2cX-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Nov 06, 2015 at 02:39:00PM -0800, Andrew Morton wrote:
> On Fri, 6 Nov 2015 12:29:21 +0200 "Kirill A. Shutemov" <kirill@shutemov.name> wrote:
> 
> > > page_mapcount() is getting pretty bad too.
> > 
> > Do you want me to uninline slow path (PageCompound())?
> 
> I guess so.  Uninlining all of page_mapcount() does this:
> 
> gcc-4.4.4:
> 
>    text    data     bss     dec     hex filename
>  973702  273954  831512 2079168  1fb9c0 mm/built-in.o-before
>  970148  273954  831000 2075102  1fa9de mm/built-in.o-after
> 
> That's quite a bit of bloat.
> 
> I don't know why bss changed; this usually (always?) happens.  Seems
> bogus.

Here it is.

From 4bd3af3b6b9498254bd71e8288721dcff641156c Mon Sep 17 00:00:00 2001
From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Date: Mon, 9 Nov 2015 01:34:08 +0200
Subject: [PATCH] mm: uninline slowpath of page_mapcount()

Let's move page_mapcount() part for compound page into mm/util.c.

make allyesconfig:

  text	   data	    bss	    dec	    hex	filename
188515051	153360535	85458720	427334306	19789aa2	vmlinux.o.before
188512917	153356439	85458720	427328076	1978824c	vmlinux.o.after

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 include/linux/mm.h | 14 +++++---------
 mm/util.c          | 14 ++++++++++++++
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index f874d2a1d1a6..72edbbec7b91 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -417,19 +417,15 @@ static inline void page_mapcount_reset(struct page *page)
 	atomic_set(&(page)->_mapcount, -1);
 }
 
+int __page_mapcount(struct page *page);
+
 static inline int page_mapcount(struct page *page)
 {
-	int ret;
 	VM_BUG_ON_PAGE(PageSlab(page), page);
 
-	ret = atomic_read(&page->_mapcount) + 1;
-	if (PageCompound(page)) {
-		page = compound_head(page);
-		ret += atomic_read(compound_mapcount_ptr(page)) + 1;
-		if (PageDoubleMap(page))
-			ret--;
-	}
-	return ret;
+	if (unlikely(PageCompound(page)))
+		return __page_mapcount(page);
+	return atomic_read(&page->_mapcount) + 1;
 }
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
diff --git a/mm/util.c b/mm/util.c
index 902b65a43899..68535c0bb9da 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -376,6 +376,20 @@ struct address_space *page_mapping(struct page *page)
 	return mapping;
 }
 
+/* Slow path of page_mapcount() for compound pages */
+int __page_mapcount(struct page *page)
+{
+	int ret;
+
+	page = compound_head(page);
+	ret = atomic_read(&page->_mapcount) + 1;
+	ret += atomic_read(compound_mapcount_ptr(page)) + 1;
+	if (PageDoubleMap(page))
+		ret--;
+	return ret;
+}
+EXPORT_SYMBOL_GPL(__page_mapcount);
+
 int overcommit_ratio_handler(struct ctl_table *table, int write,
 			     void __user *buffer, size_t *lenp,
 			     loff_t *ppos)
-- 
 Kirill A. Shutemov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] Bugfixes for THP refcounting "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-11-03 16:30 +0100
  [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-11-03 16:30 +0100
    Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new  THP refcounting Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-11-05 10:20 +0100
      Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new  THP refcounting "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-05 10:30 +0100
        Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new  THP refcounting Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-11-05 13:10 +0100
          Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new  THP refcounting "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-05 13:40 +0100
            Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new  THP refcounting "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-05 14:00 +0100
              Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new  THP refcounting Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-11-05 17:40 +0100
              [PATCH] mm: add page_check_address_transhuge helper Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-11-06 15:40 +0100
                Re: [PATCH] mm: add page_check_address_transhuge helper "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-06 16:30 +0100
            Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new  THP refcounting Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-11-05 14:00 +0100
    Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new  THP refcounting Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-11-05 17:10 +0100
      Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new  THP refcounting "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-05 18:30 +0100
    Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new  THP refcounting Andrew Morton <akpm@linux-foundation.org> - 2015-11-06 01:40 +0100
      Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new  THP refcounting "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-06 11:30 +0100
        Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new  THP refcounting Andrew Morton <akpm@linux-foundation.org> - 2015-11-06 23:40 +0100
          Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new  THP refcounting "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-09 00:50 +0100
  [PATCH 2/4] mm: duplicate rmap reference for hugetlb pages as compound "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-11-03 16:30 +0100
  [PATCH 3/4] thp: fix split vs. unmap race "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-11-03 16:30 +0100

csiph-web