summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3915255)
raw | patch | inline | side by side (parent: 3915255)
author | Florian Forster <octo@huhu.verplant.org> | |
Sun, 12 Sep 2010 06:21:08 +0000 (08:21 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Sun, 12 Sep 2010 06:21:08 +0000 (08:21 +0200) |
src/lpar.c | patch | blob | history |
diff --git a/src/lpar.c b/src/lpar.c
index 844440ae4323bad45a61a3b34f1e2f139fc6ccbb..ec39d5c0e8cac9fdc19f2f326a070ae91375dec3 100644 (file)
--- a/src/lpar.c
+++ b/src/lpar.c
static _Bool donate_flag = 0;
static char serial[SYS_NMLN];
-static u_longlong_t time_old;
-static u_longlong_t user_old,
- syst_old,
- idle_old,
- wait_old;
-static u_longlong_t pool_busy_time_old,
- pool_max_time_old;
-static u_longlong_t idle_donated_old,
- busy_donated_old,
- busy_stolen_old,
- idle_stolen_old;
-
-
-static void save_last_values (perfstat_partition_total_t *lparstats)
-{
- time_old = lparstats->timebase_last;
-
- user_old = lparstats->puser;
- syst_old = lparstats->psys;
- idle_old = lparstats->pidle;
- wait_old = lparstats->pwait;
-
- if (donate_flag)
- {
- idle_donated_old = lparstats->idle_donated_purr;
- busy_donated_old = lparstats->busy_donated_purr;
- busy_stolen_old = lparstats->busy_stolen_purr;
- idle_stolen_old = lparstats->idle_stolen_purr;
- }
-
- if (pool_stats)
- {
- pool_busy_time_old = lparstats->pool_busy_time;
- pool_max_time_old = lparstats->pool_max_time;
- }
-} /* void save_last_values */
+static perfstat_partition_total_t lparstats_old;
static int lpar_config (const char *key, const char *value)
{
static int lpar_init (void)
{
- perfstat_partition_total_t lparstats;
int status;
/* Retrieve the initial metrics. Returns the number of structures filled. */
status = perfstat_partition_total (/* name = */ NULL, /* (must be NULL) */
- &lparstats, sizeof (perfstat_partition_total_t),
+ &lparstats_old, sizeof (perfstat_partition_total_t),
/* number = */ 1 /* (must be 1) */);
if (status != 1)
{
return (-1);
}
- if (!lparstats.type.b.shared_enabled && lparstats.type.b.donate_enabled)
+ if (!lparstats_old.type.b.shared_enabled
+ && lparstats_old.type.b.donate_enabled)
{
donate_flag = 1;
}
- if (pool_stats && !lparstats.type.b.pool_util_authority)
+ if (pool_stats && !lparstats_old.type.b.pool_util_authority)
{
WARNING ("lpar plugin: This partition does not have pool authority. "
"Disabling CPU pool statistics collection.");
pool_stats = 0;
}
- /* Save the initial data */
- save_last_values (&lparstats);
-
return (0);
} /* int lpar_init */
}
/* Number of ticks since we last run. */
- ticks = lparstats.timebase_last - time_old;
+ ticks = lparstats.timebase_last - lparstats_old.timebase_last;
if (ticks == 0)
{
- /* The stats have not been updated. Return now to avoid dividing by zero */
+ /* The stats have not been updated. Return now to avoid
+ * dividing by zero */
return (0);
}
lpar_submit ("entitled", entitled_proc_capacity);
/* The number of ticks actually spent in the various states */
- user_ticks = lparstats.puser - user_old;
- syst_ticks = lparstats.psys - syst_old;
- wait_ticks = lparstats.pwait - wait_old;
- idle_ticks = lparstats.pidle - idle_old;
+ user_ticks = lparstats.puser - lparstats_old.puser;
+ syst_ticks = lparstats.psys - lparstats_old.psys;
+ wait_ticks = lparstats.pwait - lparstats_old.pwait;
+ idle_ticks = lparstats.pidle - lparstats_old.pidle;
consumed_ticks = user_ticks + syst_ticks + wait_ticks + idle_ticks;
lpar_submit ("user", (double) user_ticks / (double) ticks);
/* FYI: PURR == Processor Utilization of Resources Register
* SPURR == Scaled PURR */
- idle_donated_ticks = lparstats.idle_donated_purr - idle_donated_old;
- busy_donated_ticks = lparstats.busy_donated_purr - busy_donated_old;
- idle_stolen_ticks = lparstats.idle_stolen_purr - idle_stolen_old;
- busy_stolen_ticks = lparstats.busy_stolen_purr - busy_stolen_old;
+ idle_donated_ticks = lparstats.idle_donated_purr - lparstats_old.idle_donated_purr;
+ busy_donated_ticks = lparstats.busy_donated_purr - lparstats_old.busy_donated_purr;
+ idle_stolen_ticks = lparstats.idle_stolen_purr - lparstats_old.idle_stolen_purr;
+ busy_stolen_ticks = lparstats.busy_stolen_purr - lparstats_old.busy_stolen_purr;
lpar_submit ("idle_donated", (double) idle_donated_ticks / (double) ticks);
lpar_submit ("busy_donated", (double) busy_donated_ticks / (double) ticks);
u_longlong_t pool_max_ns;
u_longlong_t pool_idle_ns = 0;
- pool_busy_ns = lparstats.pool_busy_time - pool_busy_time_old;
- pool_max_ns = lparstats.pool_max_time - pool_max_time_old;
+ pool_busy_ns = lparstats.pool_busy_time - lparstats_old.pool_busy_time;
+ pool_max_ns = lparstats.pool_max_time - lparstats_old.pool_max_time;
if (pool_max_ns > pool_busy_ns)
pool_idle_ns = pool_max_ns - pool_busy_ns;
lpar_submit (typinst, NS_TO_TICKS ((double) pool_idle_ns) / (double) ticks);
}
- save_last_values (&lparstats);
+ memcpy (&lparstats_old, &lparstats, sizeof (lparstats_old));
return (0);
} /* int lpar_read */