bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/9] memcg: make rstat flushing irq and sleep
@ 2023-03-28 22:16 Yosry Ahmed
  2023-03-28 22:16 ` [PATCH v2 1/9] cgroup: rename cgroup_rstat_flush_"irqsafe" to "atomic" Yosry Ahmed
                   ` (8 more replies)
  0 siblings, 9 replies; 40+ messages in thread
From: Yosry Ahmed @ 2023-03-28 22:16 UTC (permalink / raw)
  To: Tejun Heo, Josef Bacik, Jens Axboe, Zefan Li, Johannes Weiner,
	Michal Hocko, Roman Gushchin, Shakeel Butt, Muchun Song,
	Andrew Morton, Michal Koutný
  Cc: Vasily Averin, cgroups, linux-block, linux-kernel, linux-mm, bpf,
	Yosry Ahmed

Patches 1 and 2 are cleanups requested during reviews of prior versions
of this series.

Patch 3 makes sure we never try to flush from within an irq context, and
patch 4 adds a WARN_ON_ONCE() to make sure we catch any violations.

Patches 5 to 8 introduce separate variants of mem_cgroup_flush_stats()
for atomic and non-atomic flushing, and make sure we only flush the
stats atomically when necessary.

Patch 9 is a slightly tangential optimization that limits the work done
by rstat flushing in some scenarios.

v1 -> v2:
- Added more context in patch 4's commit log.
- Added atomic_read() before atomic_xchg() in patch 5 to avoid
  needlessly locking the cache line (Shakeel).
- Refactored patch 6: added a common helper, do_flush_stats(), for
  mem_cgroup_flush_stats{_atomic}() (Johannes).
- Renamed mem_cgroup_flush_stats_ratelimited() to
  mem_cgroup_flush_stats_atomic_ratelimited() in patch 6. It is restored
  in patch 7, but this maintains consistency (Johannes).
- Added line break to keep the lock section visually separated in patch
  7 (Johannes).

RFC -> v1:
- Dropped patch 1 that attempted to make the global rstat lock a non-irq
  lock, will follow up on that separetly (Shakeel).
- Dropped stats_flush_lock entirely, replaced by an atomic (Johannes).
- Renamed cgroup_rstat_flush_irqsafe() to cgroup_rstat_flush_atomic()
  instead of removing it (Johannes).
- Added a patch to rename mem_cgroup_flush_stats_delayed() to
  mem_cgroup_flush_stats_ratelimited() (Johannes).
- Separate APIs for flushing memcg stats in atomic and non-atomic
  contexts instead of a boolean argument (Johannes).
- Added patches 3 & 4 to make sure we never flush from irq context
  (Shakeel & Johannes).

Yosry Ahmed (9):
  cgroup: rename cgroup_rstat_flush_"irqsafe" to "atomic"
  memcg: rename mem_cgroup_flush_stats_"delayed" to "ratelimited"
  memcg: do not flush stats in irq context
  cgroup: rstat: add WARN_ON_ONCE() if flushing outside task context
  memcg: replace stats_flush_lock with an atomic
  memcg: sleep during flushing stats in safe contexts
  workingset: memcg: sleep when flushing stats in workingset_refault()
  vmscan: memcg: sleep when flushing stats during reclaim
  memcg: do not modify rstat tree for zero updates

 include/linux/cgroup.h     |  2 +-
 include/linux/memcontrol.h |  9 ++++-
 kernel/cgroup/rstat.c      |  6 ++-
 mm/memcontrol.c            | 78 ++++++++++++++++++++++++++++++--------
 mm/workingset.c            |  5 ++-
 5 files changed, 78 insertions(+), 22 deletions(-)

-- 
2.40.0.348.gf938b09366-goog


^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2023-04-03 20:40 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-28 22:16 [PATCH v2 0/9] memcg: make rstat flushing irq and sleep Yosry Ahmed
2023-03-28 22:16 ` [PATCH v2 1/9] cgroup: rename cgroup_rstat_flush_"irqsafe" to "atomic" Yosry Ahmed
2023-03-28 22:16 ` [PATCH v2 2/9] memcg: rename mem_cgroup_flush_stats_"delayed" to "ratelimited" Yosry Ahmed
2023-03-29 11:56   ` Michal Hocko
2023-03-28 22:16 ` [PATCH v2 3/9] memcg: do not flush stats in irq context Yosry Ahmed
2023-03-29 11:58   ` Michal Hocko
2023-03-28 22:16 ` [PATCH v2 4/9] cgroup: rstat: add WARN_ON_ONCE() if flushing outside task context Yosry Ahmed
2023-03-29 11:22   ` Michal Hocko
2023-03-29 18:41     ` Yosry Ahmed
2023-03-29 19:20       ` Shakeel Butt
2023-03-30  7:06         ` Michal Hocko
2023-03-30  7:13           ` Yosry Ahmed
2023-03-30  7:49             ` Michal Hocko
2023-03-30  8:06               ` Yosry Ahmed
2023-03-30  8:14                 ` Michal Hocko
2023-03-30  8:19                   ` Yosry Ahmed
2023-03-30  8:39                     ` Michal Hocko
2023-03-30  8:53                       ` Yosry Ahmed
2023-03-31 11:02                         ` Michal Hocko
2023-03-31 19:03                           ` Yosry Ahmed
2023-04-03  8:38                             ` Michal Hocko
2023-04-03 20:39                               ` Yosry Ahmed
2023-03-28 22:16 ` [PATCH v2 5/9] memcg: replace stats_flush_lock with an atomic Yosry Ahmed
2023-03-28 22:22   ` Shakeel Butt
2023-03-29 15:58   ` Michal Hocko
2023-03-29 18:45     ` Yosry Ahmed
2023-03-28 22:16 ` [PATCH v2 6/9] memcg: sleep during flushing stats in safe contexts Yosry Ahmed
2023-03-30  7:35   ` Michal Hocko
2023-03-28 22:16 ` [PATCH v2 7/9] workingset: memcg: sleep when flushing stats in workingset_refault() Yosry Ahmed
2023-03-30  7:39   ` Michal Hocko
2023-03-30  7:42     ` Yosry Ahmed
2023-03-30  7:50       ` Michal Hocko
2023-03-30  7:55         ` Yosry Ahmed
2023-03-28 22:16 ` [PATCH v2 8/9] vmscan: memcg: sleep when flushing stats during reclaim Yosry Ahmed
2023-03-30  7:40   ` Michal Hocko
2023-03-30  7:44     ` Yosry Ahmed
2023-03-30  7:52       ` Michal Hocko
2023-03-30  7:54         ` Yosry Ahmed
2023-03-28 22:16 ` [PATCH v2 9/9] memcg: do not modify rstat tree for zero updates Yosry Ahmed
2023-03-30  7:43   ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).