lkml.org 
[lkml]   [2018]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 0/2] mm->owner to mm->memcg fixes
On Thu, 24 May 2018 13:10:02 +0200 Michal Hocko <mhocko@kernel.org> wrote:

> I would really prefer and appreciate a repost with all the fixes folded
> in.

[2/2]

From: Andrew Morton <akpm@linux-foundation.org>
Subject: mm/memcontrol.c: add mem_cgroup_from_task() as a local helper

Factor out some commonly-occurring code.

Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

mm/memcontrol.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff -puN mm/memcontrol.c~mm-memcontrolc-add-mem_cgroup_from_task-as-a-local-helper mm/memcontrol.c
--- a/mm/memcontrol.c~mm-memcontrolc-add-mem_cgroup_from_task-as-a-local-helper
+++ a/mm/memcontrol.c
@@ -664,6 +664,11 @@ static void memcg_check_events(struct me
}
}

+static inline struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p)
+{
+ return mem_cgroup_from_css(task_css(p, memory_cgrp_id));
+}
+
struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm)
{
struct mem_cgroup *memcg = NULL;
@@ -1011,7 +1016,7 @@ bool task_in_mem_cgroup(struct task_stru
* killed to prevent needlessly killing additional tasks.
*/
rcu_read_lock();
- task_memcg = mem_cgroup_from_css(task_css(task, memory_cgrp_id));
+ task_memcg = mem_cgroup_from_task(task);
css_get(&task_memcg->css);
rcu_read_unlock();
}
@@ -4836,7 +4841,7 @@ static int mem_cgroup_can_attach(struct
if (!move_flags)
return 0;

- from = mem_cgroup_from_css(task_css(p, memory_cgrp_id));
+ from = mem_cgroup_from_task(p);

VM_BUG_ON(from == memcg);

@@ -5887,7 +5892,7 @@ void mem_cgroup_sk_alloc(struct sock *sk
}

rcu_read_lock();
- memcg = mem_cgroup_from_css(task_css(current, memory_cgrp_id));
+ memcg = mem_cgroup_from_task(current);
if (memcg == root_mem_cgroup)
goto out;
if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && !memcg->tcpmem_active)
_
\
 
 \ /
  Last update: 2018-05-24 23:18    [W:0.235 / U:1.928 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site