• Michal Hocko's avatar
    hwpoison, memcg: forcibly uncharge LRU pages · fee959e9
    Michal Hocko authored
    commit 18365225 upstream.
    
    Laurent Dufour has noticed that hwpoinsoned pages are kept charged.  In
    his particular case he has hit a bad_page("page still charged to
    cgroup") when onlining a hwpoison page.  While this looks like something
    that shouldn't happen in the first place because onlining hwpages and
    returning them to the page allocator makes only little sense it shows a
    real problem.
    
    hwpoison pages do not get freed usually so we do not uncharge them (at
    least not since commit 0a31bc97 ("mm: memcontrol: rewrite uncharge
    API")).  Each charge pins memcg (since e8ea14cc ("mm: memcontrol:
    take a css reference for each charged page")) as well and so the
    mem_cgroup and the associated state will never go away.  Fix this leak
    by forcibly uncharging a LRU hwpoisoned page in delete_from_lru_cache().
    We also have to tweak uncharge_list because it cannot rely on zero ref
    count for these pages.
    
    [akpm@linux-foundation.org: codin...
    fee959e9
memcontrol.c 174 KB