login
Header Space

 
 

Re: [-mm][PATCH 3/4] Add rlimit controller accounting and control

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Balbir Singh <balbir@...>
Cc: <linux-mm@...>, Sudhir Kumar <skumar@...>, YAMAMOTO Takashi <yamamoto@...>, <lizf@...>, <linux-kernel@...>, David Rientjes <rientjes@...>, Pavel Emelianov <xemul@...>, Andrew Morton <akpm@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>
Date: Tuesday, May 6, 2008 - 11:17 pm

On Sat, May 3, 2008 at 2:38 PM, Balbir Singh <balbir@linux.vnet.ibm.com> wrote:

You need to synchronize against mm->owner changing, or
mm->owner->cgroups changing. How about:

int rlimit_cgroup_charge_as(struct mm_struct *mm, unsigned long nr_pages)
{
  int ret;
  struct rlimit_cgroup *rcg;
  struct task_struct *owner;

  rcu_read_lock();
 again:

  /* Find and lock the owner of the mm */
  owner = rcu_dereference(mm->owner);
  task_lock(owner);
  if (mm->owner != owner) {
    task_unlock(owner);
    goto again;
  }

  /* Charge the owner's cgroup with the new memory */
  rcg = rlimit_cgroup_from_task(owner);
  ret = res_counter_charge(&rcg->as_res, (nr_pages << PAGE_SHIFT));
  task_unlock(owner);
  rcu_read_unlock();
  return ret;
}


Can't this be implemented as just a call to charge() with a negative
value? (Possibly fixing res_counter_charge() to handle negative values
if necessary) Seems simpler.


You mean disallow all movement within a hierarchy that has this cgroup
mounted? Doesn't that make it rather hard to use?


Since you need to protect against concurrent charges, and against
concurrent mm ownership changes, I think you should just do this under
task_lock(p).


Also needs to task_lock(p) to prevent concurrent charges or cgroup
reassignments?

Paul
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[-mm][PATCH 0/4] Add rlimit controller to cgroups (v3), Balbir Singh, (Sat May 3, 5:37 pm)
Re: [-mm][PATCH 0/4] Add rlimit controller to cgroups (v3), KAMEZAWA Hiroyuki, (Tue May 6, 9:09 pm)
[-mm][PATCH 4/4] Add rlimit controller documentation, Balbir Singh, (Sat May 3, 5:38 pm)
Re: [-mm][PATCH 3/4] Add rlimit controller accounting and co..., Paul Menage, (Tue May 6, 11:17 pm)
[-mm][PATCH 1/4] Setup the rlimit controller, Balbir Singh, (Sat May 3, 5:37 pm)
Re: [-mm][PATCH 1/4] Setup the rlimit controller, Li Zefan, (Mon May 5, 9:31 pm)
Re: [-mm][PATCH 1/4] Setup the rlimit controller, Balbir Singh, (Tue May 6, 4:15 am)
Re: [-mm][PATCH 1/4] Setup the rlimit controller, Andrew Morton, (Mon May 5, 6:11 pm)
Re: [-mm][PATCH 1/4] Setup the rlimit controller, Balbir Singh, (Mon May 5, 11:40 pm)
speck-geostationary