From: Dan Magenheimer Subject: RE: RE: transferring ownership of domheap pages Date: Fri, 13 Feb 2009 17:02:24 +0000 (GMT) Message-ID: <11851cfd-8be0-40bd-8eb5-48bc755f6bcd@default> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="__123454459749414392acsmt705.oracle.com" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser , "Xen-Devel (E-mail)" List-Id: xen-devel@lists.xenproject.org --__123454459749414392acsmt705.oracle.com Content-Type: text/plain; charset=Windows-1252 Content-Transfer-Encoding: quoted-printable > A benefit of using steal_page() is > that we will maintain that for other callers OK, I'll use steal_page(), though I think it is overkill as the pages I am dealing with are not addressable outside of the hypervisor, so there aren't any mappings being created and destroyed. I still need code for the other direction though: I have an anonymous page (on my own private "free" page_list) and I want it to be owned by a domain, but I don't want to free it and then alloc it (because I might not get the same page back). Does the attached patch look good? Are there any races that I am missing? Is the name ("donate_page" opposite of "steal_page") OK? Thanks, Dan > -----Original Message----- > From: Keir Fraser [mailto:keir.fraser@eu.citrix.com] > Sent: Friday, February 13, 2009 8:23 AM > To: Dan Magenheimer; Xen-Devel (E-mail) > Subject: Re: [Xen-devel] RE: transferring ownership of domheap pages >=20 >=20 > On 13/02/2009 15:14, "Dan Magenheimer"=20 > wrote: >=20 > >> Yeah, that's pretty... optimistic. ;-) > >=20 > > What else do you see that is missing in my first cut? > > Do you see any other code there that's just wrong? >=20 > You can't just assert that count_info =3D=3D PGC_allocated|1, for=20 > example. You > need to be careful that mappings aren't created or destroyed=20 > while you are > changing the ownership. Steal_page() does that. Once a page=20 > is anonymous, > transferring it to a domain is easier, since mappings can't be > created/destroyed while it is anonymous. So steal_page() just=20 > does the hard > transition for you (non-anon -> anon). A benefit of using=20 > steal_page() is > that we will maintain that for other callers -- a private=20 > implementation in > tmem risks getting subtly unsafely broken every now and then. >=20 > -- Keir >=20 >=20 >=20 > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel > --__123454459749414392acsmt705.oracle.com Content-Type: application/octet-stream; name="donatepage.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="donatepage.patch" ZGlmZiAtciA0YWM4YmM2MGMwMDAgeGVuL2FyY2gveDg2L21tLmMKLS0tIGEveGVuL2FyY2gveDg2 L21tLmMJVHVlIEZlYiAxMCAwNTo1MTowMCAyMDA5ICswMDAwCisrKyBiL3hlbi9hcmNoL3g4Ni9t bS5jCUZyaSBGZWIgMTMgMDk6NTI6MzkgMjAwOSAtMDcwMApAQCAtMzQ2OSw2ICszNDY5LDM5IEBA IGludCByZXBsYWNlX2dyYW50X2hvc3RfbWFwcGluZygKICAgICByZXR1cm4gcmM7CiB9CiAKK2lu dCBkb25hdGVfcGFnZSgKKyAgICBzdHJ1Y3QgZG9tYWluICpkLCBzdHJ1Y3QgcGFnZV9pbmZvICpw YWdlLCB1bnNpZ25lZCBpbnQgbWVtZmxhZ3MpCit7CisgICAgc3Bpbl9sb2NrKCZkLT5wYWdlX2Fs bG9jX2xvY2spOworCisgICAgaWYgKCBpc194ZW5faGVhcF9wYWdlKHBhZ2UpIHx8IChwYWdlX2dl dF9vd25lcihwYWdlKSAhPSBOVUxMKSApCisgICAgICAgIGdvdG8gZmFpbDsKKworICAgIGlmICgg cGFnZS0+Y291bnRfaW5mbyAmIH4oUEdDX2FsbG9jYXRlZCB8IDEpICkKKyAgICAgICAgZ290byBm YWlsOworCisgICAgaWYgKCAhKG1lbWZsYWdzICYgTUVNRl9ub19yZWZjb3VudCkgKQorICAgIHsK KyAgICAgICAgaWYgKCBkLT50b3RfcGFnZXMgPj0gZC0+bWF4X3BhZ2VzICkKKyAgICAgICAgICAg IGdvdG8gZmFpbDsKKyAgICAgICAgZC0+dG90X3BhZ2VzKys7CisgICAgfQorCisgICAgcGFnZS0+ Y291bnRfaW5mbyA9IFBHQ19hbGxvY2F0ZWQgfCAxOworICAgIHBhZ2Vfc2V0X293bmVyKHBhZ2Us IGQpOworICAgIHBhZ2VfbGlzdF9hZGRfdGFpbChwYWdlLCZkLT5wYWdlX2xpc3QpOworCisgICAg c3Bpbl91bmxvY2soJmQtPnBhZ2VfYWxsb2NfbG9jayk7CisgICAgcmV0dXJuIDA7CisKKyBmYWls OgorICAgIHNwaW5fdW5sb2NrKCZkLT5wYWdlX2FsbG9jX2xvY2spOworICAgIE1FTV9MT0coIkJh ZCBwYWdlICVwOiBlZD0lcCgldSksIHNkPSVwLCBjYWY9JTA4bHgsIHRhZj0lIiBQUnR5cGVfaW5m bywKKyAgICAgICAgICAgICh2b2lkICopcGFnZV90b19tZm4ocGFnZSksIGQsIGQtPmRvbWFpbl9p ZCwKKyAgICAgICAgICAgIHBhZ2VfZ2V0X293bmVyKHBhZ2UpLCBwYWdlLT5jb3VudF9pbmZvLCBw YWdlLT51LmludXNlLnR5cGVfaW5mbyk7CisgICAgcmV0dXJuIC0xOworfQorCiBpbnQgc3RlYWxf cGFnZSgKICAgICBzdHJ1Y3QgZG9tYWluICpkLCBzdHJ1Y3QgcGFnZV9pbmZvICpwYWdlLCB1bnNp Z25lZCBpbnQgbWVtZmxhZ3MpCiB7Cg== --__123454459749414392acsmt705.oracle.com Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --__123454459749414392acsmt705.oracle.com--