From: Yosry Ahmed <yosryahmed@google.com> To: Andrew Morton <akpm@linux-foundation.org> Cc: "Johannes Weiner" <hannes@cmpxchg.org>, "Michal Hocko" <mhocko@kernel.org>, "Roman Gushchin" <roman.gushchin@linux.dev>, "Shakeel Butt" <shakeelb@google.com>, "Muchun Song" <muchun.song@linux.dev>, "Ivan Babrou" <ivan@cloudflare.com>, "Tejun Heo" <tj@kernel.org>, "Michal Koutný" <mkoutny@suse.com>, "Waiman Long" <longman@redhat.com>, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, "Yosry Ahmed" <yosryahmed@google.com> Subject: [PATCH v4 0/4] memcg: non-unified flushing for userspace stats Date: Thu, 31 Aug 2023 16:56:07 +0000 [thread overview] Message-ID: <20230831165611.2610118-1-yosryahmed@google.com> (raw) Most memcg flushing contexts using "unified" flushing, where only one flusher is allowed at a time (others skip), and all flushers need to flush the entire tree. This works well with high concurrency, which mostly comes from in-kernel flushers (e.g. reclaim, refault, ..). For userspace reads, unified flushing leads to non-deterministic stats staleness and reading cost. This series clarifies and documents the differences between unified and non-unified flushing (patches 1 & 2), then opts userspace reads out of unified flushing (patch 3). This patch series is a follow up on the discussion in [1]. That was a patch that proposed that userspace reads wait for ongoing unified flushers to complete before returning. There were concerns about the latency that this introduces to userspace reads, especially with ongoing reports of expensive stat reads even with unified flushing. Hence, this series follows a different approach, by opting userspace reads out of unified flushing completely. The cost of userspace reads are now determinstic, and depend on the size of the subtree being read. This should fix both the *sometimes* expensive reads (due to flushing the entire tree) and occasional staless (due to skipping flushing). I attempted to remove unified flushing completely, but noticed that in-kernel flushers with high concurrency (e.g. hundreds of concurrent reclaimers). This sort of concurrency is not expected from userspace reads. More details about testing and some numbers in the last patch's changelog. v4 -> v5: - Fixed build error in the last patch with W=1 because of a missed 'static'. v4: https://lore.kernel.org/lkml/20230830175335.1536008-1-yosryahmed@google.com/ Yosry Ahmed (4): mm: memcg: properly name and document unified stats flushing mm: memcg: add a helper for non-unified stats flushing mm: memcg: let non-unified root stats flushes help unified flushes mm: memcg: use non-unified stats flushing for userspace reads include/linux/memcontrol.h | 8 +-- mm/memcontrol.c | 106 +++++++++++++++++++++++++++---------- mm/vmscan.c | 2 +- mm/workingset.c | 4 +- 4 files changed, 85 insertions(+), 35 deletions(-) -- 2.42.0.rc2.253.gd59a3bf2b4-goog
WARNING: multiple messages have this Message-ID (diff)
From: Yosry Ahmed <yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> To: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> Cc: "Johannes Weiner" <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>, "Michal Hocko" <mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>, "Roman Gushchin" <roman.gushchin-fxUVXftIFDnyG1zEObXtfA@public.gmane.org>, "Shakeel Butt" <shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>, "Muchun Song" <muchun.song-fxUVXftIFDnyG1zEObXtfA@public.gmane.org>, "Ivan Babrou" <ivan-lDpJ742SOEtZroRs9YW3xA@public.gmane.org>, "Tejun Heo" <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>, "Michal Koutný" <mkoutny-IBi9RG/b67k@public.gmane.org>, "Waiman Long" <longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "Yosry Ahmed" <yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> Subject: [PATCH v4 0/4] memcg: non-unified flushing for userspace stats Date: Thu, 31 Aug 2023 16:56:07 +0000 [thread overview] Message-ID: <20230831165611.2610118-1-yosryahmed@google.com> (raw) Most memcg flushing contexts using "unified" flushing, where only one flusher is allowed at a time (others skip), and all flushers need to flush the entire tree. This works well with high concurrency, which mostly comes from in-kernel flushers (e.g. reclaim, refault, ..). For userspace reads, unified flushing leads to non-deterministic stats staleness and reading cost. This series clarifies and documents the differences between unified and non-unified flushing (patches 1 & 2), then opts userspace reads out of unified flushing (patch 3). This patch series is a follow up on the discussion in [1]. That was a patch that proposed that userspace reads wait for ongoing unified flushers to complete before returning. There were concerns about the latency that this introduces to userspace reads, especially with ongoing reports of expensive stat reads even with unified flushing. Hence, this series follows a different approach, by opting userspace reads out of unified flushing completely. The cost of userspace reads are now determinstic, and depend on the size of the subtree being read. This should fix both the *sometimes* expensive reads (due to flushing the entire tree) and occasional staless (due to skipping flushing). I attempted to remove unified flushing completely, but noticed that in-kernel flushers with high concurrency (e.g. hundreds of concurrent reclaimers). This sort of concurrency is not expected from userspace reads. More details about testing and some numbers in the last patch's changelog. v4 -> v5: - Fixed build error in the last patch with W=1 because of a missed 'static'. v4: https://lore.kernel.org/lkml/20230830175335.1536008-1-yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org/ Yosry Ahmed (4): mm: memcg: properly name and document unified stats flushing mm: memcg: add a helper for non-unified stats flushing mm: memcg: let non-unified root stats flushes help unified flushes mm: memcg: use non-unified stats flushing for userspace reads include/linux/memcontrol.h | 8 +-- mm/memcontrol.c | 106 +++++++++++++++++++++++++++---------- mm/vmscan.c | 2 +- mm/workingset.c | 4 +- 4 files changed, 85 insertions(+), 35 deletions(-) -- 2.42.0.rc2.253.gd59a3bf2b4-goog
next reply other threads:[~2023-08-31 16:56 UTC|newest] Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-08-31 16:56 Yosry Ahmed [this message] 2023-08-31 16:56 ` [PATCH v4 0/4] memcg: non-unified flushing for userspace stats Yosry Ahmed 2023-08-31 16:56 ` [PATCH v4 1/4] mm: memcg: properly name and document unified stats flushing Yosry Ahmed 2023-09-04 14:44 ` Michal Hocko 2023-09-04 14:44 ` Michal Hocko 2023-09-05 15:55 ` Yosry Ahmed 2023-09-05 15:55 ` Yosry Ahmed 2023-08-31 16:56 ` [PATCH v4 2/4] mm: memcg: add a helper for non-unified " Yosry Ahmed 2023-08-31 16:56 ` Yosry Ahmed 2023-09-04 14:45 ` Michal Hocko 2023-09-04 14:45 ` Michal Hocko 2023-08-31 16:56 ` [PATCH v4 3/4] mm: memcg: let non-unified root stats flushes help unified flushes Yosry Ahmed 2023-08-31 16:56 ` Yosry Ahmed 2023-09-04 14:50 ` Michal Hocko 2023-09-04 15:29 ` Michal Koutný 2023-09-04 15:29 ` Michal Koutný 2023-09-04 15:41 ` Michal Hocko 2023-09-04 15:41 ` Michal Hocko 2023-09-05 14:10 ` Michal Koutný 2023-09-05 14:10 ` Michal Koutný 2023-09-05 15:54 ` Yosry Ahmed 2023-09-05 15:54 ` Yosry Ahmed 2023-09-05 16:07 ` Michal Koutný 2023-09-05 16:07 ` Michal Koutný 2023-09-12 11:03 ` Michal Hocko 2023-09-12 11:03 ` Michal Hocko 2023-08-31 16:56 ` [PATCH v4 4/4] mm: memcg: use non-unified stats flushing for userspace reads Yosry Ahmed 2023-08-31 16:56 ` Yosry Ahmed 2023-09-04 15:15 ` Michal Hocko 2023-09-04 15:15 ` Michal Hocko 2023-09-05 15:57 ` Yosry Ahmed 2023-09-05 15:57 ` Yosry Ahmed 2023-09-08 0:52 ` Wei Xu 2023-09-08 0:52 ` Wei Xu 2023-09-08 1:02 ` Ivan Babrou 2023-09-08 1:02 ` Ivan Babrou 2023-09-08 1:11 ` Yosry Ahmed 2023-09-08 1:11 ` Yosry Ahmed 2023-09-11 13:11 ` Michal Hocko 2023-09-11 19:15 ` Wei Xu 2023-09-11 19:15 ` Wei Xu 2023-09-11 19:34 ` Michal Hocko 2023-09-11 19:34 ` Michal Hocko 2023-09-11 20:01 ` Wei Xu 2023-09-11 20:21 ` Tejun Heo 2023-09-11 20:28 ` Yosry Ahmed 2023-09-11 20:28 ` Yosry Ahmed 2023-09-12 11:03 ` Michal Hocko 2023-09-12 11:03 ` Michal Hocko 2023-09-12 11:09 ` Yosry Ahmed 2023-09-12 11:09 ` Yosry Ahmed 2023-08-31 17:18 ` [PATCH v4 0/4] memcg: non-unified flushing for userspace stats Waiman Long 2023-08-31 17:18 ` Waiman Long
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230831165611.2610118-1-yosryahmed@google.com \ --to=yosryahmed@google.com \ --cc=akpm@linux-foundation.org \ --cc=cgroups@vger.kernel.org \ --cc=hannes@cmpxchg.org \ --cc=ivan@cloudflare.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=longman@redhat.com \ --cc=mhocko@kernel.org \ --cc=mkoutny@suse.com \ --cc=muchun.song@linux.dev \ --cc=roman.gushchin@linux.dev \ --cc=shakeelb@google.com \ --cc=tj@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.