From patchwork Tue Oct 10 20:24:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9998125 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A9D0F601AE for ; Tue, 10 Oct 2017 23:04:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9099E28706 for ; Tue, 10 Oct 2017 23:04:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83D9228744; Tue, 10 Oct 2017 23:04:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8E7D128706 for ; Tue, 10 Oct 2017 23:04:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e23X5-0004CI-P9; Tue, 10 Oct 2017 23:01:51 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e23X4-0004CC-Gb for xen-devel@lists.xen.org; Tue, 10 Oct 2017 23:01:50 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 54/FF-31244-D515DD95; Tue, 10 Oct 2017 23:01:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPLMWRWlGSWpSXmKPExsXitHSDvW5s4N1 Ig2crmSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1owPs68yFzzJr3jWO4O9gfGXbxcjJ4eEgL9E 75LDLCA2m4C+xO4Xn5hAbBEBdYnTHRdZuxi5OJgFdjFJvJrxkx0kISwQI/Gg+Q8jiM0ioCox+ fJcIJuDg1fAU+JBhz7ETDmJ88d/MoPYQgJqEtf6L4G18goISpyc+QRsF7OAhMTBFy+YJzByz0 KSmoUktYCRaRWjRnFqUVlqka6RoV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5yfu4mRmA wMADBDsY/ywIOMUpyMCmJ8r5WvxspxJeUn1KZkVicEV9UmpNafIhRhoNDSYJXLQAoJ1iUmp5a kZaZAwxLmLQEB4+SCG+XP1Cat7ggMbc4Mx0idYrRmOPYpst/mDg6bt79wyTEkpeflyolzmsPM kkApDSjNA9uECxeLjHKSgnzMgKdJsRTkFqUm1mCKv+KUZyDUUmYVwhkCk9mXgncvldApzABnS KadgfklJJEhJRUA+OBf8kJrwSWceXM/biiVUol14nveOJR4UealjNPT1+9rPnz8r8rKi/e5OS ZnPH6ekncofIgxlc5O4tes54/6jVl+kyNbD6e7p55H3/OFD2i5Fh3pqnkYP/d9pOXuDhT178z d7roszIxedsWoYsl0i3L13O+6nuQ18D0w0s8Si9XdI3rsbara54psRRnJBpqMRcVJwIA+WPAo pICAAA= X-Env-Sender: prvs=449b7a24d=Andrew.Cooper3@citrix.com X-Msg-Ref: server-5.tower-27.messagelabs.com!1507676507!105571848!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63195 invoked from network); 10 Oct 2017 23:01:48 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-5.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 10 Oct 2017 23:01:48 -0000 X-IronPort-AV: E=Sophos;i="5.43,359,1503360000"; d="scan'208";a="453294271" From: Andrew Cooper To: Xen-devel Date: Tue, 10 Oct 2017 21:24:35 +0100 Message-ID: <1507667075-15556-1-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH for-4.10] common/gnttab: Improve logging message by including relevent domid X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Several logging messages cite "bad ref %#x", without identifying which domain the ref belongs to. Add a domain back-pointer to struct grant_table to improve the debugability. While editing the messages, clean up some others: * Remove extranious punctuation * Use d%d rather than Dom%d * Remove "gnttab_transfer:" prefixes, as it is included by the gdprintk() * Reflow several messages to not be split across multiple lines Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: George Dunlap CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Wei Liu CC: Julien Grall --- xen/common/grant_table.c | 91 +++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 43 deletions(-) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 6d20b17..3a7a7e4 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -76,6 +76,9 @@ struct grant_table { /* Mapping tracking table per vcpu. */ struct grant_mapping **maptrack; + /* Domain to which this struct grant_table belongs. */ + struct domain *domain; + struct grant_table_arch arch; }; @@ -651,7 +654,7 @@ static int _set_status_v1(domid_t domid, GTF_permit_access) || (scombo.shorts.domid != domid)) ) PIN_FAIL(done, GNTST_general_error, - "Bad flags (%x) or dom (%d). (expected dom %d)\n", + "Bad flags (%x) or dom (%d); expected d%d\n", scombo.shorts.flags, scombo.shorts.domid, domid); @@ -663,7 +666,7 @@ static int _set_status_v1(domid_t domid, new_scombo.shorts.flags |= GTF_writing; if ( unlikely(scombo.shorts.flags & GTF_readonly) ) PIN_FAIL(done, GNTST_general_error, - "Attempt to write-pin a r/o grant entry.\n"); + "Attempt to write-pin a r/o grant entry\n"); } prev_scombo.word = cmpxchg((u32 *)shah, @@ -673,7 +676,7 @@ static int _set_status_v1(domid_t domid, if ( retries++ == 4 ) PIN_FAIL(done, GNTST_general_error, - "Shared grant entry is unstable.\n"); + "Shared grant entry is unstable\n"); scombo = prev_scombo; } @@ -715,7 +718,7 @@ static int _set_status_v2(domid_t domid, ((flags & mask) != GTF_transitive)) || (id != domid)) ) PIN_FAIL(done, GNTST_general_error, - "Bad flags (%x) or dom (%d). (expected dom %d, flags %x)\n", + "Bad flags (%x) or dom (%d); expected d%d, flags %x\n", flags, id, domid, mask); if ( readonly ) @@ -726,7 +729,7 @@ static int _set_status_v2(domid_t domid, { if ( unlikely(flags & GTF_readonly) ) PIN_FAIL(done, GNTST_general_error, - "Attempt to write-pin a r/o grant entry.\n"); + "Attempt to write-pin a r/o grant entry\n"); *status |= GTF_reading | GTF_writing; } @@ -749,8 +752,7 @@ static int _set_status_v2(domid_t domid, gnttab_clear_flag(_GTF_writing, status); gnttab_clear_flag(_GTF_reading, status); PIN_FAIL(done, GNTST_general_error, - "Unstable flags (%x) or dom (%d). (expected dom %d) " - "(r/w: %d)\n", + "Unstable flags (%x) or dom (%d); expected d%d (r/w: %d)\n", flags, id, domid, !readonly); } } @@ -896,7 +898,7 @@ map_grant_ref( if ( unlikely((op->flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0) ) { - gdprintk(XENLOG_INFO, "Bad flags in grant map op (%x).\n", op->flags); + gdprintk(XENLOG_INFO, "Bad flags in grant map op: %x\n", op->flags); op->status = GNTST_bad_gntref; return; } @@ -905,7 +907,7 @@ map_grant_ref( (op->flags & (GNTMAP_device_map|GNTMAP_application_map| GNTMAP_contains_pte))) ) { - gdprintk(XENLOG_INFO, "No device mapping in HVM domain.\n"); + gdprintk(XENLOG_INFO, "No device mapping in HVM domain\n"); op->status = GNTST_general_error; return; } @@ -930,7 +932,7 @@ map_grant_ref( if ( unlikely(handle == INVALID_MAPTRACK_HANDLE) ) { rcu_unlock_domain(rd); - gdprintk(XENLOG_INFO, "Failed to obtain maptrack handle.\n"); + gdprintk(XENLOG_INFO, "Failed to obtain maptrack handle\n"); op->status = GNTST_no_device_space; return; } @@ -940,7 +942,8 @@ map_grant_ref( /* Bounds check on the grant ref */ if ( unlikely(op->ref >= nr_grant_entries(rgt))) - PIN_FAIL(unlock_out, GNTST_bad_gntref, "Bad ref %#x\n", op->ref); + PIN_FAIL(unlock_out, GNTST_bad_gntref, "Bad ref %#x for d%d\n", + op->ref, rgt->domain->domain_id); act = active_entry_acquire(rgt, op->ref); shah = shared_entry_header(rgt, op->ref); @@ -1239,7 +1242,8 @@ unmap_common( if ( unlikely(op->handle >= lgt->maptrack_limit) ) { - gdprintk(XENLOG_INFO, "Bad handle %#x\n", op->handle); + gdprintk(XENLOG_INFO, "Bad d%d handle %#x\n", + lgt->domain->domain_id, op->handle); op->status = GNTST_bad_handle; return; } @@ -1249,7 +1253,8 @@ unmap_common( if ( unlikely(!read_atomic(&map->flags)) ) { - gdprintk(XENLOG_INFO, "Zero flags for handle %#x\n", op->handle); + gdprintk(XENLOG_INFO, "Zero flags for d%d handle %#x\n", + lgt->domain->domain_id, op->handle); op->status = GNTST_bad_handle; return; } @@ -1304,7 +1309,8 @@ unmap_common( smp_rmb(); if ( unlikely(op->ref >= nr_grant_entries(rgt)) ) { - gdprintk(XENLOG_WARNING, "Unstable handle %#x\n", op->handle); + gdprintk(XENLOG_WARNING, "Unstable d%d handle %#x\n", + rgt->domain->domain_id, op->handle); rc = GNTST_bad_handle; flags = 0; goto unlock_out; @@ -1678,7 +1684,7 @@ gnttab_grow_table(struct domain *d, unsigned int req_nr_frames) ASSERT(req_nr_frames <= gt->max_grant_frames); gdprintk(XENLOG_INFO, - "Expanding dom (%d) grant table from (%d) to (%d) frames.\n", + "Expanding d%d grant table from %u to %u frames\n", d->domain_id, nr_grant_frames(gt), req_nr_frames); /* Active */ @@ -1727,7 +1733,8 @@ gnttab_grow_table(struct domain *d, unsigned int req_nr_frames) free_xenheap_page(gt->active[i]); gt->active[i] = NULL; } - gdprintk(XENLOG_INFO, "Allocation failure when expanding grant table.\n"); + gdprintk(XENLOG_INFO, "Allocation failure when expanding d%d grant table\n", + d->domain_id); return -ENOMEM; } @@ -1971,10 +1978,10 @@ gnttab_prepare_for_transfer( if ( unlikely(scombo.shorts.flags != GTF_accept_transfer) || unlikely(scombo.shorts.domid != ld->domain_id) ) { - gdprintk(XENLOG_INFO, "Bad flags (%x) or dom (%d). " - "(NB. expected dom %d)\n", - scombo.shorts.flags, scombo.shorts.domid, - ld->domain_id); + gdprintk(XENLOG_INFO, + "Bad flags (%x) or dom (%d); expected d%d\n", + scombo.shorts.flags, scombo.shorts.domid, + ld->domain_id); goto fail; } @@ -1988,7 +1995,7 @@ gnttab_prepare_for_transfer( if ( retries++ == 4 ) { - gdprintk(XENLOG_WARNING, "Shared grant entry is unstable.\n"); + gdprintk(XENLOG_WARNING, "Shared grant entry is unstable\n"); goto fail; } @@ -2027,7 +2034,7 @@ gnttab_transfer( /* Read from caller address space. */ if ( unlikely(__copy_from_guest(&gop, uop, 1)) ) { - gdprintk(XENLOG_INFO, "gnttab_transfer: error reading req %d/%d\n", + gdprintk(XENLOG_INFO, "error reading req %d/%d\n", i, count); return -EFAULT; } @@ -2048,8 +2055,7 @@ gnttab_transfer( if ( unlikely(!mfn_valid(_mfn(mfn))) ) { put_gfn(d, gop.mfn); - gdprintk(XENLOG_INFO, "gnttab_transfer: out-of-range %lx\n", - (unsigned long)gop.mfn); + gdprintk(XENLOG_INFO, "out-of-range %lx\n", (unsigned long)gop.mfn); gop.status = GNTST_bad_page; goto copyback; } @@ -2066,8 +2072,7 @@ gnttab_transfer( gnttab_flush_tlb(d); if ( rc ) { - gdprintk(XENLOG_INFO, - "gnttab_transfer: can't remove GFN %"PRI_xen_pfn" (MFN %lx)\n", + gdprintk(XENLOG_INFO, "can't remove GFN %"PRI_xen_pfn" (MFN %lx)\n", gop.mfn, mfn); gop.status = GNTST_general_error; goto put_gfn_and_copyback; @@ -2076,8 +2081,7 @@ gnttab_transfer( /* Find the target domain. */ if ( unlikely((e = rcu_lock_domain_by_id(gop.domid)) == NULL) ) { - gdprintk(XENLOG_INFO, "gnttab_transfer: can't find domain %d\n", - gop.domid); + gdprintk(XENLOG_INFO, "can't find domain %d\n", gop.domid); gop.status = GNTST_bad_domain; goto put_gfn_and_copyback; } @@ -2130,11 +2134,11 @@ gnttab_transfer( spin_unlock(&e->page_alloc_lock); if ( e->is_dying ) - gdprintk(XENLOG_INFO, "gnttab_transfer: " - "Transferee (d%d) is dying\n", e->domain_id); + gdprintk(XENLOG_INFO, "Transferee d%d is dying\n", + e->domain_id); else - gdprintk(XENLOG_INFO, "gnttab_transfer: " - "Transferee (d%d) has no headroom (tot %u, max %u)\n", + gdprintk(XENLOG_INFO, + "Transferee d%d has no headroom (tot %u, max %u)\n", e->domain_id, e->tot_pages, e->max_pages); gop.status = GNTST_general_error; @@ -2162,8 +2166,8 @@ gnttab_transfer( spin_unlock(&e->page_alloc_lock); if ( okay /* i.e. e->is_dying due to the surrounding if() */ ) - gdprintk(XENLOG_INFO, "gnttab_transfer: " - "Transferee (d%d) is now dying\n", e->domain_id); + gdprintk(XENLOG_INFO, "Transferee d%d is now dying\n", + e->domain_id); if ( drop_dom_ref ) put_domain(e); @@ -2214,8 +2218,7 @@ gnttab_transfer( copyback: if ( unlikely(__copy_field_to_guest(uop, &gop, status)) ) { - gdprintk(XENLOG_INFO, "gnttab_transfer: error writing resp " - "%d/%d\n", i, count); + gdprintk(XENLOG_INFO, "error writing resp %d/%u\n", i, count); return -EFAULT; } guest_handle_add_offset(uop, 1); @@ -2680,7 +2683,7 @@ static int gnttab_copy_claim_buf(const struct gnttab_copy *op, buf->read_only, buf->domain); if ( rc != GNTST_okay ) PIN_FAIL(out, rc, - "source frame %"PRI_xen_pfn" invalid.\n", ptr->u.gmfn); + "source frame %"PRI_xen_pfn" invalid\n", ptr->u.gmfn); buf->ptr.u.gmfn = ptr->u.gmfn; buf->ptr.offset = 0; @@ -2692,7 +2695,8 @@ static int gnttab_copy_claim_buf(const struct gnttab_copy *op, if ( !get_page_type(buf->page, PGT_writable_page) ) { if ( !buf->domain->is_dying ) - gdprintk(XENLOG_WARNING, "Could not get writable frame %lx\n", buf->frame); + gdprintk(XENLOG_WARNING, "Could not get writable frame %lx\n", + buf->frame); rc = GNTST_general_error; goto out; } @@ -2725,7 +2729,7 @@ static int gnttab_copy_buf(const struct gnttab_copy *op, if ( ((op->source.offset + op->len) > PAGE_SIZE) || ((op->dest.offset + op->len) > PAGE_SIZE) ) - PIN_FAIL(out, GNTST_bad_copy_arg, "copy beyond page area.\n"); + PIN_FAIL(out, GNTST_bad_copy_arg, "copy beyond page area\n"); if ( op->source.offset < src->ptr.offset || op->source.offset + op->len > src->ptr.offset + src->len ) @@ -3017,7 +3021,7 @@ gnttab_get_status_frames(XEN_GUEST_HANDLE_PARAM(gnttab_get_status_frames_t) uop, if ( unlikely(copy_from_guest(&op, uop, 1) != 0) ) { gdprintk(XENLOG_INFO, - "Fault while reading gnttab_get_status_frames_t.\n"); + "Fault while reading gnttab_get_status_frames_t\n"); return -EFAULT; } @@ -3493,6 +3497,7 @@ grant_table_create( spin_lock_init(&t->maptrack_lock); /* Okay, install the structure. */ + t->domain = d; d->grant_table = t; if ( d->domain_id == 0 ) @@ -3527,7 +3532,7 @@ gnttab_release_mappings( ref = map->ref; - gdprintk(XENLOG_INFO, "Grant release %#x ref %#x flags %#x dom %u\n", + gdprintk(XENLOG_INFO, "Grant release %#x ref %#x flags %#x d%d\n", handle, ref, map->flags, map->domid); rd = rcu_lock_domain_by_id(map->domid); @@ -3632,7 +3637,7 @@ void grant_table_warn_active_grants(struct domain *d) nr_active++; if ( nr_active <= WARN_GRANT_MAX ) - printk(XENLOG_G_DEBUG "Dom%d has active grant %x (" + printk(XENLOG_G_DEBUG "d%d has active grant %x (" #ifndef NDEBUG "GFN %lx, " #endif @@ -3646,7 +3651,7 @@ void grant_table_warn_active_grants(struct domain *d) } if ( nr_active > WARN_GRANT_MAX ) - printk(XENLOG_G_DEBUG "Dom%d has too many (%d) active grants to report\n", + printk(XENLOG_G_DEBUG "d%d has too many (%d) active grants to report\n", d->domain_id, nr_active); grant_read_unlock(gt);