On Wed, Sep 30, 2015 at 12:51:18PM -0700, Greg Thelen wrote: > > Vladimir Davydov wrote: ... > > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h > > index 416509e26d6d..a190719c2f46 100644 > > --- a/include/linux/page-flags.h > > +++ b/include/linux/page-flags.h > > @@ -594,6 +594,28 @@ static inline void __ClearPageBalloon(struct page *page) > > } > > > > /* > > + * PageKmem() returns true if the page was allocated with alloc_kmem_pages(). > > + */ > > +#define PAGE_KMEM_MAPCOUNT_VALUE (-512) > > + > > +static inline int PageKmem(struct page *page) > > +{ > > + return atomic_read(&page->_mapcount) == PAGE_KMEM_MAPCOUNT_VALUE; > > +} > > + > > +static inline void __SetPageKmem(struct page *page) > > +{ > > + VM_BUG_ON_PAGE(atomic_read(&page->_mapcount) != -1, page); > > + atomic_set(&page->_mapcount, PAGE_KMEM_MAPCOUNT_VALUE); > > +} > > What do you think about several special mapcount values for various > types of kmem? > > It's helps user and administrators break down memory usage. > > A nice equation is: > memory.usage_in_bytes = memory.stat[file + anon + unevictable + kmem] > > Next, it's helpful to be able to breakdown kmem into: > kmem = stack + pgtable + slab + ... > > On one hand (and the kernel I use internally) we can use separate per > memcg counters for each kmem type. Then reconstitute memory.kmem as > needed by adding them together. But using keeping a single kernel kmem > counter is workable if there is a way to breakdown the memory charge to > a container (e.g. by walking /proc/kpageflags-ish or per memcg > memory.kpageflags-ish file). I don't think that storing information about kmem type on the page struct just to report it via /proc/kpageflags is a good idea, because the number of unused bits left on the page struct is limited so we'd better (ab)use them carefully, only when it's really difficult to get along w/o them. OTOH I do agree that some extra info showing what "kmem" is actually used for could be helpful. To accumulate this info we can always use per-cpu counters, which are pretty cheap and won't degrade performance, and then report it via memory.stat. Furthermore, it will be more convenient for administrators to read this info in human-readable format than parsing /proc/kpageflags, which in addition takes long on systems with a lot of RAM. Thanks, Vladimir -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>