Skip to contentSkip to conversation

What locks are needed to safely use vma->vm_file ?

DISCUSSION Jose Luis Marchetti 1 participant 1 message May 11, 2010

lore
Share & tools
lore
#0 lore raw

Hi,

It appears that doing down_read(&mm->mmap_sem) is enough to safely use vma->vm_file, is it correct ?

Also in the lock subject, to get to all vm_files in the system, is the following correct or something is missing ?

read_lock(&tasklist_lock);
for_each_process(p)

{
    mm = get_task_mm(p);
    down_read(&mm->mmap_sem);

    // ... Here what I need to do with this mm vm_file objects

    up_read(&mm->mmap_sem);
    mmput(mm);
}

read_unlock(&tasklist_lock);

Thanks in advance for your answer
José Luís Marchetti