Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1008049pxu; Mon, 26 Oct 2020 01:23:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwO5KaDggo4o1KKzz+t3guvU2eZeziJ5j7upVRGZVyRG45iAmL41QGegXcYaeVd687IdbtT X-Received: by 2002:a05:6402:135a:: with SMTP id y26mr14601908edw.114.1603700583032; Mon, 26 Oct 2020 01:23:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603700583; cv=none; d=google.com; s=arc-20160816; b=YxDjV7to0Lb0bodwolDYEhCTQCo8MOeFncxzUpSGJvvKSIYR0FxrVOn+9b2Ei2NvJN vnaH+5NYvGZAhp+cBq1Nrm+DPiKewPy93gAR7ZBXBp8W4UP9diRSZBwHfO/T5ihlHqni lgErU2s+fbFAtk3Gil4tEfYI0V12v+ues7wHVawb6yiaORwacydX2/vvfnyVKSqYPuY4 UQENmAwk1OPO+hopLLHE5qrOuSNK36RPN4HlAiAXk2zIbgpfuaPZVDOyxXMErF/WhDmd HInMxAB8bPO1odfqrp7r0BOwtwiiDn6gZu5YJMDmoVXlL0Wfy8jvAxwAaDFzZ238RwD1 xo5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:in-reply-to :reply-to:subject:cc:to:from:user-agent:references; bh=K7j95HziOJROgktiz5isrDqOzAuJfYKkDhDYKQJ4UpM=; b=azZlAsdPhloIptKorx4k1NYbT2uHMC1MFZfk+2lXHEaB25E3Ej6LRoGxXv77Emi4cb tE6fLJCS8L4IJVvmBj1eoCBy3/XDtpwHp2i3NeJqi0rYaUpDjpCjgA4S+Vr9XDeKCbCY qV+AZPs3lx3s0yjILDTsEpgO562NIFOKDIJd+hKODnOijcjOyk85uFigW0FH61tSnfm+ 3AygeKIsOpv708Jt5hBNIgYInWyRnkc1lPbGvgXdLe/99vN2QLipw3Wu/ik1z5R+TZEw MFpq6IpVCfYMwz4rLRqDbWb+kFk5YUYQv7vkfYzAGqjLkJcZdPLcEyqqgyoYsJaFAjAx H2vg== 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 v13si9522636edl.492.2020.10.26.01.22.40; Mon, 26 Oct 2020 01:23:03 -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 S1421646AbgJZHcm (ORCPT + 99 others); Mon, 26 Oct 2020 03:32:42 -0400 Received: from mx2.suse.de ([195.135.220.15]:60016 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728469AbgJZHcm (ORCPT ); Mon, 26 Oct 2020 03:32:42 -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 7C1B0AD07; Mon, 26 Oct 2020 07:32:40 +0000 (UTC) References: <87sga6vizp.fsf@suse.de> <20201022122858.8638-1-rpalethorpe@suse.com> <20201022172508.GF300658@carbon.dhcp.thefacebook.com> <20201023004026.GG300658@carbon.dhcp.thefacebook.com> User-agent: mu4e 1.4.13; emacs 27.1 From: Richard Palethorpe To: Roman Gushchin Cc: Shakeel Butt , Linux MM , LKML , LTP List , "Johannes Weiner" , Andrew Morton , Christoph Lameter , Michal Hocko , Tejun Heo , Vlastimil Babka Subject: Re: [PATCH v4] mm: memcg/slab: Stop reparented obj_cgroups from charging root Reply-To: rpalethorpe@suse.de In-reply-to: <20201023004026.GG300658@carbon.dhcp.thefacebook.com> Date: Mon, 26 Oct 2020 07:32:39 +0000 Message-ID: <87d015v3vs.fsf@suse.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Roman, Roman Gushchin writes: > On Thu, Oct 22, 2020 at 04:59:56PM -0700, Shakeel Butt wrote: >> On Thu, Oct 22, 2020 at 10:25 AM Roman Gushchin wrote: >> > >> [snip] >> > > >> > > Since bf4f059954dc ("mm: memcg/slab: obj_cgroup API") is in 5.9, I >> > > think we can take this patch for 5.9 and 5.10 but keep Roman's cleanup >> > > for 5.11. >> > > >> > > What does everyone think? >> > >> > I think we should use the link to the root approach both for stable backports >> > and for 5.11+, to keep them in sync. The cleanup (always charging the root cgroup) >> > is not directly related to this problem, and we can keep it for 5.11+ only. >> > >> > Thanks! >> >> Roman, can you send the signed-off patch for the root linking for >> use_hierarchy=0? > > Sure, here we are. > > Thanks! > > -- > > From 19d66695f0ef1bf1ef7c51073ab91d67daa91362 Mon Sep 17 00:00:00 2001 > From: Roman Gushchin > Date: Thu, 22 Oct 2020 17:12:32 -0700 > Subject: [PATCH] mm: memcg: link page counters to root if use_hierarchy is false > > Richard reported a warning which can be reproduced by running the LTP > madvise6 test (cgroup v1 in the non-hierarchical mode should be used): > > [ 9.841552] ------------[ cut here ]------------ > [ 9.841788] WARNING: CPU: 0 PID: 12 at mm/page_counter.c:57 page_counter_uncharge (mm/page_counter.c:57 mm/page_counter.c:50 mm/page_counter.c:156) > [ 9.841982] Modules linked in: > [ 9.842072] CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.9.0-rc7-22-default #77 > [ 9.842266] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-48-gd9c812d-rebuilt.opensuse.org 04/01/2014 > [ 9.842571] Workqueue: events drain_local_stock > [ 9.842750] RIP: 0010:page_counter_uncharge (mm/page_counter.c:57 mm/page_counter.c:50 mm/page_counter.c:156) > [ 9.842894] Code: 0f c1 45 00 4c 29 e0 48 89 ef 48 89 c3 48 89 c6 e8 2a fe ff ff 48 85 db 78 10 48 8b 6d 28 48 85 ed 75 d8 5b 5d 41 5c 41 5d c3 <0f> 0b eb ec 90 e8 4b f9 88 2a 48 8b 17 48 39 d6 72 41 41 54 49 89 > [ 9.843438] RSP: 0018:ffffb1c18006be28 EFLAGS: 00010086 > [ 9.843585] RAX: ffffffffffffffff RBX: ffffffffffffffff RCX: ffff94803bc2cae0 > [ 9.843806] RDX: 0000000000000001 RSI: ffffffffffffffff RDI: ffff948007d2b248 > [ 9.844026] RBP: ffff948007d2b248 R08: ffff948007c58eb0 R09: ffff948007da05ac > [ 9.844248] R10: 0000000000000018 R11: 0000000000000018 R12: 0000000000000001 > [ 9.844477] R13: ffffffffffffffff R14: 0000000000000000 R15: ffff94803bc2cac0 > [ 9.844696] FS: 0000000000000000(0000) GS:ffff94803bc00000(0000) knlGS:0000000000000000 > [ 9.844915] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > [ 9.845096] CR2: 00007f0579ee0384 CR3: 000000002cc0a000 CR4: 00000000000006f0 > [ 9.845319] Call Trace: > [ 9.845429] __memcg_kmem_uncharge (mm/memcontrol.c:3022) > [ 9.845582] drain_obj_stock (./include/linux/rcupdate.h:689 mm/memcontrol.c:3114) > [ 9.845684] drain_local_stock (mm/memcontrol.c:2255) > [ 9.845789] process_one_work (./arch/x86/include/asm/jump_label.h:25 ./include/linux/jump_label.h:200 ./include/trace/events/workqueue.h:108 kernel/workqueue.c:2274) > [ 9.845898] worker_thread (./include/linux/list.h:282 kernel/workqueue.c:2416) > [ 9.846034] ? process_one_work (kernel/workqueue.c:2358) > [ 9.846162] kthread (kernel/kthread.c:292) > [ 9.846271] ? __kthread_bind_mask (kernel/kthread.c:245) > [ 9.846420] ret_from_fork (arch/x86/entry/entry_64.S:300) > [ 9.846531] ---[ end trace 8b5647c1eba9d18a ]--- > > The problem occurs because in the non-hierarchical mode non-root page > counters are not linked to root page counters, so the charge is not > propagated to the root memory cgroup. > > After the removal of the original memory cgroup and reparenting of the > object cgroup, the root cgroup might be uncharged by draining a objcg I think it is worth mentioning that reparenting will always be to root to avoid any confusion about what may happen with deeper, broken, hierarchies. > stock, for example. It leads to an eventual underflow of the charge > and triggers a warning. > > Fix it by linking all page counters to corresponding root page > counters in the non-hierarchical mode. > > The patch doesn't affect how the hierarchical mode is working, > which is the only sane and truly supported mode now. > > Thanks to Richard for reporting, debugging and providing an > alternative version of the fix! > > Reported-by: ltp@lists.linux.it > Debugged-by: Richard Palethorpe Much appreciated, thanks! -- Thank you, Richard.