Message ID | 20200312164137.GA1753625@chrisdown.name (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | mm, memcg: Bypass high reclaim iteration for cgroup hierarchy root | expand |
On Thu, 12 Mar 2020 16:41:37 +0000 Chris Down <chris@chrisdown.name> wrote: > The root of the hierarchy cannot have high set, so we will never reclaim > based on it. This makes that clearer and avoids another entry. > > ... > > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -2232,7 +2232,8 @@ static void reclaim_high(struct mem_cgroup *memcg, > continue; > memcg_memory_event(memcg, MEMCG_HIGH); > try_to_free_mem_cgroup_pages(memcg, nr_pages, gfp_mask, true); > - } while ((memcg = parent_mem_cgroup(memcg))); > + } while ((memcg = parent_mem_cgroup(memcg)) && > + !mem_cgroup_is_root(memcg)); > } > > static void high_work_func(struct work_struct *work) Does someone have time to review this one? Thanks.
On Thu, Mar 12, 2020 at 04:41:37PM +0000, Chris Down wrote: > The root of the hierarchy cannot have high set, so we will never reclaim > based on it. This makes that clearer and avoids another entry. > > Signed-off-by: Chris Down <chris@chrisdown.name> > Cc: Andrew Morton <akpm@linux-foundation.org> > Cc: Johannes Weiner <hannes@cmpxchg.org> > Cc: Tejun Heo <tj@kernel.org> > Cc: linux-mm@kvack.org > Cc: cgroups@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Cc: kernel-team@fb.com This makes sense, memory.high doesn't exist on the root. And the mem_cgroup_is_root() check, a simple pointer comparison, is cheaper than reading the page_counter atomic and memcg->high (which we already know to be PAGE_COUNTER_MAX). Acked-by: Johannes Weiner <hannes@cmpxchg.org>
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 63bb6a2aab81..ab9d24a657b9 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2232,7 +2232,8 @@ static void reclaim_high(struct mem_cgroup *memcg, continue; memcg_memory_event(memcg, MEMCG_HIGH); try_to_free_mem_cgroup_pages(memcg, nr_pages, gfp_mask, true); - } while ((memcg = parent_mem_cgroup(memcg))); + } while ((memcg = parent_mem_cgroup(memcg)) && + !mem_cgroup_is_root(memcg)); } static void high_work_func(struct work_struct *work)
The root of the hierarchy cannot have high set, so we will never reclaim based on it. This makes that clearer and avoids another entry. Signed-off-by: Chris Down <chris@chrisdown.name> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Tejun Heo <tj@kernel.org> Cc: linux-mm@kvack.org Cc: cgroups@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: kernel-team@fb.com --- mm/memcontrol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)