-}
-
-static int lpar_read_shared_partition (const perfstat_partition_total_t *data)
-{
- static counter_t time_old;
- static counter_t user_old;
- static counter_t syst_old;
- static counter_t wait_old;
- static counter_t idle_old;
- static counter_t unav_old;
-
- counter_t user = (counter_t) data->puser;
- counter_t syst = (counter_t) data->psys;
- counter_t wait = (counter_t) data->pwait;
- counter_t idle = (counter_t) data->pidle;
- counter_t unav = 0;
-
- /*
- * On a shared partition, we're "entitled" to a certain amount of
- * processing power, for example 250/100 of a physical CPU. Processing
- * capacity not used by the partition may be assigned to a different
- * partition by the hypervisor, so "idle" is hopefully a very small
- * number.
- *
- * We calculate the amount of ticks assigned to a different partition
- * from the number of ticks we're entitled to and the number of ticks
- * we used up.
- */
- if (time_old != 0)
- {
- counter_t time_diff;
- counter_t entitled_ticks;
- counter_t consumed_ticks;
- counter_t user_diff;
- counter_t syst_diff;
- counter_t wait_diff;
- counter_t idle_diff;
- counter_t unav_diff;
-
- double entitled_pool_capacity;
-
- /* Number of ticks since we last run. */
- time_diff = ((counter_t) data->timebase_last) - time_old;
-
- /* entitled_pool_capacity is in 1/100th of a CPU */
- entitled_pool_capacity = 0.01 * ((double) data->entitled_pool_capacity);
-
- /* The number of ticks this partition would have been entitled to. */
- entitled_ticks = (counter_t) ((entitled_pool_capacity * ((double) time_diff)) + .5);
-
- /* The number of ticks actually spent in the various states */
- user_diff = user - user_old;
- syst_diff = syst - syst_old;
- wait_diff = wait - wait_old;
- idle_diff = idle - idle_old;
- consumed_ticks = user_diff + syst_diff + wait_diff + idle_diff;
-
- /* "uncapped" partitions are allowed to consume more ticks than
- * they are entitled to. */
- if (entitled_ticks >= consumed_ticks)
- unav_diff = entitled_ticks - consumed_ticks;
- else
- unav_diff = 0;
- unav = unav_old + unav_diff;
-
- lpar_submit ("user", user);
- lpar_submit ("system", syst);
- lpar_submit ("wait", wait);
- lpar_submit ("idle", idle);
- lpar_submit ("unavailable", unav);
- }
-
- time_old = (counter_t) data->timebase_last;
- user_old = user;
- syst_old = syst;
- wait_old = wait;
- idle_old = idle;
- unav_old = unav;
-
- return (0);
-} /* int lpar_read_shared_partition */
-
-static int lpar_read_dedicated_partition (const perfstat_partition_total_t *data)
-{
- lpar_submit ("user", (counter_t) data->puser);
- lpar_submit ("system", (counter_t) data->psys);
- lpar_submit ("wait", (counter_t) data->pwait);
- lpar_submit ("idle", (counter_t) data->pidle);
-
- if (data->type.b.donate_enabled)
- {
- /* FYI: PURR == Processor Utilization of Resources Register
- * SPURR == Scaled PURR */
- lpar_submit ("idle_donated", (counter_t) data->idle_donated_purr);
- lpar_submit ("busy_donated", (counter_t) data->busy_donated_purr);
- lpar_submit ("idle_stolen", (counter_t) data->idle_stolen_purr);
- lpar_submit ("busy_stolen", (counter_t) data->busy_stolen_purr);
- }
-
- return (0);
-} /* int lpar_read_dedicated_partition */