Re: [PATCHv6 26/36] mm: rework mapcount accounting to enable 4k mapping of THPs

From: Kirill A. Shutemov
Date: Mon Jun 22 2015 - 06:22:44 EST


On Wed, Jun 10, 2015 at 03:47:06PM +0200, Vlastimil Babka wrote:
> On 06/03/2015 07:05 PM, Kirill A. Shutemov wrote:
> >@@ -415,8 +428,17 @@ static inline void page_mapcount_reset(struct page *page)
> >
> > static inline int page_mapcount(struct page *page)
> > {
> >+ int ret;
> > VM_BUG_ON_PAGE(PageSlab(page), page);
> >- return atomic_read(&page->_mapcount) + 1;
> >+
> >+ ret = atomic_read(&page->_mapcount) + 1;
> >+ if (PageCompound(page)) {
> >+ page = compound_head(page);
> >+ ret += compound_mapcount(page);
>
> compound_mapcount() means another PageCompound() and compound_head(), which
> you just did. I've tried this to see the effect on a function that "calls"
> (inlines) page_mapcount() once:
>
> - ret += compound_mapcount(page);
> + ret += atomic_read(compound_mapcount_ptr(page)) + 1;
>
> bloat-o-meter on compaction.o:
> add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-59 (-59)
> function old new delta
> isolate_migratepages_block 1769 1710 -59

Okay, fair enough.

> >diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> >index 74b7cece1dfa..a8d47c1edf6a 100644
> >--- a/include/linux/page-flags.h
> >+++ b/include/linux/page-flags.h
> >@@ -127,6 +127,9 @@ enum pageflags {
> >
> > /* SLOB */
> > PG_slob_free = PG_private,
> >+
> >+ /* THP. Stored in first tail page's flags */
> >+ PG_double_map = PG_private_2,
>
> Well, not just THP. Any user of compound pages must make sure not to use
> PG_private_2 on the first tail page. At least where the page is going to be
> user-mapped. And same thing about fields that are in union with
> compound_mapcount. Should that be documented more prominently somewhere?

I would substitute "THP" for "Compound pages".

> I guess there's no such user so far, right?

I believe so.

--
Kirill A. Shutemov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at http://www.tux.org/lkml/