Messages in this thread | | | From | Yosry Ahmed <> | Date | Tue, 22 Aug 2023 09:00:06 -0700 | Subject | Re: [PATCH 2/3] mm: memcg: add a helper for non-unified stats flushing |
| |
On Tue, Aug 22, 2023 at 6:01 AM Michal Koutný <mkoutny@suse.com> wrote: > > On Mon, Aug 21, 2023 at 08:54:57PM +0000, Yosry Ahmed <yosryahmed@google.com> wrote: > > +static void do_stats_flush(struct mem_cgroup *memcg) > > +{ > > + cgroup_rstat_flush(memcg->css.cgroup); > if(memcg == root_mem_cgroup) > atomic_set(&stats_flush_threshold, 0); > > +} > > + > > /* > > * do_unified_stats_flush - do a unified flush of memory cgroup statistics > > * > > @@ -656,7 +667,7 @@ static void do_unified_stats_flush(void) > > > > WRITE_ONCE(flush_next_time, jiffies_64 + 2*FLUSH_TIME); > > > > - cgroup_rstat_flush(root_mem_cgroup->css.cgroup); > > + do_stats_flush(root_mem_cgroup); > > > - atomic_set(&stats_flush_threshold, 0); > > atomic_set(&stats_flush_ongoing, 0); > > You may reset stats_flush_threshold to save the unified flushers some > work.
We can probably also kick FLUSH_TIME forward as well. Perhaps I can move both into do_stats_flush() then. If I understand correctly this is what you mean?
static void do_stats_flush(struct mem_cgroup *memcg) { if (mem_cgroup_is_root(memcg)) WRITE_ONCE(flush_next_time, jiffies_64 + 2*FLUSH_TIME);
cgroup_rstat_flush(memcg->css.cgroup);
if (mem_cgroup_is_root(memcg)) atomic_set(&stats_flush_threshold, 0); }
static void do_unified_stats_flush(void) { if (atomic_read(&stats_flush_ongoing) || atomic_xchg(&stats_flush_ongoing, 1)) return;
do_stats_flush(root_mem_cgroup); atomic_set(&stats_flush_ongoing, 0); }
, or simplify it further by just resetting stats_flush_threshold before we flush as well:
static void do_stats_flush(struct mem_cgroup *memcg) { /* for unified flushing, root non-unified flushing can help as well */ if (mem_cgroup_is_root(memcg)) { WRITE_ONCE(flush_next_time, jiffies_64 + 2*FLUSH_TIME); atomic_set(&stats_flush_threshold, 0); }
cgroup_rstat_flush(memcg->css.cgroup); }
static void do_unified_stats_flush(void) { if (atomic_read(&stats_flush_ongoing) || atomic_xchg(&stats_flush_ongoing, 1)) return;
do_stats_flush(root_mem_cgroup); atomic_set(&stats_flush_ongoing, 0); }
What do you think?
| |