Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1324510pxu; Fri, 16 Oct 2020 09:11:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfm1DwIo3NxH3Tt1KEz6+zXsViQBxmOnPkGKb2XVMtGcdRuOFlXpILC8z6pN+yNm/9f6Yj X-Received: by 2002:a50:9b1d:: with SMTP id o29mr4987129edi.56.1602864707855; Fri, 16 Oct 2020 09:11:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602864706; cv=none; d=google.com; s=arc-20160816; b=NSRbvUZHOWNwyTgSLPbcUsu8Vxp8nj0SvfrdDUgxjKTTWKt/Om5aFhLjJEhnH3jSu6 4DZut86gTpNCqLFS2D3f3RANOpb5oUHWPYgjXJIh7H8ouf+59stbkSUXqZPFewCK3wHm j7sTZK9/MAGUL6EM7H5mVBaz17bM4l2ZSWPXJzHXOGSEji0gFQM5q1gf76QWEfFkODOb Uc48N2qMXFdXRC9ht9tZzt0Yce3o7sl1/vFbulWw8svWZr4KazZlxXwBu4BX0G7ZCs3b LDxV2+AfhYppiUrm8ydBm/iCktRlKb/RwFVXmXmblZPVlMCyNvQ4qYBYSXCOVtr8fgYb cw1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:in-reply-to:reply-to:subject:cc:to:from:user-agent :references; bh=ynMiPDjzLo7LkyV4mes+H30xvMJpQGecyjAms1Zp21I=; b=bLhIxDNGhXE73sArFSzLA8hY6el3sgXxf3CRIa9u64deBRKeaO0zbi2exsnJb/gj2s kscZ7wwMaCb7GAZCQusNBWlHvciBZpuNPVhKIediempH6qxMhrs5OlHnID+5YmiPRJNJ h8r+jicx1idbsiiF3uk5bAFF4GHGuO3WSkpFty/MPgiF/PDLQqdDy9ajFLfstiZLd03O v7rwvt4VhcxIh1IK7qyJzXQcerHgfWUAZ+08+gNRqFcEmTGJyzv4PBEhB16ztkS5v7ba 3YOZW5fshC6L/drv4hd71sM9sYi57La/nJILK8WbUt9VTfTYQrhbFhoL76pegzYtr5Ek f5Lw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f4si2008691ejw.642.2020.10.16.09.11.23; Fri, 16 Oct 2020 09:11:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406694AbgJPPFY convert rfc822-to-8bit (ORCPT + 99 others); Fri, 16 Oct 2020 11:05:24 -0400 Received: from mx2.suse.de ([195.135.220.15]:55660 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406455AbgJPPFY (ORCPT ); Fri, 16 Oct 2020 11:05:24 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 594B3B1AB; Fri, 16 Oct 2020 15:05:22 +0000 (UTC) References: <20201014190749.24607-1-rpalethorpe@suse.com> <20201016094702.GA95052@blackbook> <87sgaesba0.fsf@suse.de> User-agent: mu4e 1.4.13; emacs 27.1 From: Richard Palethorpe To: Michal =?utf-8?Q?Koutn=C3=BD?= Cc: Roman Gushchin , ltp@lists.linux.it, Johannes Weiner , Andrew Morton , "Shakeel Butt" , Christoph Lameter , Michal Hocko , Tejun Heo , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root Reply-To: rpalethorpe@suse.de In-reply-to: <87sgaesba0.fsf@suse.de> Date: Fri, 16 Oct 2020 16:05:21 +0100 Message-ID: <87pn5irz2m.fsf@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Richard Palethorpe writes: > Hello Michal, > > Michal Koutný writes: > >> Hello. >> >> On Wed, Oct 14, 2020 at 08:07:49PM +0100, Richard Palethorpe wrote: >>> SLAB objects which outlive their memcg are moved to their parent >>> memcg where they may be uncharged. However if they are moved to the >>> root memcg, uncharging will result in negative page counter values as >>> root has no page counters. >> Why do you think those are reparented objects? If those are originally >> charged in a non-root cgroup, then the charge value should be propagated up the >> hierarchy, including root memcg, so if they're later uncharged in root >> after reparenting, it should still break even. (Or did I miss some stock >> imbalance?) > > I traced it and can see they are reparented objects and that the root > groups counters are zero (or negative if I run madvise06 multiple times) > before a drain takes place. I'm guessing this is because the root group > has 'use_hierachy' set to false so that the childs page_counter parents > are set to NULL. However I will check, because I'm not sure about > either. Yes, it appears that use_hierarchy=0 which is probably because the test mounts cgroup v1, creates a child group within that and does not set use_hierarchy on the root. On v2 root always has use_hierarchy enabled. > >> >> (But the patch seems justifiable to me as objects (not)charged directly to >> root memcg may be incorrectly uncharged.) >> >> Thanks, >> Michal I'm don't know if that could happen without reparenting. I suppose if use_hierarchy=1 then actually this patch will result in root being overcharged, so perhaps it should also check for use_hierarchy? -- Thank you, Richard.