[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 3 of 3] Provided a routine to print the active grant table entries
# HG changeset patch # User konrad@xxxxxxxxxxxxxxxxxxx # Date 1259773614 18000 # Node ID c926e5e4728dc0383a5e80954d22be123118373c # Parent 2e270f268c03dff2e029561a13de11129c8bbb20 Provided a routine to print the active grant table entries. This can be called by command 'g' from the xen console. Also, provided a command (invoked by 'G' from the xen console) to forcibly increment the pin count of some arbitrary grant table entry. This can be used to test the printing feature. Authored-By: Robert Phillips Signed-off-By: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> diff -r 2e270f268c03 -r c926e5e4728d xen/common/grant_table.c --- a/xen/common/grant_table.c Wed Dec 02 12:04:35 2009 -0500 +++ b/xen/common/grant_table.c Wed Dec 02 12:06:54 2009 -0500 @@ -2491,6 +2491,152 @@ d->grant_table = NULL; } +#define GNTTAB_USAGE_PROFILE +#ifdef GNTTAB_USAGE_PROFILE + +#include <xen/keyhandler.h> + +void gnttab_usage_print(struct domain *rd) +{ + int first = 1; + grant_ref_t ref; + printk(" -------- active -------- -------- shared --------\n"); + printk("[ref] localdom mfn pin localdom gmfn flags\n"); + + spin_lock(&rd->grant_table->lock); + for (ref = 0; ref != nr_grant_entries(rd->grant_table); ref++) { + struct active_grant_entry *act; + struct grant_entry_header *sha; + grant_entry_v1_t *sha1; + grant_entry_v2_t *sha2; + uint16_t status; + uint64_t frame; + + act = &active_entry(rd->grant_table, ref); + sha = shared_entry_header(rd->grant_table, ref); + if (rd->grant_table->gt_version == 1) { + sha1 = &shared_entry_v1(rd->grant_table, ref); + sha2 = NULL; + status = sha->flags; + frame = sha1->frame; + } else { + sha2 = &shared_entry_v2(rd->grant_table, ref); + sha1 = NULL; + frame = sha2->full_page.frame; + status = status_entry(rd->grant_table, ref); + } + if (act->pin) { + if (first) { + printk("grant-table for remote domain:%5d (v%d)\n", + rd->domain_id, rd->grant_table->gt_version); + first = 0; + } + // [ddd] ddddd 0xXXXXXX 0xXXXXXXXX ddddd 0xXXXXXX 0xXX + printk("[%3d] %5d 0x%06lx 0x%08x %5d 0x%06lx 0x%02x\n", + ref, act->domid, act->frame, act->pin, sha->domid, frame, status); + } + } + spin_unlock(&rd->grant_table->lock); + if (first) + printk("grant-table for remote domain:%5d ... no active grant table entries\n", rd->domain_id); +} + +static void gnttab_usage_print_all(unsigned char key) +{ + struct domain *d; + printk("%s [ key '%c' pressed\n", __FUNCTION__, key); + for_each_domain(d) { + gnttab_usage_print(d); + } + printk("%s ] done\n", __FUNCTION__); +} + +static int gnttab_incr_pin_one(struct domain *rd) +{ + int first = 1; + grant_ref_t ref; + printk(" -------- active -------- -------- shared --------\n"); + printk("[ref] localdom mfn pin localdom gmfn flags\n"); + + spin_lock(&rd->grant_table->lock); + for (ref = 0; ref != nr_grant_entries(rd->grant_table); ref++) { + struct active_grant_entry *act; + struct grant_entry_header *sha; + grant_entry_v1_t *sha1; + grant_entry_v2_t *sha2; + uint16_t *status; + uint64_t frame; + + act = &active_entry(rd->grant_table, ref); + sha = shared_entry_header(rd->grant_table, ref); + if (rd->grant_table->gt_version == 1) { + sha1 = &shared_entry_v1(rd->grant_table, ref); + sha2 = NULL; + status = &sha->flags; + frame = sha1->frame; + } else { + sha2 = &shared_entry_v2(rd->grant_table, ref); + sha1 = NULL; + frame = sha2->full_page.frame; + status = &status_entry(rd->grant_table, ref); + } + if (act->pin) { + printk("grant-table for remote domain:%5d\n", rd->domain_id); + first = 0; + // [ddd] ddddd 0xXXXXXX 0xXXXXXXXX ddddd 0xXXXXXX 0xXX + printk("[%3d] %5d 0x%06lx 0x%08x %5d 0x%06lx 0x%02x <== BEFORE\n", + ref, act->domid, act->frame, act->pin, sha->domid, frame, *status); + act->pin++; + get_page(mfn_to_page(act->frame), rd); + printk("[%3d] %5d 0x%06lx 0x%08x %5d 0x%06lx 0x%02x <== AFTER\n", + ref, act->domid, act->frame, act->pin, sha->domid, frame, *status); + break; + } + } + spin_unlock(&rd->grant_table->lock); + if (first) { + printk("grant-table for remote domain:%5d ... no active grant table entries\n", rd->domain_id); + return 0; + } + return 1; +} + +static void gnttab_incr_pin(unsigned char key) +{ + struct domain *d; + printk("%s [ key '%c' pressed\n", __FUNCTION__, key); + for_each_domain(d) { + if (gnttab_incr_pin_one(d)) + break; + } + printk("%s ] done\n", __FUNCTION__); +} +static struct keyhandler gnttab_usage_print_all_keyhandler = { + .diagnostic = 1, + .u.fn = gnttab_usage_print_all, + .desc = "print grant table usage" +}; + + +static struct keyhandler gnttab_incr_pin_keyhandler = { + .diagnostic = 1, + .u.fn = gnttab_incr_pin, + .desc = "force +1 in grant table pin entry" +}; + + +static int __init gnttab_usage_init(void) +{ + register_keyhandler('g', &gnttab_usage_print_all_keyhandler); + register_keyhandler('G', &gnttab_incr_pin_keyhandler); + return 0; +} + +__initcall(gnttab_usage_init); + +#endif + + /* * Local variables: * mode: C _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |