From patchwork Wed Jan 23 22:31:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Down X-Patchwork-Id: 10778067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 400061399 for ; Wed, 23 Jan 2019 22:31:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2652C2D52C for ; Wed, 23 Jan 2019 22:31:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A2C82D53B; Wed, 23 Jan 2019 22:31:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C4902D52C for ; Wed, 23 Jan 2019 22:31:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65B978E0058; Wed, 23 Jan 2019 17:31:47 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 60A808E0047; Wed, 23 Jan 2019 17:31:47 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 548198E0058; Wed, 23 Jan 2019 17:31:47 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) by kanga.kvack.org (Postfix) with ESMTP id 2D0318E0047 for ; Wed, 23 Jan 2019 17:31:47 -0500 (EST) Received: by mail-yb1-f200.google.com with SMTP id n1so1792158ybd.10 for ; Wed, 23 Jan 2019 14:31:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=rN8KV8MqbWC2EzLp/Y3zp+83cz1GfcZCLRbo4f/oY74=; b=MUA4xkSDEKS6J3xB2CrFV8Mz/tEeuxjrxasv66BDtUJpIIu7Y4gaD26+Ka6GYEVG0S YyrRE1At+DJ54s/9LOUXFOob0S5YSY13Gu5XaToifknxJbvmgi0n6MatMZYUZxTb70fZ JZYVNqHr8/B1iVwzIuw2RnHZj3qJdGbsSkp+DslGVMLlCZ44ZPGOHtl51FVM0Ppy5fi5 PYisoUvNZaP8loklGWQaBjA2VKYgDTvzwXgrMeYqO3kZ44U8u+6MWIYHXK3xKNJiZ12t OI+I4FffbdWDOYAfxL/keovbTMU22WHaDAhTXHUgm714v5bYqTlX62eJowg6BxFfek4/ Dr/g== X-Gm-Message-State: AJcUukcJ9OeryqYMbEc3bbK+htdLxwTYxi2RdfVSX29noGytdrkmMWXw eL/80vMDts9vBxwJ5oPI/hwTrEpF6KvC7SOAT7zyxsuQjfyT0NrAq7IvkwZqdWgMjc7OpzXxf5s AlGvcdOfeQH8USrEPqb4tkYRSb7crC9fDHjsPJ9HUYzDAxrFTO8pcZoUZ2GWWpstkMwORd8XZWz 5ELo29VkTsBJqvnGq5wodhOM2sEAgDjnCVjCOVXeu5hISi4lF7Hw7WVrxkptQP+6PFqLeFrvogL GLTDbGL439VJTQiHokOt5cwnvJV47kDIlos99T428lp3mWTMTIzvKAXs0+GulZe+xhKAM3LHPZe smpmFqrHstFxtd/qmibb8K9MgG2jrKiHJ6tUt2dgdLAqvHNIaInCiNUz+MVFI4PQKp8wr5Zgqfc / X-Received: by 2002:a81:a748:: with SMTP id e69mr3886500ywh.309.1548282706814; Wed, 23 Jan 2019 14:31:46 -0800 (PST) X-Received: by 2002:a81:a748:: with SMTP id e69mr3886449ywh.309.1548282705637; Wed, 23 Jan 2019 14:31:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548282705; cv=none; d=google.com; s=arc-20160816; b=1ACIxEgUHkBcnyv7th82OMbkG3RWn2we3tCisPilyvrRyWULFx1Dz3TZaP55mFrOKo xonNDzNYDawyKSHJwmujbJVJNkHYD8M2zCtKPuHslZHQwrntORbu8GtPkBStbdjyf62V BX25hTZ1ClLtp9JtJf+k+4CvynAHOEmxl2EGbcpREbfqyM6+aejnXZnPLo9uMNdkGcoh P7jtoWlnN/o0AtMKah3jjOWU58G+7hESJ0xpAhSRY2fFei9NyGHRa0J2U6bqES9XXk6X 0veKMb2n7XY6MZLBSbaoyCK6YTtghzoMB+MLgDNB0cJkODdw+XrW30M+hoLx6WYimDIu RbGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature; bh=rN8KV8MqbWC2EzLp/Y3zp+83cz1GfcZCLRbo4f/oY74=; b=AjQGVVFTt8GxdZaRYDQmlKH7Le8oK10YufnlQG9BbqgT+oPmgIX+z1IMvgRWLDUGEA jbitTrSr+ylSbbhYLZRr41vvnASRZ6j/3JSJSdzfm2I+znp0AwhrPvAMFsQei3ocQiNu vEBKxLWxjLqD6M5fGG/5CwEl1CU6TLZCiXfngWorUnLd2MShOhVu8loK4EgNF9roBXxV fdkGWYHkcKa5kh7PzUntT4n0aOoy+xwIeowsGeZwox+dHjCUr9rqkLcUY8X9rxqU5cWj Py7OtqxZZ74KmQfacMeQWBc3IZ4VLBpXzTqizFerMveUGkvj+1gkeVKthY1HXsben3Fu 96mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=HSlGn43T; spf=pass (google.com: domain of chris@chrisdown.name designates 209.85.220.65 as permitted sender) smtp.mailfrom=chris@chrisdown.name; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p9sor3532936ywc.175.2019.01.23.14.31.45 for (Google Transport Security); Wed, 23 Jan 2019 14:31:45 -0800 (PST) Received-SPF: pass (google.com: domain of chris@chrisdown.name designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=HSlGn43T; spf=pass (google.com: domain of chris@chrisdown.name designates 209.85.220.65 as permitted sender) smtp.mailfrom=chris@chrisdown.name; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=rN8KV8MqbWC2EzLp/Y3zp+83cz1GfcZCLRbo4f/oY74=; b=HSlGn43T/DPjcpxY2PHRVu5emRtk6G3y3/2N+3fPvO4BIBYuyxKbQVal+a3OPdq0d2 FHrF4yEJD/k1F/jtCNZ9VK6eBNouqJ3EVBdmc2Ht3rBYTihQb4mXfIOaUOhIdU+TAWm2 RJGVihJfhTS9IVLmmR21QUwV6Dtasmzv3PUCI= X-Google-Smtp-Source: ALg8bN40eS4e/F5lkk+WMZkqLL0VlzoE7n63AlUxPDaTsYNruD/BT6hchGE5b3Ze/PIg84m36SDSow== X-Received: by 2002:a81:ac1e:: with SMTP id k30mr4100091ywh.513.1548282705278; Wed, 23 Jan 2019 14:31:45 -0800 (PST) Received: from localhost ([2620:10d:c091:200::4:a24b]) by smtp.gmail.com with ESMTPSA id x132sm16043434ywx.27.2019.01.23.14.31.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 23 Jan 2019 14:31:44 -0800 (PST) Date: Wed, 23 Jan 2019 17:31:44 -0500 From: Chris Down To: Andrew Morton Cc: Johannes Weiner , Michal Hocko , Tejun Heo , Roman Gushchin , Dennis Zhou , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, kernel-team@fb.com Subject: [PATCH 2/2] mm: Consider subtrees in memory.events Message-ID: <20190123223144.GA10798@chrisdown.name> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.11.2 (2019-01-07) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP memory.stat and other files already consider subtrees in their output, and we should too in order to not present an inconsistent interface. The current situation is fairly confusing, because people interacting with cgroups expect hierarchical behaviour in the vein of memory.stat, cgroup.events, and other files. For example, this causes confusion when debugging reclaim events under low, as currently these always read "0" at non-leaf memcg nodes, which frequently causes people to misdiagnose breach behaviour. The same confusion applies to other counters in this file when debugging issues. Aggregation is done at write time instead of at read-time since these counters aren't hot (unlike memory.stat which is per-page, so it does it at read time), and it makes sense to bundle this with the file notifications. After this patch, events are propagated up the hierarchy: [root@ktst ~]# cat /sys/fs/cgroup/system.slice/memory.events low 0 high 0 max 0 oom 0 oom_kill 0 [root@ktst ~]# systemd-run -p MemoryMax=1 true Running as unit: run-r251162a189fb4562b9dabfdc9b0422f5.service [root@ktst ~]# cat /sys/fs/cgroup/system.slice/memory.events low 0 high 0 max 7 oom 1 oom_kill 1 Signed-off-by: Chris Down Acked-by: Johannes Weiner To: Andrew Morton Cc: Michal Hocko Cc: Tejun Heo Cc: Roman Gushchin Cc: Dennis Zhou Cc: linux-kernel@vger.kernel.org Cc: cgroups@vger.kernel.org Cc: linux-mm@kvack.org Cc: kernel-team@fb.com Acked-by: Johannes Weiner Acked-by: Tejun Heo --- include/linux/memcontrol.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 380a212a8c52..5428b372def4 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -769,8 +769,10 @@ static inline void count_memcg_event_mm(struct mm_struct *mm, static inline void memcg_memory_event(struct mem_cgroup *memcg, enum memcg_memory_event event) { - atomic_long_inc(&memcg->memory_events[event]); - cgroup_file_notify(&memcg->events_file); + do { + atomic_long_inc(&memcg->memory_events[event]); + cgroup_file_notify(&memcg->events_file); + } while ((memcg = parent_mem_cgroup(memcg))); } static inline void memcg_memory_event_mm(struct mm_struct *mm,