Date: Wed, 23 Sep 1998 18:24:25 -0400 (EDT) From: Luoqi Chen <luoqi@watermarkgroup.com> To: current@FreeBSD.ORG Subject: deadlock in vm_fault() Message-ID: <199809232224.SAA17260@lor.watermarkgroup.com>
next in thread | raw e-mail | index | archive | help
I ran into a deadlock in vm_fault code today while making -j12 world. It's caused by a reversed lock acquisition order. The normal order of acquisition is vm map lock first and vnode lock next (if the fault is in a vnode backed object). During the course of the fault handling, lock on the vm map is released prior to paging io and has to be reacquired if it's modified by another process during the io. Before reacquiring the lock of vm map, we have to release the vnode lock we still hold, otherwise another page fault in the same map/vnode would send us into a deadlock. Attached is a fix for this problem. Would any of the vm/lock experts out there review this? Thanks. -lq Index: vm_fault.c =================================================================== RCS file: /home/ncvs/src/sys/vm/vm_fault.c,v retrieving revision 1.88 diff -u -r1.88 vm_fault.c --- vm_fault.c 1998/09/04 08:06:57 1.88 +++ vm_fault.c 1998/09/23 21:54:14 @@ -656,6 +656,14 @@ */ /* + * Unlock vnode before the lookup to avoid deadlock + */ + if (fs.vp != NULL) { + vput(fs.vp); + fs.vp = NULL; + } + + /* * To avoid trying to write_lock the map while another process * has it read_locked (in vm_map_pageable), we do not try for * write permission. If the page is still writable, we will To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809232224.SAA17260>