Received: by 10.223.176.5 with SMTP id f5csp3376585wra; Mon, 29 Jan 2018 12:19:28 -0800 (PST) X-Google-Smtp-Source: AH8x225q66QZtPcoL8Wo2YfcuB0qGH2ahbWxR7fiwtdfFduSwClsnvqrZq2jZrgu9nDXkGP8tjYZ X-Received: by 10.99.114.27 with SMTP id n27mr22675929pgc.424.1517257168269; Mon, 29 Jan 2018 12:19:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517257168; cv=none; d=google.com; s=arc-20160816; b=okevXP9iQ5R/iUh6BFY1E/eZhjQ5ICUZJjLYRx5TWnlGioKnRFKFIKGUz1KnmgEKP2 c1kAuGT6j+0mkOzzgTtXqu2CzdnmJNLtWrf1p2SqpFKENkD1qZZ6vi6O+QNo+FEtQYcl U2Lfd6llzMfDwMRxYaLLtys04/lLH5bLqlX3Iv0GzlIUA13cp4lqWIeoKu9suCG/z3qU V7ej/5WGQdp3hNTGvNUF2ba0dmxaBWgqTMDJhDeiBlgYK8DqI1GqEYVYkAwL6b+Qo+ZS R7MpaTpBvarlapcuv8VyhUnRSGVuyPUqpty//jUiN50rZToleZ/ddrqClLVhuvCJLPfr KcoA== 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=B+/sKMjMWN9l3y51zDKVOXRXANCOhTtkEpI3WCY57Ko=; b=UQffYfo0mSldZ6VK/BObNzTdmxvJXczKO4TkS4sgyPAWD3HH4pUfprD7X+8aPkytPF tQyqhPhDKWb1cIuszBfTkbuwsj5/68ycBqmlLeACiQRUH+dm/SEwrRkftMOp6p2W1PRO r55M7t3d9eKydg+/ZfA9UZ5vilI4ct9MsXARofq5bPfvBwxWsUCu54h7kSZc6OmJchq/ Id7eyYILL31Arsdsc+7Jh4P6wkT9sEoSBRk/pIPDc8dmj6CYwwtV6PPixxUnRG4IcPTC /iKCOZjF0jSk88DBVVFf9A7PH6tLsuqNQaLSDHPfdAiHgMH8jXIbq44c+LqZfw3YpjGs McZg== 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 n26si4097367pge.266.2018.01.29.12.19.13; Mon, 29 Jan 2018 12:19:28 -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 S1754722AbeA2UR1 (ORCPT + 99 others); Mon, 29 Jan 2018 15:17:27 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:46788 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753554AbeA2URX (ORCPT ); Mon, 29 Jan 2018 15:17:23 -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 B547A2E9A; Mon, 29 Jan 2018 12:58:43 +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 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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() */