lkml.org 
[lkml]   [2015]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 11/51] memcg: implement mem_cgroup_css_from_page()
    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.


    \
     
     \ /
      Last update: 2015-05-23 02:01    [W:2.251 / U:0.000 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site