From: "Jan Beulich" Subject: [PATCH] x86/mm: print domain IDs instead of pointers Date: Fri, 05 Jun 2015 11:27:26 +0100 Message-ID: <557195AE02000078000813DC@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartAB9F829E.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z0oqW-0007h0-OP for xen-devel@lists.xenproject.org; Fri, 05 Jun 2015 10:27:28 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Andrew Cooper , Keir Fraser , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartAB9F829E.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Printing pointers to struct domain isn't really useful for initial problem analysis. In get_page() also drop the page only after issuing the log message, so that at the time of printing the state can be considered reasonably consistent. Signed-off-by: Jan Beulich --- It also slightly concerns me that page_get_owner_and_reference() can (at least theoretically) return NULL even after having taken a page reference (when ->v.inuse._domain is clear), in which case that reference would never get dropped again. One case where this might be a problem is sh_set_allocation(), which - other than all other uses of page_set_owner(, NULL) - doesn't zap the refcount. --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -2082,14 +2082,16 @@ int get_page(struct page_info *page, str if ( likely(owner =3D=3D domain) ) return 1; =20 - if ( owner !=3D NULL ) - put_page(page); - if ( !paging_mode_refcounts(domain) && !domain->is_dying ) gprintk(XENLOG_INFO, - "Error pfn %lx: rd=3D%p, od=3D%p, caf=3D%08lx, taf=3D%" = PRtype_info "\n", - page_to_mfn(page), domain, owner, - page->count_info, page->u.inuse.type_info); + "Error pfn %lx: rd=3D%d od=3D%d caf=3D%08lx taf=3D%" = PRtype_info "\n", + page_to_mfn(page), domain->domain_id, + owner ? owner->domain_id : DOMID_INVALID, + page->count_info - !!owner, page->u.inuse.type_info); + + if ( owner ) + put_page(page); + return 0; } =20 @@ -4225,9 +4227,11 @@ int replace_grant_host_mapping( int donate_page( struct domain *d, struct page_info *page, unsigned int memflags) { + const struct domain *owner =3D dom_xen; + spin_lock(&d->page_alloc_lock); =20 - if ( is_xen_heap_page(page) || (page_get_owner(page) !=3D NULL) ) + if ( is_xen_heap_page(page) || ((owner =3D page_get_owner(page)) !=3D = NULL) ) goto fail; =20 if ( d->is_dying ) @@ -4252,9 +4256,10 @@ int donate_page( =20 fail: spin_unlock(&d->page_alloc_lock); - MEM_LOG("Bad donate %p: ed=3D%p(%u), sd=3D%p, caf=3D%08lx, taf=3D%" = PRtype_info, - (void *)page_to_mfn(page), d, d->domain_id, - page_get_owner(page), page->count_info, page->u.inuse.type_inf= o); + MEM_LOG("Bad donate %lx: ed=3D%d sd=3D%d caf=3D%08lx taf=3D%" = PRtype_info, + page_to_mfn(page), d->domain_id, + owner ? owner->domain_id : DOMID_INVALID, + page->count_info, page->u.inuse.type_info); return -1; } =20 @@ -4263,10 +4268,11 @@ int steal_page( { unsigned long x, y; bool_t drop_dom_ref =3D 0; + const struct domain *owner =3D dom_xen; =20 spin_lock(&d->page_alloc_lock); =20 - if ( is_xen_heap_page(page) || (page_get_owner(page) !=3D d) ) + if ( is_xen_heap_page(page) || ((owner =3D page_get_owner(page)) !=3D = d) ) goto fail; =20 /* @@ -4301,9 +4307,10 @@ int steal_page( =20 fail: spin_unlock(&d->page_alloc_lock); - MEM_LOG("Bad page %p: ed=3D%p(%u), sd=3D%p, caf=3D%08lx, taf=3D%" = PRtype_info, - (void *)page_to_mfn(page), d, d->domain_id, - page_get_owner(page), page->count_info, page->u.inuse.type_inf= o); + MEM_LOG("Bad page %lx: ed=3D%d sd=3D%d caf=3D%08lx taf=3D%" PRtype_inf= o, + page_to_mfn(page), d->domain_id, + owner ? owner->domain_id : DOMID_INVALID, + page->count_info, page->u.inuse.type_info); return -1; } =20 --=__PartAB9F829E.1__= Content-Type: text/plain; name="x86-get_page-warning.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-get_page-warning.patch" x86/mm: print domain IDs instead of pointers=0A=0APrinting pointers to = struct domain isn't really useful for initial=0Aproblem analysis. In = get_page() also drop the page only after issuing=0Athe log message, so = that at the time of printing the state can be=0Aconsidered reasonably = consistent.=0A=0ASigned-off-by: Jan Beulich =0A---=0AIt = also slightly concerns me that page_get_owner_and_reference() can=0A(at = least theoretically) return NULL even after having taken a page=0Areference= (when ->v.inuse._domain is clear), in which case that=0Areference would = never get dropped again. One case where this might be a=0Aproblem is = sh_set_allocation(), which - other than all other uses of=0Apage_set_owner(= , NULL) - doesn't zap the refcount.=0A=0A--- a/xen/arch/x86/mm.c=0A+++ = b/xen/arch/x86/mm.c=0A@@ -2082,14 +2082,16 @@ int get_page(struct = page_info *page, str=0A if ( likely(owner =3D=3D domain) )=0A = return 1;=0A =0A- if ( owner !=3D NULL )=0A- put_page(page);=0A-= =0A if ( !paging_mode_refcounts(domain) && !domain->is_dying )=0A = gprintk(XENLOG_INFO,=0A- "Error pfn %lx: rd=3D%p, = od=3D%p, caf=3D%08lx, taf=3D%" PRtype_info "\n",=0A- = page_to_mfn(page), domain, owner,=0A- page->count_info, = page->u.inuse.type_info);=0A+ "Error pfn %lx: rd=3D%d = od=3D%d caf=3D%08lx taf=3D%" PRtype_info "\n",=0A+ = page_to_mfn(page), domain->domain_id,=0A+ owner ? owner->dom= ain_id : DOMID_INVALID,=0A+ page->count_info - !!owner, = page->u.inuse.type_info);=0A+=0A+ if ( owner )=0A+ put_page(page)= ;=0A+=0A return 0;=0A }=0A =0A@@ -4225,9 +4227,11 @@ int replace_grant_= host_mapping(=0A int donate_page(=0A struct domain *d, struct = page_info *page, unsigned int memflags)=0A {=0A+ const struct domain = *owner =3D dom_xen;=0A+=0A spin_lock(&d->page_alloc_lock);=0A =0A- = if ( is_xen_heap_page(page) || (page_get_owner(page) !=3D NULL) )=0A+ = if ( is_xen_heap_page(page) || ((owner =3D page_get_owner(page)) !=3D = NULL) )=0A goto fail;=0A =0A if ( d->is_dying )=0A@@ -4252,9 = +4256,10 @@ int donate_page(=0A =0A fail:=0A spin_unlock(&d->page_allo= c_lock);=0A- MEM_LOG("Bad donate %p: ed=3D%p(%u), sd=3D%p, caf=3D%08lx, = taf=3D%" PRtype_info,=0A- (void *)page_to_mfn(page), d, = d->domain_id,=0A- page_get_owner(page), page->count_info, = page->u.inuse.type_info);=0A+ MEM_LOG("Bad donate %lx: ed=3D%d sd=3D%d = caf=3D%08lx taf=3D%" PRtype_info,=0A+ page_to_mfn(page), = d->domain_id,=0A+ owner ? owner->domain_id : DOMID_INVALID,=0A+ = page->count_info, page->u.inuse.type_info);=0A return = -1;=0A }=0A =0A@@ -4263,10 +4268,11 @@ int steal_page(=0A {=0A = unsigned long x, y;=0A bool_t drop_dom_ref =3D 0;=0A+ const struct = domain *owner =3D dom_xen;=0A =0A spin_lock(&d->page_alloc_lock);=0A = =0A- if ( is_xen_heap_page(page) || (page_get_owner(page) !=3D d) )=0A+ = if ( is_xen_heap_page(page) || ((owner =3D page_get_owner(page)) !=3D = d) )=0A goto fail;=0A =0A /*=0A@@ -4301,9 +4307,10 @@ int = steal_page(=0A =0A fail:=0A spin_unlock(&d->page_alloc_lock);=0A- = MEM_LOG("Bad page %p: ed=3D%p(%u), sd=3D%p, caf=3D%08lx, taf=3D%" = PRtype_info,=0A- (void *)page_to_mfn(page), d, d->domain_id,=0A-= page_get_owner(page), page->count_info, page->u.inuse.type_info= );=0A+ MEM_LOG("Bad page %lx: ed=3D%d sd=3D%d caf=3D%08lx taf=3D%" = PRtype_info,=0A+ page_to_mfn(page), d->domain_id,=0A+ = owner ? owner->domain_id : DOMID_INVALID,=0A+ page->count_info,= page->u.inuse.type_info);=0A return -1;=0A }=0A =0A --=__PartAB9F829E.1__= 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.xen.org http://lists.xen.org/xen-devel --=__PartAB9F829E.1__=--