login
Header Space

 
 

Re: [RFC][-mm] Memory controller add mm->owner

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <balbir@...>
Cc: <linux-mm@...>, Hugh Dickins <hugh@...>, Sudhir Kumar <skumar@...>, YAMAMOTO Takashi <yamamoto@...>, <lizf@...>, <linux-kernel@...>, <taka@...>, David Rientjes <rientjes@...>, Pavel Emelianov <xemul@...>, Andrew Morton <akpm@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>
Date: Wednesday, March 26, 2008 - 7:20 am

On Wed, Mar 26, 2008 at 3:29 AM, Balbir Singh <balbir@linux.vnet.ibm.com> wrote:

I'm not convinced of this. All we have to do is find some other
process p where p->mm == current->mm and make it the new owner.
Exactly what sequence of clone() calls was used to cause the sharing
isn't really relevant. I really think that a suitable candidate will
be found amongst your children or your first sibling in 99.9% of those
cases where more than one process is using an mm.

The actual sequence would have to go something like:

static inline bool need_new_owner(struct mm_struct *mm) {
  return (mm && mm->owner == current && atomic_read(&mm->users) > 1);
}
static inline void try_give_mm_ownership(
    struct task_struct *task,
    struct mm_struct *mm) {
  if (task->mm != mm) return;
  task_lock(task);
  if (task->mm == mm) {
    mm->owner = task;
  }
  task_unlock(task);
}

struct mm_struct *mm = current->mm;
task_lock(current);
current->mm = NULL;
task_unlock(current);

/* First try my children */
if (need_new_owner(mm)) {
  for_each_child(current, c) {
    try_give_mm_ownership(c);
    if (!need_new_owner(mm)) break;
  }
}

/* Then try my siblings */
if (need_new_owner(mm)) {
  for_each_child(current->real_parent, c) {
    try_give_mm_ownership(c);
    if (!need_new_owner(mm)) break;
  }
}

if (need_new_owner(mm)) {
  /* We'll almost never get here */
  for_each_process(p) {
    try_give_mm_ownership(p);
    if (!need_new_owner(mm)) break;
  }
}

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

Messages in current thread:
[RFC][-mm] Memory controller add mm-&gt;owner, Balbir Singh, (Mon Mar 24, 10:01 am)
Re: [RFC][-mm] Memory controller add mm-&gt;owner, Li Zefan, (Mon Mar 24, 9:26 pm)
Re: [RFC][-mm] Memory controller add mm-&gt;owner, Balbir Singh, (Tue Mar 25, 11:48 am)
Re: [RFC][-mm] Memory controller add mm-&gt;owner, Paul Menage, (Mon Mar 24, 11:03 am)
Re: [RFC][-mm] Memory controller add mm-&gt;owner, Balbir Singh, (Mon Mar 24, 12:21 pm)
Re: [RFC][-mm] Memory controller add mm-&gt;owner, Paul Menage, (Mon Mar 24, 12:34 pm)
Re: [RFC][-mm] Memory controller add mm-&gt;owner, Balbir Singh, (Mon Mar 24, 1:33 pm)
Re: [RFC][-mm] Memory controller add mm-&gt;owner, Paul Menage, (Mon Mar 24, 1:46 pm)
Re: [RFC][-mm] Memory controller add mm-&gt;owner, Balbir Singh, (Tue Mar 25, 7:41 am)
Re: [RFC][-mm] Memory controller add mm-&gt;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-&gt;owner, Balbir Singh, (Wed Mar 26, 7:41 am)
Re: [RFC][-mm] Memory controller add mm-&gt;owner, Paul Menage, (Wed Mar 26, 11:21 am)
speck-geostationary