Re: [-mm] Add an owner to the mm_struct (v6)

Previous thread: [rfc] SLQB: YASA by Nick Piggin on Thursday, April 3, 2008 - 3:25 am. (16 messages)

Next thread: Re: suspend by Stefan Schweizer on Thursday, April 3, 2008 - 3:42 am. (5 messages)
To: Paul Menage <menage@...>, Pavel Emelianov <xemul@...>
Cc: Hugh Dickins <hugh@...>, Sudhir Kumar <skumar@...>, YAMAMOTO Takashi <yamamoto@...>, <lizf@...>, <linux-kernel@...>, <taka@...>, <linux-mm@...>, David Rientjes <rientjes@...>, Balbir Singh <balbir@...>, Andrew Morton <akpm@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>
Date: Thursday, April 3, 2008 - 3:30 am

Changelog v5
------------
Remove the hooks for .owner from init_task.h and move it to init/main.c

Changelog v4
------------
1. Release rcu_read_lock() after acquiring task_lock(). Also get a reference
to the task_struct
2. Change cgroup mm_owner_changed callback to callback only if the
cgroup of old and new task is different and to pass the old and new
cgroups instead of task pointers
3. Port the patch to 2.6.25-rc8-mm1

Changelog v3
------------

1. Add mm->owner change callbacks using cgroups

This patch removes the mem_cgroup member from mm_struct and instead adds
an owner. This approach was suggested by Paul Menage. The advantage of
this approach is that, once the mm->owner is known, using the subsystem
id, the cgroup can be determined. It also allows several control groups
that are virtually grouped by mm_struct, to exist independent of the memory
controller i.e., without adding mem_cgroup's for each controller,
to mm_struct.

A new config option CONFIG_MM_OWNER is added and the memory resource
controller selects this config option.

This patch also adds cgroup callbacks to notify subsystems when mm->owner
changes. The mm_cgroup_changed callback is called with the task_lock()
of the new task held and is called just prior to changing the mm->owner.

I am indebted to Paul Menage for the several reviews of this patchset
and helping me make it lighter and simpler.

This patch was tested on a powerpc box, it was compiled with both the
MM_OWNER config turned on and off.

Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
---

fs/exec.c | 1
include/linux/cgroup.h | 15 ++++++++
include/linux/init_task.h | 1
include/linux/memcontrol.h | 16 +--------
include/linux/mm_types.h | 5 +-
include/linux/sched.h | 13 +++++++
init/Kconfig | 15 ++++++++
init/main.c | 1
kernel/cgroup.c | 30 +++++++++++++++++
kernel/exit.c | 77...

To: Balbir Singh <balbir@...>
Cc: Pavel Emelianov <xemul@...>, Hugh Dickins <hugh@...>, Sudhir Kumar <skumar@...>, YAMAMOTO Takashi <yamamoto@...>, <lizf@...>, <linux-kernel@...>, <taka@...>, <linux-mm@...>, David Rientjes <rientjes@...>, Andrew Morton <akpm@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>
Date: Thursday, April 3, 2008 - 11:45 am

Even better, maybe just pass in the relevant cgroup_subsys_state

These get/put calls are now unwanted?

Could you also add comments in mm_need_new_owner(), in particular the
reason for checking for delay_group_leader() ?

Paul
--

To: Paul Menage <menage@...>
Cc: Pavel Emelianov <xemul@...>, Hugh Dickins <hugh@...>, Sudhir Kumar <skumar@...>, YAMAMOTO Takashi <yamamoto@...>, <lizf@...>, <linux-kernel@...>, <taka@...>, <linux-mm@...>, David Rientjes <rientjes@...>, Andrew Morton <akpm@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>
Date: Thursday, April 3, 2008 - 1:15 pm

Is that better than passing the cgroups? All the callbacks I see usually pass
either task_struct or cgroup. Won't it be better, consistent use of API to pass

Yep, will do

--
Warm Regards,
Balbir Singh
Linux Technology Center
IBM, ISTL
--

To: <balbir@...>
Cc: Pavel Emelianov <xemul@...>, Hugh Dickins <hugh@...>, Sudhir Kumar <skumar@...>, YAMAMOTO Takashi <yamamoto@...>, <lizf@...>, <linux-kernel@...>, <taka@...>, <linux-mm@...>, David Rientjes <rientjes@...>, Andrew Morton <akpm@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>
Date: Thursday, April 3, 2008 - 1:17 pm

I have a long term plan to try to divorce the subsystems from having
to worry too much about actual control groups where possible.

But I guess that for consistency with the current API, passing in the
cgroup is OK.

Paul
--

Previous thread: [rfc] SLQB: YASA by Nick Piggin on Thursday, April 3, 2008 - 3:25 am. (16 messages)

Next thread: Re: suspend by Stefan Schweizer on Thursday, April 3, 2008 - 3:42 am. (5 messages)