Received: by 10.223.176.5 with SMTP id f5csp3417656wra; Mon, 29 Jan 2018 12:53:38 -0800 (PST) X-Google-Smtp-Source: AH8x227MEB7VjK75T3Ldu8Hcik4KfFoKWN8bb8LmlS4Z7jThtz8fprz5PvrfnLpMsDUBRfOR9BEv X-Received: by 2002:a17:902:1a4:: with SMTP id b33-v6mr22700572plb.58.1517259218483; Mon, 29 Jan 2018 12:53:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517259218; cv=none; d=google.com; s=arc-20160816; b=UstTudIxMLudgOK7BZVUeiuex+xb2fdg/hFFA6B7V/3FSgEsobBfV8R85tCx85agSU fWdnkMSpdhFqEu6+6tpcSvEJYuVvmQrRuBLT9rV0qIo7OnlTUbOisqNO+9vRWBba3A1t xum5uBIF8JMQnU54tgKTK91sZgm068Pch4nbkf2Ysfw9oDRyEA0cpU4RYolCB9de+fUb RJ7tfNUbj0ztO0OpTJA7xyYNhhnK/iMaqfeqmKpVCP91h1/7dPzPQk6OqtAY0h9w/ouJ m+rqXQgBuDIRqDKCwrBZi8s1hW+qzFk8c8qia6xc/Ixa6VxHR4hIkrDlSZKLBZnxlbQp 5uFg== 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=sA87IiN+zRtDE6E38gHucsXBqGesrZbroZX60omVwaI=; b=PO/AHzY+yERk2wmbw7NT4i2CkkTuWjxPSoeIghT9DnrFtkSBlMC42QbbLuWYPeHB+w Jp4RR7vosBldQXqI/v0TELFThJ8vIYPfagTf8Ir5VMTY47PEQ6+qAwuw9XDm9Wo4XOYN QKVy2rDOVu0tQJEr0P2/1hRecd4AxzQKQsRlRPf2y8/XKsfVPTbuDO/wMmlh04WR5jFc UZq/RaW4dkHB8lcjmN6hmdr4LWpC//WcMpe1zXRMc71pEF9UceSWRBbYkPB0Yj3YAEfa KmxeNPrzq2jk13kaDRDiw6kJa5hVP0sI+IjlWEG1qvtrB8ZJ/aj23bOnz+3Hroj6gdJi o4TQ== 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 x13si7958544pgp.281.2018.01.29.12.53.24; Mon, 29 Jan 2018 12:53:38 -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 S1751579AbeA2UxC (ORCPT + 99 others); Mon, 29 Jan 2018 15:53:02 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:57242 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753469AbeA2UK2 (ORCPT ); Mon, 29 Jan 2018 15:10:28 -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 0951C2F5F; Mon, 29 Jan 2018 13:04:33 +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.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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() */