From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227+IuMf48p7uFmVhXUkzsw3ftFwhzWUXdS3lEkLBY2/AFfkv70uxfg6bhTlv8yLjGT6Evt1 ARC-Seal: i=1; a=rsa-sha256; t=1517256757; cv=none; d=google.com; s=arc-20160816; b=HE1wYBqGG8nWgsUCHsE3cQD5jZal7GqPUtGmiFDBcbKpr55tUPeMQ8x4+vcM5zSLpf wot2LT3TxC+rCaBcurHsJzzDVDwttRcIbozCEQEMm4KoRRiYzCtuFNh7/LV4K2ZW9Nw9 +MtllW0GEv6MAM+oa+T21vTDOomWi6fyRBQjNQwNP7kPOh4R1tkqAEv8qL51hOQmu7qq TZY1N3RavBEyTZagUFG+iXXyVAYP6TG3Tnt1+3+Xr67LOCIXswOIO0a0qNijbrBaydw8 leoADDBEPNNZVkb1dj69TSoqlJ3o8T6ewCJqmWZv0RPWdugzE1V7hUIzb3OoghydA2Ab uETQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=dPD1H0GfF2l00tG6F7nAAFAbwvAXS0CnO4O23tWjSFU=; b=SszgedzmbU3zpsDknDyAExZfL6MzopnBF8I2qwIxiparMfhL8YQ/d8WF9P21D7qLQ4 WbqHnJmL48yNk2gvOCz5GTS60pCCVSIUXO3fjeHySy1OV7wk4ysRNmQX+2VSJjhv63+1 9z88GxA11q5VgaKjHfnznvWmELBp+q33EwivTX1pEUV+2mNYMBJnUYHq3YHed68IRrgA zKiyFzxTAgEw1afkGFSO+U5AFaWwdpPh0Y1J0qOqeTktDdSxWDnE6Orby5yXFjDWxxYB QEn6hmK35oznQv/Ow/nDkVvvMju9vF7sbx/Ab/8OFsITpGO/BSEfDXbGBHSjy6ufHkGg qASg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michal Hocko , Laurent Dufour , Balbir Singh , Naoya Horiguchi , Andrew Morton , Linus Torvalds Subject: [PATCH 4.4 22/74] hwpoison, memcg: forcibly uncharge LRU pages Date: Mon, 29 Jan 2018 13:56:27 +0100 Message-Id: <20180129123848.626564488@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123847.507563674@linuxfoundation.org> References: <20180129123847.507563674@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590958886641404770?= X-GMAIL-MSGID: =?utf-8?q?1590959021922452311?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michal Hocko commit 18365225f0440d09708ad9daade2ec11275c3df9 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 0a31bc97c80c ("mm: memcontrol: rewrite uncharge API")). Each charge pins memcg (since e8ea14cc6ead ("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: coding-style fixes] Fixes: 0a31bc97c80c ("mm: memcontrol: rewrite uncharge API") Link: http://lkml.kernel.org/r/20170502185507.GB19165@dhcp22.suse.cz Signed-off-by: Michal Hocko Reported-by: Laurent Dufour Tested-by: Laurent Dufour Reviewed-by: Balbir Singh Reviewed-by: Naoya Horiguchi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/memcontrol.c | 2 +- mm/memory-failure.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5576,7 +5576,7 @@ static void uncharge_list(struct list_he next = page->lru.next; VM_BUG_ON_PAGE(PageLRU(page), page); - VM_BUG_ON_PAGE(page_count(page), page); + VM_BUG_ON_PAGE(!PageHWPoison(page) && page_count(page), page); if (!page->mem_cgroup) continue; --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -539,6 +539,13 @@ static int delete_from_lru_cache(struct */ ClearPageActive(p); ClearPageUnevictable(p); + + /* + * Poisoned page might never drop its ref count to 0 so we have + * to uncharge it manually from its memcg. + */ + mem_cgroup_uncharge(p); + /* * drop the page count elevated by isolate_lru_page() */