Subject: Incorrect locking of uobj in nfs_getpages()?
To: None <tech-kern@NetBSD.org>
From: Jaromir Dolecek <jaromir.dolecek@artisys.cz>
List: tech-kern
Date: 12/20/2001 10:28:27
Hi,
I've encountered this with LOCKDEBUG on NetBSD/i386 with sommerfeld_386mp_1
kernel. It happens either with or without MULTIPROCESSOR. I have not
tried non-386mp kernel with LOCKDEBUG yet, but IMHO the problem
happens there as well.

double /netbsd: simple_lock: lock held
double /netbsd: lock: 0xd3ee55a8, currently at: /home/dolecek/sys/arch/i386/compile/DOUBLE/../../../../nfs/nfs_bio.c:1037
double /netbsd: last locked: /home/dolecek/sys/arch/i386/compile/DOUBLE/../../../../uvm/uvm_fault.c:867
double /netbsd: last unlocked: ../../../../uvm/uvm_fault_i.h:91 
double /netbsd: nfs_getpages(d3ef1da8,0,d39b9780,c01699a2,d3ef1eb4) at nfs_getpages+0x10e
double /netbsd: VOP_GETPAGES(d3ee55a8,0,0,d3ef1eb4,d3ef1eac) at VOP_GETPAGES+0x5e
double /netbsd: uvn_get(d3ee55a8,0,0,d3ef1eb4,d3ef1eac) at uvn_get+0x2b
double /netbsd: uvm_fault(d3e7e838,48085000,0,3,0) at uvm_fault+0x7fc
double /netbsd: trap() at trap+0x4cb
double /netbsd: --- trap (number 6) ---
double /netbsd: 0x480dcc78:

With MULTIPROCESSOR, this becomes a panic of course. The exact
details of setup to trigger this are not too interesting, but I can
provide the info if needed.

I've looked into this a bit, and VOP_GETPAGES() seems to be always called
with uobj->vmobjlock simplelocked, either from uvm_bio.c:ubc_fault(),
uvm_bio.c:ubc_alloc() or uvm_fault.c:uvm_fault()->uvn_get() via pgo_get
hook.

However, nfs_getpages() does explicit simple_lock(&uobj->vmobjlock)
and simple_unlock(&uobj->vmobjlock) when manipulating the pg->flags.
This seems to be WRONG. I've not yet kernel tried with those calls
removed, since I don't understand this enough to be sure that is
right.

Are those simple_[un]lock() calls in nfs_getpages() superfluous?

Jaromir
-- 
Jaromir Dolecek <jaromir.dolecek@artisys.cz>
ARTISYS, s.r.o., Stursova 71, 61600 Brno, Czech Republic
phone: +420-5-41224836 / fax: +420-5-41224870 / http://www.artisys.cz