login
Login
/
Register
Search
Header Space
Forums
News
Jobs
Blogs
Features
Man Pages
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
March
»
25
Re: [RFC][-mm] Memory controller add mm->owner
view
thread
Score:
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From:
Li Zefan <lizf@...>
To: Balbir Singh <balbir@...>
Cc: <linux-mm@...>, Hugh Dickins <hugh@...>, Sudhir Kumar <skumar@...>, YAMAMOTO Takashi <yamamoto@...>, Paul Menage <menage@...>, <linux-kernel@...>, <taka@...>, David Rientjes <rientjes@...>, Pavel Emelianov <xemul@...>, Andrew Morton <akpm@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>
Subject:
Re: [RFC][-mm] Memory controller add mm->owner
Date: Monday, March 24, 2008 - 9:26 pm
Balbir Singh wrote:
quoted text
> 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. > > The code initially assigns mm->owner to the task and then after the > thread group leader is identified. The mm->owner is changed to the thread > group leader of the task later at the end of copy_process. > > Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> > --- > > include/linux/memcontrol.h | 14 +++++++++++++- > include/linux/mm_types.h | 5 ++++- > kernel/fork.c | 4 ++++ > mm/memcontrol.c | 42 ++++++++++++++++++++++++++++++++++-------- > 4 files changed, 55 insertions(+), 10 deletions(-) > > diff -puN include/linux/mm_types.h~memory-controller-add-mm-owner include/linux/mm_types.h > --- linux-2.6.25-rc5/include/linux/mm_types.h~memory-controller-add-mm-owner 2008-03-20 13:35:09.000000000 +0530 > +++ linux-2.6.25-rc5-balbir/include/linux/mm_types.h 2008-03-20 15:11:05.000000000 +0530 > @@ -228,7 +228,10 @@ struct mm_struct { > rwlock_t ioctx_list_lock; > struct kioctx *ioctx_list; > #ifdef CONFIG_CGROUP_MEM_RES_CTLR > - struct mem_cgroup *mem_cgroup; > + struct task_struct *owner; /* The thread group leader that */ > + /* owns the mm_struct. This */ > + /* might be useful even outside */ > + /* of the config option */ > #endif > > #ifdef CONFIG_PROC_FS > diff -puN kernel/fork.c~memory-controller-add-mm-owner kernel/fork.c > --- linux-2.6.25-rc5/kernel/fork.c~memory-controller-add-mm-owner 2008-03-20 13:35:09.000000000 +0530 > +++ linux-2.6.25-rc5-balbir/kernel/fork.c 2008-03-24 18:49:29.000000000 +0530 > @@ -1357,6 +1357,10 @@ static struct task_struct *copy_process( > write_unlock_irq(&tasklist_lock); > proc_fork_connector(p); > cgroup_post_fork(p); > + > + if (!(clone_flags & CLONE_VM)) > + mem_cgroup_fork_init(p); > + > return p; > > bad_fork_free_pid: > diff -puN include/linux/memcontrol.h~memory-controller-add-mm-owner include/linux/memcontrol.h > --- linux-2.6.25-rc5/include/linux/memcontrol.h~memory-controller-add-mm-owner 2008-03-20 13:35:09.000000000 +0530 > +++ linux-2.6.25-rc5-balbir/include/linux/memcontrol.h 2008-03-24 18:49:52.000000000 +0530 > @@ -29,6 +29,7 @@ struct mm_struct; > > extern void mm_init_cgroup(struct mm_struct *mm, struct task_struct *p); > extern void mm_free_cgroup(struct mm_struct *mm); > +extern void mem_cgroup_fork_init(struct task_struct *p); > > #define page_reset_bad_cgroup(page) ((page)->page_cgroup = 0) > > @@ -49,7 +50,7 @@ extern void mem_cgroup_out_of_memory(str > int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem); > > #define mm_match_cgroup(mm, cgroup) \ > - ((cgroup) == rcu_dereference((mm)->mem_cgroup)) > + ((cgroup) == mem_cgroup_from_task((mm)->owner)) > > extern int mem_cgroup_prepare_migration(struct page *page); > extern void mem_cgroup_end_migration(struct page *page); > @@ -72,6 +73,8 @@ extern long mem_cgroup_calc_reclaim_acti > extern long mem_cgroup_calc_reclaim_inactive(struct mem_cgroup *mem, > struct zone *zone, int priority); > > +extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p); > + > #else /* CONFIG_CGROUP_MEM_RES_CTLR */ > static inline void mm_init_cgroup(struct mm_struct *mm, > struct task_struct *p) > @@ -82,6 +85,10 @@ static inline void mm_free_cgroup(struct > { > } > > +static inline void mem_cgroup_fork_init(struct task_struct *p) > +{ > +} > + > static inline void page_reset_bad_cgroup(struct page *page) > { > } > @@ -172,6 +179,11 @@ static inline long mem_cgroup_calc_recla > { > return 0; > } > + > +static void mm_free_fork_cgroup(struct task_struct *p) > +{ > +} > +
Where is this function used? I don't see the corresponding one with CONFIG_CGROUP_MEM_RES_CTLR enabled?
quoted text
> #endif /* CONFIG_CGROUP_MEM_CONT */ > > #endif /* _LINUX_MEMCONTROL_H */ > diff -puN mm/memcontrol.c~memory-controller-add-mm-owner mm/memcontrol.c > --- linux-2.6.25-rc5/mm/memcontrol.c~memory-controller-add-mm-owner 2008-03-20 13:35:09.000000000 +0530 > +++ linux-2.6.25-rc5-balbir/mm/memcontrol.c 2008-03-24 19:04:32.000000000 +0530 > @@ -236,7 +236,7 @@ static struct mem_cgroup *mem_cgroup_fro > css); > } > > -static struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p) > +struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p) > { > return container_of(task_subsys_state(p, mem_cgroup_subsys_id), > struct mem_cgroup, css); > @@ -248,12 +248,40 @@ void mm_init_cgroup(struct mm_struct *mm > > mem = mem_cgroup_from_task(p); > css_get(&mem->css); > - mm->mem_cgroup = mem; > + mm->owner = p; > +} > + > +void mem_cgroup_fork_init(struct task_struct *p) > +{ > + struct mm_struct *mm = get_task_mm(p); > + struct mem_cgroup *mem, *oldmem;
Leave an empty line here.
quoted text
> + if (!mm) > + return; > + > + /* > + * Initial owner at mm_init_cgroup() time is the task itself. > + * The thread group leader had not been setup then > + */ > + oldmem = mem_cgroup_from_task(mm->owner); > + /* > + * Override the mm->owner after we know the thread group later > + */ > + mm->owner = p->group_leader; > + mem = mem_cgroup_from_task(mm->owner); > + css_get(&mem->css); > + css_put(&oldmem->css); > + mmput(mm); > } > > void mm_free_cgroup(struct mm_struct *mm) > { > - css_put(&mm->mem_cgroup->css); > + struct mem_cgroup *mem; > + > + /* > + * TODO: Should we assign mm->owner to NULL here? > + */ > + mem = mem_cgroup_from_task(mm->owner); > + css_put(&mem->css); > } > > static inline int page_cgroup_locked(struct page *page) > @@ -476,6 +504,7 @@ unsigned long mem_cgroup_isolate_pages(u > int zid = zone_idx(z); > struct mem_cgroup_per_zone *mz; > > + BUG_ON(!mem_cont); > mz = mem_cgroup_zoneinfo(mem_cont, nid, zid); > if (active) > src = &mz->active_list; > @@ -573,13 +602,11 @@ retry: > if (!mm) > mm = &init_mm; > > - rcu_read_lock(); > - mem = rcu_dereference(mm->mem_cgroup); > + mem = mem_cgroup_from_task(mm->owner); > /* > * For every charge from the cgroup, increment reference count > */ > css_get(&mem->css); > - rcu_read_unlock(); > > while (res_counter_charge(&mem->res, PAGE_SIZE)) { > if (!(gfp_mask & __GFP_WAIT)) > @@ -988,7 +1015,7 @@ mem_cgroup_create(struct cgroup_subsys * > > if (unlikely((cont->parent) == NULL)) { > mem = &init_mem_cgroup; > - init_mm.mem_cgroup = mem; > + init_mm.owner = &init_task; > } else > mem = kzalloc(sizeof(struct mem_cgroup), GFP_KERNEL); > > @@ -1069,7 +1096,6 @@ static void mem_cgroup_move_task(struct > goto out; > > css_get(&mem->css); > - rcu_assign_pointer(mm->mem_cgroup, mem); > css_put(&old_mem->css); > > out: > _ >
--
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[RFC][-mm] Memory controller add mm->owner
, Balbir Singh
, (Mon Mar 24, 10:01 am)
Re: [RFC][-mm] Memory controller add mm->owner
, Li Zefan
, (Mon Mar 24, 9:26 pm)
Re: [RFC][-mm] Memory controller add mm->owner
, Balbir Singh
, (Tue Mar 25, 11:48 am)
Re: [RFC][-mm] Memory controller add mm->owner
, Paul Menage
, (Mon Mar 24, 11:03 am)
Re: [RFC][-mm] Memory controller add mm->owner
, Balbir Singh
, (Mon Mar 24, 12:21 pm)
Re: [RFC][-mm] Memory controller add mm->owner
, Paul Menage
, (Mon Mar 24, 12:34 pm)
Re: [RFC][-mm] Memory controller add mm->owner
, Balbir Singh
, (Mon Mar 24, 1:33 pm)
Re: [RFC][-mm] Memory controller add mm->owner
, Paul Menage
, (Mon Mar 24, 1:46 pm)
Re: [RFC][-mm] Memory controller add mm->owner
, Balbir Singh
, (Tue Mar 25, 7:41 am)
Re: [RFC][-mm] Memory controller add mm->owner
, Balbir Singh
, (Wed Mar 26, 6:29 am)
Re: [RFC][-mm] Memory controller add mm->owner
, Paul Menage
, (Wed Mar 26, 7:20 am)
Re: [RFC][-mm] Memory controller add mm->owner
, Balbir Singh
, (Wed Mar 26, 7:41 am)
Re: [RFC][-mm] Memory controller add mm->owner
, Paul Menage
, (Wed Mar 26, 11:21 am)
Navigation
Create content
Mailing list archives
Recent posts
Mail archive search
Enter your search terms.
all mailing lists
alsa-devel
dragonflybsd-bugs
dragonflybsd-commit
dragonflybsd-docs
dragonflybsd-kernel
dragonflybsd-submit
dragonflybsd-user
freebsd-announce
freebsd-bugs
freebsd-chat
freebsd-cluster
freebsd-current
freebsd-drivers
freebsd-embeded
freebsd-fs
freebsd-hackers
freebsd-hardware
freebsd-mobile
freebsd-net
freebsd-performance
freebsd-pf
freebsd-security
freebsd-security-notifications
freebsd-threads
git
git-commits-head
linux-activists
linux-arm
linux-ath5k-devel
linux-btrfs
linux-c-programming
linux-driver-devel
linux-ext4
linux-fsdevel
linux-ia64
linux-input
linux-kernel
linux-kernel-janitors
linux-kernel-mentors
linux-kernel-newbies
linux-kvm
linux-net
linux-netdev
linux-newbie
linux-nfs
linux-raid
linux-scsi
linux-security-module
linux-sparse
linux-usb
linux-usb-devel
madwifi-devel
netbsd-announce
netbsd-tech-kern
openbsd-announce
openbsd-bugs
openbsd-ipv6
openbsd-misc
openbsd-security-announce
openbsd-smp
openbsd-source-changes
openbsd-tech
openfabrics-general
openmoko-community
openmoko-devel
openmoko-kernel
reiserfs-devel
tux3
ucarp
Optionally limit your search to a specific mailing list.
advanced
Popular discussions
linux-kernel
:
Ryan Hope
reiser4 for 2.6.27-rc1
Ingo Molnar
Re: 2.6.24-rc6-mm1
Tejun Heo
[PATCHSET] CUSE: implement CUSE
Peter Zijlstra
Re: 2.6.24-rc8-mm1 (BUG: sched_rt)
git
:
Shawn O. Pearce
Re: [PATCH/POLL] git-format-patch: the default suffix is now .patch, not .txt
Jakub Narebski
Re: What's cooking in git.git (topics)
Junio C Hamano
Maintaining "needswork" section of "What's (not) cooking"
Matthias Lederhofer
[PATCH] prune-packed: new option --min-age=N
openbsd-misc
:
Theo de Raadt
That whole "Linux stealing our code" thing
Karthik Kumar
Re: Real men don't attack straw men
Khalid Schofield
Configuring sendmail openbsd 4.2
Ray Percival
Re: Real men don't attack straw men
freebsd-hackers
:
RW
Re: forcefsck on booting stage
Vladimir Terziev
Video memory as swap under FreeBSD
Ivan Voras
Progress for 7.0 - the "what's cooking" page
Pietro Cerutti
Re: [patch] enhance powerd(8) to handle max temperature
Latest forum posts
trouble with my Asus Mainboard
16 minutes ago
Linux kernel
what is "callback function"?.can anyone explain me please..
20 hours ago
Linux general
unable to remove block device driver module
1 day ago
Linux kernel
Is there anything like Real-time drivers?
2 days ago
Linux general
I can't allocate more than 4 MB with pci_alloc_consistent
2 days ago
Linux kernel
Resetting the bios password for Toshiba Laptop
2 days ago
Hardware
Kernel panic while installing fedora core 5 or ubuntu
3 days ago
Hardware
Interactive Linux kernel map
3 days ago
Linux kernel
unable to add a variable in buffer_head struct
3 days ago
Linux kernel
Linux Input driver - setting scaling/resolution on USB mouse
4 days ago
Linux kernel
Show all forums...
Recent Tags
Ingo Molnar
Junio Hamano
Jared Hulbert
Rik van Riel
git 1.6.0
Linus Torvalds
Linux
squashfs
cramfs
Andrew Morton
performance
GCC
filesystem
quote
release
git 1.6
AXFS
-rc
2.6.27
git
more tags
Colocation donated by:
Who's online
There are currently
4 users
and
738 guests
online.
Online users
Jeremy
Raynus
Mr_Z
mmessano
Syndicate
speck-geostationary