From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x226mHoZ1FJrhN+YSc5kAGYM3ZI9dDdLJUoMgmPlM7a1DaAAf978PCDNYAV87LwQGBNKhvzu5 ARC-Seal: i=1; a=rsa-sha256; t=1517256628; cv=none; d=google.com; s=arc-20160816; b=Ahy7FdWYYnK1Gz3W7zMixgLxxLXev/KJFjWjUrCBfxBtbLHw8ABnSYtobd+s2PUbQA CaZoZP9OVJt1SxsSRpZynLm0zpZycgloiLiG3nSihG0cKYYdLPqHelshwGHRTDhOS+Ii DmsVdxr1QocrOzv/eOYdnl/9DFnjQjRrQp/tk7HHpi9zy1ShluZNwGdF92o+ixicUwZ0 k6EBB5rpCvv7TxOf1Q7tk1VArFbeYh3q/+1zugcCOG8x0c6NXm/mPuCQRsnpr0HrcYMy sa4gHDeBPoKvy/ryNPjbSaZx34IEoJzD1C/4HdUZhvtLKLpbQy0zSeUqbnHdOrS1gveC HE/Q== 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=sA87IiN+zRtDE6E38gHucsXBqGesrZbroZX60omVwaI=; b=xWhZIl8f9hLWF9eQckVwTqlwFKkUQLS1F3SDMGWAndQihmRJ58Wc0p7vCiRuU64Kfo 0Gulf8GzYwhXLz3D1rHllU8SsnHHp2QBBuNrWfJYbW0JZx53XW+bmIjpqDGGwf7mhf6h +tvlEfpKJ8EnkrxdOwBXF+BOcNdjdwmG910TSeOaOppjJXCioxZPKpKgr+DqH2MKmgYl 4nXhj4wOhq0SY+4P/HA9cD5CydEoOnFkM+yrQBwdyLZmrJi+4r6EuO0KgY7YspWcj75u VKUiiEwyR/wRab/Twt0fPeuFX4EibWWrXRWkbGRLkOfCjCpo3FCqTMxy6Hk9Po6wNXvC EgjA== 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.9 14/66] hwpoison, memcg: forcibly uncharge LRU pages Date: Mon, 29 Jan 2018 13:56:38 +0100 Message-Id: <20180129123840.576722849@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123839.842860149@linuxfoundation.org> References: <20180129123839.842860149@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?1590958886641404770?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.9-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 @@ -5531,7 +5531,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 @@ -535,6 +535,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() */