ia64/xen-unstable

changeset 19300:b249f3e979a5

scheduler: Use perf_counter subsystem for stats

Signed-off-by: Xiaowei Yang <xiaowei.yang@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Mar 09 10:32:24 2009 +0000 (2009-03-09)
parents f57ac4af36b4
children 00b8c660be97
files xen/common/sched_credit.c xen/include/xen/perfc_defn.h
line diff
     1.1 --- a/xen/common/sched_credit.c	Mon Mar 09 09:56:16 2009 +0000
     1.2 +++ b/xen/common/sched_credit.c	Mon Mar 09 10:32:24 2009 +0000
     1.3 @@ -25,12 +25,14 @@
     1.4  /*
     1.5   * CSCHED_STATS
     1.6   *
     1.7 - * Manage very basic counters and stats.
     1.8 + * Manage very basic per-vCPU counters and stats.
     1.9   *
    1.10   * Useful for debugging live systems. The stats are displayed
    1.11   * with runq dumps ('r' on the Xen console).
    1.12   */
    1.13 +#ifdef PERF_COUNTERS
    1.14  #define CSCHED_STATS
    1.15 +#endif
    1.16  
    1.17  
    1.18  /*
    1.19 @@ -77,86 +79,9 @@
    1.20  /*
    1.21   * Stats
    1.22   */
    1.23 -#ifdef CSCHED_STATS
    1.24 -
    1.25 -#define CSCHED_STAT(_X)         (csched_priv.stats._X)
    1.26 -#define CSCHED_STAT_DEFINE(_X)  uint32_t _X;
    1.27 -#define CSCHED_STAT_PRINTK(_X)                                  \
    1.28 -    do                                                          \
    1.29 -    {                                                           \
    1.30 -        printk("\t%-30s = %u\n", #_X, CSCHED_STAT(_X));  \
    1.31 -    } while ( 0 );
    1.32 +#define CSCHED_STAT_CRANK(_X)               (perfc_incr(_X))
    1.33  
    1.34 -/*
    1.35 - * Try and keep often cranked stats on top so they'll fit on one
    1.36 - * cache line.
    1.37 - */
    1.38 -#define CSCHED_STATS_EXPAND_SCHED(_MACRO)   \
    1.39 -    _MACRO(schedule)                        \
    1.40 -    _MACRO(acct_run)                        \
    1.41 -    _MACRO(acct_no_work)                    \
    1.42 -    _MACRO(acct_balance)                    \
    1.43 -    _MACRO(acct_reorder)                    \
    1.44 -    _MACRO(acct_min_credit)                 \
    1.45 -    _MACRO(acct_vcpu_active)                \
    1.46 -    _MACRO(acct_vcpu_idle)                  \
    1.47 -    _MACRO(vcpu_sleep)                      \
    1.48 -    _MACRO(vcpu_wake_running)               \
    1.49 -    _MACRO(vcpu_wake_onrunq)                \
    1.50 -    _MACRO(vcpu_wake_runnable)              \
    1.51 -    _MACRO(vcpu_wake_not_runnable)          \
    1.52 -    _MACRO(vcpu_park)                       \
    1.53 -    _MACRO(vcpu_unpark)                     \
    1.54 -    _MACRO(tickle_local_idler)              \
    1.55 -    _MACRO(tickle_local_over)               \
    1.56 -    _MACRO(tickle_local_under)              \
    1.57 -    _MACRO(tickle_local_other)              \
    1.58 -    _MACRO(tickle_idlers_none)              \
    1.59 -    _MACRO(tickle_idlers_some)              \
    1.60 -    _MACRO(load_balance_idle)               \
    1.61 -    _MACRO(load_balance_over)               \
    1.62 -    _MACRO(load_balance_other)              \
    1.63 -    _MACRO(steal_trylock_failed)            \
    1.64 -    _MACRO(steal_peer_idle)                 \
    1.65 -    _MACRO(migrate_queued)                  \
    1.66 -    _MACRO(migrate_running)                 \
    1.67 -    _MACRO(dom_init)                        \
    1.68 -    _MACRO(dom_destroy)                     \
    1.69 -    _MACRO(vcpu_init)                       \
    1.70 -    _MACRO(vcpu_destroy)                    \
    1.71 -    _MACRO(vcpu_hot)
    1.72 -
    1.73 -#ifndef NDEBUG
    1.74 -#define CSCHED_STATS_EXPAND_CHECKS(_MACRO)  \
    1.75 -    _MACRO(vcpu_check)
    1.76 -#else
    1.77 -#define CSCHED_STATS_EXPAND_CHECKS(_MACRO)
    1.78 -#endif
    1.79 -
    1.80 -#define CSCHED_STATS_EXPAND(_MACRO)         \
    1.81 -    CSCHED_STATS_EXPAND_CHECKS(_MACRO)      \
    1.82 -    CSCHED_STATS_EXPAND_SCHED(_MACRO)
    1.83 -
    1.84 -#define CSCHED_STATS_RESET()                                        \
    1.85 -    do                                                              \
    1.86 -    {                                                               \
    1.87 -        memset(&csched_priv.stats, 0, sizeof(csched_priv.stats));   \
    1.88 -    } while ( 0 )
    1.89 -
    1.90 -#define CSCHED_STATS_DEFINE()                   \
    1.91 -    struct                                      \
    1.92 -    {                                           \
    1.93 -        CSCHED_STATS_EXPAND(CSCHED_STAT_DEFINE) \
    1.94 -    } stats;
    1.95 -
    1.96 -#define CSCHED_STATS_PRINTK()                   \
    1.97 -    do                                          \
    1.98 -    {                                           \
    1.99 -        printk("stats:\n");                     \
   1.100 -        CSCHED_STATS_EXPAND(CSCHED_STAT_PRINTK) \
   1.101 -    } while ( 0 )
   1.102 -
   1.103 -#define CSCHED_STAT_CRANK(_X)               (CSCHED_STAT(_X)++)
   1.104 +#ifdef CSCHED_STATS
   1.105  
   1.106  #define CSCHED_VCPU_STATS_RESET(_V)                     \
   1.107      do                                                  \
   1.108 @@ -170,10 +95,6 @@
   1.109  
   1.110  #else /* CSCHED_STATS */
   1.111  
   1.112 -#define CSCHED_STATS_RESET()                do {} while ( 0 )
   1.113 -#define CSCHED_STATS_DEFINE()
   1.114 -#define CSCHED_STATS_PRINTK()               do {} while ( 0 )
   1.115 -#define CSCHED_STAT_CRANK(_X)               do {} while ( 0 )
   1.116  #define CSCHED_VCPU_STATS_RESET(_V)         do {} while ( 0 )
   1.117  #define CSCHED_VCPU_STAT_CRANK(_V, _X)      do {} while ( 0 )
   1.118  #define CSCHED_VCPU_STAT_SET(_V, _X, _Y)    do {} while ( 0 )
   1.119 @@ -239,7 +160,6 @@ struct csched_private {
   1.120      uint32_t credit;
   1.121      int credit_balance;
   1.122      uint32_t runq_sort;
   1.123 -    CSCHED_STATS_DEFINE()
   1.124  };
   1.125  
   1.126  
   1.127 @@ -1339,8 +1259,6 @@ csched_dump(void)
   1.128      cpumask_scnprintf(idlers_buf, sizeof(idlers_buf), csched_priv.idlers);
   1.129      printk("idlers: %s\n", idlers_buf);
   1.130  
   1.131 -    CSCHED_STATS_PRINTK();
   1.132 -
   1.133      printk("active vcpus:\n");
   1.134      loop = 0;
   1.135      list_for_each( iter_sdom, &csched_priv.active_sdom )
   1.136 @@ -1371,7 +1289,6 @@ csched_init(void)
   1.137      csched_priv.credit = 0U;
   1.138      csched_priv.credit_balance = 0;
   1.139      csched_priv.runq_sort = 0U;
   1.140 -    CSCHED_STATS_RESET();
   1.141  }
   1.142  
   1.143  /* Tickers cannot be kicked until SMP subsystem is alive. */
     2.1 --- a/xen/include/xen/perfc_defn.h	Mon Mar 09 09:56:16 2009 +0000
     2.2 +++ b/xen/include/xen/perfc_defn.h	Mon Mar 09 10:32:24 2009 +0000
     2.3 @@ -16,6 +16,40 @@ PERFCOUNTER(sched_irq,              "sch
     2.4  PERFCOUNTER(sched_run,              "sched: runs through scheduler")
     2.5  PERFCOUNTER(sched_ctx,              "sched: context switches")
     2.6  
     2.7 +PERFCOUNTER(vcpu_check,             "csched: vcpu_check")
     2.8 +PERFCOUNTER(schedule,               "csched: schedule")
     2.9 +PERFCOUNTER(acct_run,               "csched: acct_run")
    2.10 +PERFCOUNTER(acct_no_work,           "csched: acct_no_work")
    2.11 +PERFCOUNTER(acct_balance,           "csched: acct_balance")
    2.12 +PERFCOUNTER(acct_reorder,           "csched: acct_reorder")
    2.13 +PERFCOUNTER(acct_min_credit,        "csched: acct_min_credit")
    2.14 +PERFCOUNTER(acct_vcpu_active,       "csched: acct_vcpu_active")
    2.15 +PERFCOUNTER(acct_vcpu_idle,         "csched: acct_vcpu_idle")
    2.16 +PERFCOUNTER(vcpu_sleep,             "csched: vcpu_sleep")
    2.17 +PERFCOUNTER(vcpu_wake_running,      "csched: vcpu_wake_running")
    2.18 +PERFCOUNTER(vcpu_wake_onrunq,       "csched: vcpu_wake_onrunq")
    2.19 +PERFCOUNTER(vcpu_wake_runnable,     "csched: vcpu_wake_runnable")
    2.20 +PERFCOUNTER(vcpu_wake_not_runnable, "csched: vcpu_wake_not_runnable")
    2.21 +PERFCOUNTER(vcpu_park,              "csched: vcpu_park")
    2.22 +PERFCOUNTER(vcpu_unpark,            "csched: vcpu_unpark")
    2.23 +PERFCOUNTER(tickle_local_idler,     "csched: tickle_local_idler")
    2.24 +PERFCOUNTER(tickle_local_over,      "csched: tickle_local_over")
    2.25 +PERFCOUNTER(tickle_local_under,     "csched: tickle_local_under")
    2.26 +PERFCOUNTER(tickle_local_other,     "csched: tickle_local_other")
    2.27 +PERFCOUNTER(tickle_idlers_none,     "csched: tickle_idlers_none")
    2.28 +PERFCOUNTER(tickle_idlers_some,     "csched: tickle_idlers_some")
    2.29 +PERFCOUNTER(load_balance_idle,      "csched: load_balance_idle")
    2.30 +PERFCOUNTER(load_balance_over,      "csched: load_balance_over")
    2.31 +PERFCOUNTER(load_balance_other,     "csched: load_balance_other")
    2.32 +PERFCOUNTER(steal_trylock_failed,   "csched: steal_trylock_failed")
    2.33 +PERFCOUNTER(steal_peer_idle,        "csched: steal_peer_idle")
    2.34 +PERFCOUNTER(migrate_queued,         "csched: migrate_queued")
    2.35 +PERFCOUNTER(migrate_running,        "csched: migrate_running")
    2.36 +PERFCOUNTER(dom_init,               "csched: dom_init")
    2.37 +PERFCOUNTER(dom_destroy,            "csched: dom_destroy")
    2.38 +PERFCOUNTER(vcpu_init,              "csched: vcpu_init")
    2.39 +PERFCOUNTER(vcpu_destroy,           "csched: vcpu_destroy")
    2.40 +
    2.41  PERFCOUNTER(need_flush_tlb_flush,   "PG_need_flush tlb flushes")
    2.42  
    2.43  /*#endif*/ /* __XEN_PERFC_DEFN_H__ */