Date: Wed, 13 Jun 2007 12:15:34 +0200 From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: Howard Su <howard0su@gmail.com> Cc: alc@freebsd.org, arch@freebsd.org Subject: Re: help on lock around vm_page Message-ID: <20070613101534.GA9200@garage.freebsd.pl> In-Reply-To: <f126fae00706060918q5fc7f664v5a9eb8af76080a3e@mail.gmail.com> References: <f126fae00706060918q5fc7f664v5a9eb8af76080a3e@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--+HP7ph2BbKc20aGI Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 07, 2007 at 12:18:10AM +0800, Howard Su wrote: > I want some helps from VM guru. I try to fix a panic in tmpfs. In > order to push tmpfs into -Current, I really want some help to solve > this. >=20 > 1. we allocate an object from vm_pager_alloc(OBJT_SWAP, ...) when create = a file. > 2. the panic is during handling write op: > a) find the first page we want to write > b) call vm_page_grab to get the page from object. > c) call use sf_buf_alloc to map it into kernel_map > d) use uiomove to move the data > e) mark page as dirty > f) loop to a until all pages are handled. >=20 > there is a race condition. while doing b-c & e, we hold the > OBJ_LOCK/page_queue_lock. when doing d, we have to drop the locks to > call uiomove. When calling uio move, the page may moved to cache queue > since in that time it is not dirty. >=20 > There is a solution that we allocate a page buffer. Before a), we > uiomove it to the buffer and replace uiomove with a bcopy in d). Then, > we can hold lock in b - e. I feel this will cause performance problem. >=20 > For the detailed code, please check: > http://perforce.freebsd.org/fileViewer.cgi?FSPC=3D//depot/user/howardsu/t= russ/sys/fs/tmpfs/tmpfs%5fvnops.c&REV=3D30 >=20 > function: tmpfs_uio_xfer() >=20 > Any idea to close this race condition? >=20 > PS: If you can review my code about usage of vm, it will be appreciated. I've no time to review your code atm, but you may want to look how it is done in ZFS, maybe this will give you hint. Check out zfs_{read,write} and mapped{read,write} functions in sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c. --=20 Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --+HP7ph2BbKc20aGI Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) iD8DBQFGb8PGForvXbEpPzQRAsslAKDlR6mDBMaBghsWnhqbLon6gPGjIgCfWMZJ W0nWHETWr2QoZ6Pq2KyR/c4= =7v97 -----END PGP SIGNATURE----- --+HP7ph2BbKc20aGI--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070613101534.GA9200>