memobj: transform memobj lock to refcounting

We had a deadlock between:
 - free_process_memory_range (take lock) -> ihk_mc_pt_free_range ->
... -> remote_flush_tlb_array_cpumask -> "/* Wait for all cores */"
and
 - obj_list_lookup() under fileobj_list_lock that disabled irqs
and thus never ack'd the remote flush

The rework is quite big but removes the need for the big lock,
although devobj and shmobj needed a new smaller lock to be
introduced - the new locks are used much more locally and
should not cause problems.

On the bright side, refcounting being moved to memobj level means
we could remove refcounting implemented separately in all object
types and simplifies code a bit.

Change-Id: I6bc8438a98b1d8edddc91c4ac33c11b88e097ebb
This commit is contained in:
Dominique Martinet
2018-08-07 15:40:25 +09:00
parent b51886421e
commit c25fb2aa39
10 changed files with 307 additions and 403 deletions

View File

@@ -1399,7 +1399,7 @@ static int xpmem_free_process_memory_range(
}
if (range->memobj) {
memobj_release(range->memobj);
memobj_unref(range->memobj);
}
rb_erase(&range->vm_rb_node, &vm->vm_range_tree);
@@ -1732,7 +1732,8 @@ int xpmem_remove_process_memory_range(
remaining_vmr->private_data = NULL;
/* This function is always followed by xpmem_free_process_memory_range()
which in turn calls memobj_release() */
* which in turn calls memobj_put()
*/
remaining_vaddr = att->at_vaddr;
}
@@ -1755,7 +1756,8 @@ int xpmem_remove_process_memory_range(
vmr->private_data = NULL;
/* This function is always followed by [xpmem_]free_process_memory_range()
which in turn calls memobj_release() */
* which in turn calls memobj_put()
*/
out:
mcs_rwlock_writer_unlock(&att->at_lock, &at_lock);