Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1955034AbdDZEra convert rfc822-to-8bit (ORCPT ); Wed, 26 Apr 2017 00:47:30 -0400 Received: from tyo162.gate.nec.co.jp ([114.179.232.162]:49663 "EHLO tyo162.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1035167AbdDZErY (ORCPT ); Wed, 26 Apr 2017 00:47:24 -0400 From: Naoya Horiguchi To: Balbir Singh CC: Laurent Dufour , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "akpm@linux-foundation.org" Subject: Re: [PATCH v2 1/2] mm: Uncharge poisoned pages Thread-Topic: [PATCH v2 1/2] mm: Uncharge poisoned pages Thread-Index: AQHSvdAlGOZ3BQwtDkae9J7zLQT7cKHWTbcAgAAK9ACAABPKAIAAERaA Date: Wed, 26 Apr 2017 04:46:09 +0000 Message-ID: <20170426044608.GA32451@hori1.linux.bs1.fc.nec.co.jp> References: <1493130472-22843-1-git-send-email-ldufour@linux.vnet.ibm.com> <1493130472-22843-2-git-send-email-ldufour@linux.vnet.ibm.com> <1493171698.4828.1.camel@gmail.com> <20170426023410.GA11619@hori1.linux.bs1.fc.nec.co.jp> <1493178300.4828.5.camel@gmail.com> In-Reply-To: <1493178300.4828.5.camel@gmail.com> Accept-Language: en-US, ja-JP Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.128.101.32] Content-Type: text/plain; charset="iso-2022-jp" Content-ID: Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-TM-AS-MML: disable Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1201 Lines: 29 On Wed, Apr 26, 2017 at 01:45:00PM +1000, Balbir Singh wrote: > > > > static int delete_from_lru_cache(struct page *p) > > > > { > > > > + if (memcg_kmem_enabled()) > > > > + memcg_kmem_uncharge(p, 0); > > > > + > > > > > > The changelog is not quite clear, so we are uncharging a page using > > > memcg_kmem_uncharge for a page in swap cache/page cache? > > > > Hi Balbir, > > > > Yes, in the normal page lifecycle, uncharge is done in page free time. > > But in memory error handling case, in-use pages (i.e. swap cache and page > > cache) are removed from normal path and they don't pass page freeing code. > > So I think that this change is to keep the consistent charging for such a case. > > I agree we should uncharge, but looking at the API name, it seems to > be for kmem pages, why are we not using mem_cgroup_uncharge()? Am I missing > something? Thank you for pointing out. Actually I had the same question and this surely looks strange. But simply calling mem_cgroup_uncharge() here doesn't work because it assumes that page_refcount(p) == 0, which is not true in hwpoison context. We need some other clearer way or at least some justifying comment about why this is ok. - Naoya