debuggers.hg

annotate tools/xenmon/setmask.c @ 22848:6341fe0f4e5a

Added tag 4.1.0-rc2 for changeset 9dca60d88c63
author Keir Fraser <keir@xen.org>
date Tue Jan 25 14:06:55 2011 +0000 (2011-01-25)
parents 779c0ef9682c
children
rev   line source
kaf24@7840 1 /******************************************************************************
kaf24@7840 2 * tools/xenmon/setmask.c
kaf24@7840 3 *
kaf24@7840 4 * Simple utility for getting/setting the event mask
kaf24@7840 5 *
kaf24@7840 6 * Copyright (C) 2005 by Hewlett-Packard, Palo Alto and Fort Collins
kaf24@7840 7 *
kaf24@7840 8 * Authors: Lucy Cherkasova, lucy.cherkasova.hp.com
kaf24@7840 9 * Rob Gardner, rob.gardner@hp.com
kaf24@7840 10 * Diwaker Gupta, diwaker.gupta@hp.com
kaf24@7840 11 * Date: August, 2005
kaf24@7840 12 *
kaf24@7840 13 * This program is free software; you can redistribute it and/or modify
kaf24@7840 14 * it under the terms of the GNU General Public License as published by
kaf24@7840 15 * the Free Software Foundation; under version 2 of the License.
kaf24@7840 16 *
kaf24@7840 17 * This program is distributed in the hope that it will be useful,
kaf24@7840 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
kaf24@7840 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kaf24@7840 20 * GNU General Public License for more details.
kaf24@7840 21 *
kaf24@7840 22 * You should have received a copy of the GNU General Public License
kaf24@7840 23 * along with this program; if not, write to the Free Software
kaf24@7840 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
kaf24@7840 25 */
kaf24@7840 26
kaf24@7840 27 #include <stdlib.h>
kaf24@7840 28 #include <stdio.h>
kaf24@7840 29 #include <sys/types.h>
kaf24@7840 30 #include <fcntl.h>
kaf24@7840 31 #include <unistd.h>
kaf24@7840 32 #include <errno.h>
kaf24@7840 33 #include <getopt.h>
kaf24@7840 34 #include <xenctrl.h>
kaf24@7840 35 #include <xen/xen.h>
kaf24@7840 36 typedef struct { int counter; } atomic_t;
kaf24@7840 37 #include <xen/trace.h>
kaf24@7840 38
kaf24@7840 39 #define XENMON (TRC_SCHED_DOM_ADD | TRC_SCHED_DOM_REM | TRC_SCHED_SWITCH_INFPREV | TRC_SCHED_SWITCH_INFNEXT | TRC_SCHED_BLOCK | TRC_SCHED_SLEEP | TRC_SCHED_WAKE | TRC_MEM_PAGE_GRANT_TRANSFER)
kaf24@7840 40
kaf24@7840 41 int main(int argc, char * argv[])
kaf24@7840 42 {
kfraser@11295 43 struct xen_sysctl sysctl;
kaf24@7840 44 int ret;
kaf24@7840 45
keir@21529 46 xc_interface *xc_handle = xc_interface_open(0,0,0);
kfraser@11295 47 sysctl.cmd = XEN_SYSCTL_tbuf_op;
kfraser@11295 48 sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
kfraser@11295 49 sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_get_info;
kfraser@11295 50 ret = xc_sysctl(xc_handle, &sysctl);
kaf24@7840 51 if ( ret != 0 )
kaf24@7840 52 {
kaf24@7840 53 perror("Failure to get event mask from Xen");
kaf24@7840 54 exit(1);
kaf24@7840 55 }
kaf24@7840 56 else
kaf24@7840 57 {
kfraser@11295 58 printf("Current event mask: 0x%.8x\n", sysctl.u.tbuf_op.evt_mask);
kaf24@7840 59 }
kaf24@7840 60
kfraser@11295 61 sysctl.cmd = XEN_SYSCTL_tbuf_op;
kfraser@11295 62 sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
kfraser@11295 63 sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_set_evt_mask;
kfraser@11295 64 sysctl.u.tbuf_op.evt_mask = XENMON;
kaf24@7840 65
kfraser@11295 66 ret = xc_sysctl(xc_handle, &sysctl);
kfraser@11295 67 printf("Setting mask to 0x%.8x\n", sysctl.u.tbuf_op.evt_mask);
kaf24@7840 68 if ( ret != 0 )
kaf24@7840 69 {
kaf24@7840 70 perror("Failure to get scheduler ID from Xen");
kaf24@7840 71 exit(1);
kaf24@7840 72 }
kaf24@7840 73
kfraser@11295 74 sysctl.cmd = XEN_SYSCTL_tbuf_op;
kfraser@11295 75 sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
kfraser@11295 76 sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_get_info;
kfraser@11295 77 ret = xc_sysctl(xc_handle, &sysctl);
kaf24@7840 78 if ( ret != 0 )
kaf24@7840 79 {
kaf24@7840 80 perror("Failure to get event mask from Xen");
kaf24@7840 81 exit(1);
kaf24@7840 82 }
kaf24@7840 83 else
kaf24@7840 84 {
kfraser@11295 85 printf("Current event mask: 0x%.8x\n", sysctl.u.tbuf_op.evt_mask);
kaf24@7840 86 }
kaf24@7840 87 xc_interface_close(xc_handle);
kaf24@7840 88 return 0;
kaf24@7840 89 }