On Fri, May 22, 2015 at 05:13:25PM -0400, Tejun Heo wrote: > +/** > + * mem_cgroup_css_from_page - css of the memcg associated with a page > + * @page: page of interest > + * > + * This function is guaranteed to return a valid cgroup_subsys_state and > + * the returned css remains accessible until @page is released. > + */ > +struct cgroup_subsys_state *mem_cgroup_css_from_page(struct page *page) > +{ > + if (page->mem_cgroup) > + return &page->mem_cgroup->css; > + return &root_mem_cgroup->css; > +} replace_page_cache() can clear page->mem_cgroup even when the page still has references, so unfortunately you must hold the page lock when calling this function. I haven't checked how you use this - chances are you always have the page locked anyways - but it probably needs a comment. -- 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>