Date: Thu, 15 May 2008 14:18:47 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: Teemu Rinta-aho <teemu@rinta-aho.org> Cc: freebsd-hackers@freebsd.org Subject: Re: copy-on-write anonymous memory? Message-ID: <20080515111847.GX18958@deviant.kiev.zoral.com.ua> In-Reply-To: <482C0E70.4020305@rinta-aho.org> References: <482C0E70.4020305@rinta-aho.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--Ny9pOG5CW+LNoymi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 15, 2008 at 01:20:32PM +0300, Teemu Rinta-aho wrote: > Hi all, >=20 > is it possible to create a memory object that represents > anonymous memory pages *and* is copy-on-write? >=20 > I have this code in a kernel module: >=20 > object =3D vm_object_allocate(OBJT_DEFAULT, 1); >=20 > result =3D vm_map_find(vmmap_proc, > object, > 0, > &addr, > len, > TRUE, > VM_PROT_ALL, > VM_PROT_ALL, > MAP_COPY_ON_WRITE); >=20 > Then I pass the addr to the user space, but when > I write to the addr, I see no shadow objects created, > i.e. the changes are written to the original memory > pages no matter if I have the map entry set as > copy-on-write or not... I am assuming a write fault would > create a new page and hang it to a shadow object thus > leaving the original memory untouched. >=20 > I'd appreciate any kind of help here. I cannot get a complete handle on your problem without full code, but I guess that you have only one reference to the backing object through the vm map entry. If this is the case, then the shadow copying actually does not make sense since no other users of the object need it. Look at the vm_object_shadow(), check at the start of the function. --Ny9pOG5CW+LNoymi Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkgsHBcACgkQC3+MBN1Mb4iIgACgoPCEMrYPXQikN3G2neX51+jR txUAn0JJMcoPypfEXwium413Sp7Ratpt =YxN0 -----END PGP SIGNATURE----- --Ny9pOG5CW+LNoymi--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080515111847.GX18958>