vmspace_fork()

Konstantin Belousov kostikbel at gmail.com
Tue Apr 23 18:48:31 UTC 2013


On Tue, Apr 23, 2013 at 10:44:56AM -0700, Vijay Singh wrote:
> Hackers, what does hitting the following assert in vmspace_fork() imply?
> 
>  3101 <http://fxr.watson.org/fxr/source/vm/vm_map.c#L3101>
> new_map = &vm2 <http://fxr.watson.org/fxr/ident?im=3;i=vm2>->vm_map
> <http://fxr.watson.org/fxr/ident?im=3;i=vm_map>;
>  3102 <http://fxr.watson.org/fxr/source/vm/vm_map.c#L3102>
> locked <http://fxr.watson.org/fxr/ident?im=3;i=locked> =
> vm_map_trylock <http://fxr.watson.org/fxr/ident?im=3;i=vm_map_trylock>(new_map);
> */* trylock to silence WITNESS */*
>  3103 <http://fxr.watson.org/fxr/source/vm/vm_map.c#L3103>
> KASSERT <http://fxr.watson.org/fxr/ident?im=3;i=KASSERT>(locked
> <http://fxr.watson.org/fxr/ident?im=3;i=locked>, (*"vmspace_fork: lock
> failed"*));
I have hard time reading this html.

> 
> I am hitting the assert in line 3103 and it seems like the assumption
> is that the trylock will
> always get the lock?
Assuming you are referencing line 3103 of the sys/vm/vm_map.c, yes,
the try lock operation must always succeed. The reason is that the new_map
AKA vm2 is freshly allocated and its pointer is not yet published for other
threads to see. So nothing could own the lock.

The try is done to silence the witness warning about the same lock type,
as indicated by the comment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20130423/c2fbfa7c/attachment.sig>


More information about the freebsd-hackers mailing list