Received: by 10.223.176.5 with SMTP id f5csp3408599wra; Mon, 29 Jan 2018 12:45:29 -0800 (PST) X-Google-Smtp-Source: AH8x225ZQJDyOTXN3dQJtNimH4B8HldcapPlLm1ZjPTWbFeeiELIC0DAJ3qfhXE9y1er6nQDbJ6O X-Received: by 2002:a17:902:bf41:: with SMTP id u1-v6mr13561839pls.416.1517258729807; Mon, 29 Jan 2018 12:45:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517258729; cv=none; d=google.com; s=arc-20160816; b=fmoWVWu+A/QoKepwlYO7SGray+h8jl3uQ8WbBvZ+Lvzgl07dbl5igjKVdBqq4slvSm Djc7n6S7HXM7RFDPeqH2A9icd2rzDP294gabb6ATLGq0rmkbNGh1UWf9xu3qoSN0DmMN /8qhmzcBN4TTERj/65Bp263Yt+AkXo1rJ3Z6kGeQjAzXg2Z0TjHD49kTuiCU9nd3loiN 5l7RwGdkpWXS4z9PhbOL3ClGytSdpG1tW8YwTGFOT0CmMU2NU1ck8W5xrfo+gVG1ThoR ZRopwYnHJNnjVIWQUnGEjnubvO7U8TCOw+NZUM5P3hUueBX8695TVTG/kv16ADxASlOW gzBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=dPD1H0GfF2l00tG6F7nAAFAbwvAXS0CnO4O23tWjSFU=; b=SQSxRwLPv8/2vRVGeJJebG8E2Xc6jhjCWg6i+dLGIZq+MS23Ts0IDghe7v4i7jrUrU gHjRsouoWMefiq7hOdnTJnmLf4QUzVaewgFoK2w7k+HPq2+cfRCniHQMspxIuBJBN/HK hvyioeJSW8RUgKlpOiwUPDI1nkSvA7pxDtd9Y4ERcDSEdsp5KIND3x8vSsnmySqHtPcj rBaH4OOgLUCl7fuNgLjbI2II5Ij6hBHKl/+b59FGmGXZA73gKu/V2A7c7QoSbV8/Aml6 sN4O4rtByvtqCaV8sveBLSyuL9qsMVQluFr+UGGOVowlf+pCB3NGXf9zoz1X7cICBAYC Rvqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g24-v6si9062019plj.50.2018.01.29.12.45.15; Mon, 29 Jan 2018 12:45:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754116AbeA2UoN (ORCPT + 99 others); Mon, 29 Jan 2018 15:44:13 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35336 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753943AbeA2UMg (ORCPT ); Mon, 29 Jan 2018 15:12:36 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 559132F2E; Mon, 29 Jan 2018 13:03:03 +0000 (UTC) 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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() */