From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x22659pTLyWuG+EVUN/Q9FfImybJ7dQtWlmOrIUb93xd8Abs7zewH6fOB1lVBt7oJ8SAarNkB ARC-Seal: i=1; a=rsa-sha256; t=1517257044; cv=none; d=google.com; s=arc-20160816; b=MeWYVANS5EZ2TB1A1T5IqSxcBRWKtIGKqwjnrBTtFVbmNgVFrUow1hBrNNoB/a+3DF /DHvVCUc/3fBy6FlJgLqY4hLKZpXl275fDxFUVL13xfUQieJGQ9JgGcRuHPyvAO2Rjsu ttLKPzyCYgd/IuMK9YZTBbz+VSbP2ssLjeLak5PlZeDtQYmrUSbJn2LrCwXhDz/J4Sh2 C0mkvUcrDocbYZ0QwTs/gnJ8zThaFPOjO45V9UJNMFHrk7a6DmkS0ClXGxOkMzQt/UD7 LqcSepY0KoH/B7qNu8qKfSbDfO6XWO43GfEhyKOBqSw4Wqh5k854fOZmgoeb1R+O3zJ1 628Q== 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=B+/sKMjMWN9l3y51zDKVOXRXANCOhTtkEpI3WCY57Ko=; b=TU4YwDe9ZQuVtyQw1eJ8MmIK4RMF8CgT20Gxdc0itzgVggXRL1h7WHy+jcL45bZOWd XkmgAN7Nmqk6429SJofCcZSGoTc5eqV7ANOWSEsMGNSHhavjXhwEoLFnf4EmjueqQhmX +pHci0GV64fOTzMoZ6ahhIagZBCtHgxU79rSFstwwqWO0lJpFM3X733zCIz38tN5BZ5W vOJYDs9evBkMHYavLe0L+whuTmQ1z+GGrIXa180VT37OorVhKCjLOuFWyCkD52Yz8iKy fBiodp37tWYwW2VIHMvYYEov4B4tEltbHX4VkgJYJspZ2wsyXr5DMrPSOVWSEpuUWYj+ nzkw== 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 3.18 25/52] hwpoison, memcg: forcibly uncharge LRU pages Date: Mon, 29 Jan 2018 13:56:43 +0100 Message-Id: <20180129123629.310171627@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123628.168904217@linuxfoundation.org> References: <20180129123628.168904217@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?1590959322687293026?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 3.18-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 @@ -6500,7 +6500,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); pc = lookup_page_cgroup(page); if (!PageCgroupUsed(pc)) --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -548,6 +548,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() */