Ejemplo n.º 1
0
static int cmd_host_cpu_stats(struct vmm_chardev *cdev)
{
	int rc;
	char str[16];
	u32 c, p, khz, util;
	unsigned long hwid;

	vmm_cprintf(cdev, "----------------------------------------"
			  "----------------------------------------\n");
	vmm_cprintf(cdev, " %4s %14s %15s %13s %12s %16s\n",
			  "CPU#", "HWID", "Speed (MHz)", "Util. (%)",
			  "IRQs (%)", "Active VCPUs");
	vmm_cprintf(cdev, "----------------------------------------"
			  "----------------------------------------\n");

	for_each_online_cpu(c) {
		vmm_cprintf(cdev, " %4d", c);

		rc = vmm_smp_map_hwid(c, &hwid);
		if (rc)
			return rc;
		vmm_snprintf(str, sizeof(str), "0x%lx", hwid);
		vmm_cprintf(cdev, " %14s", str);

		khz = vmm_delay_estimate_cpu_khz(c);
		vmm_cprintf(cdev, " %11d.%03d",
			    udiv32(khz, 1000), umod32(khz, 1000));

		util = udiv64(vmm_scheduler_idle_time(c) * 1000,
			      vmm_scheduler_get_sample_period(c));
		util = (util > 1000) ? 1000 : util;
		util = 1000 - util;
		vmm_cprintf(cdev, " %11d.%01d",
			    udiv32(util, 10), umod32(util, 10));

		util = udiv64(vmm_scheduler_irq_time(c) * 1000,
			      vmm_scheduler_get_sample_period(c));
		util = (util > 1000) ? 1000 : util;
		vmm_cprintf(cdev, " %10d.%01d",
			    udiv32(util, 10), umod32(util, 10));

		util = 1;
		for (p = VMM_VCPU_MIN_PRIORITY;
		     p <= VMM_VCPU_MAX_PRIORITY; p++) {
			util += vmm_scheduler_ready_count(c, p);
		}
		vmm_cprintf(cdev, " %15d ", util);

		vmm_cprintf(cdev, "\n");
	}

	vmm_cprintf(cdev, "----------------------------------------"
			  "----------------------------------------\n");

	return VMM_OK;
}
Ejemplo n.º 2
0
static void cmd_host_cpu_stats(struct vmm_chardev *cdev)
{
    u32 c, p, khz, util;

    vmm_cprintf(cdev, "----------------------------------------"
                "-------------------------\n");
    vmm_cprintf(cdev, " %4s %15s %13s %12s %16s\n",
                "CPU#", "Speed (MHz)", "Util. (%)",
                "IRQs (%)", "Active VCPUs");
    vmm_cprintf(cdev, "----------------------------------------"
                "-------------------------\n");

    for_each_online_cpu(c) {
        vmm_cprintf(cdev, " %4d", c);

        khz = vmm_delay_estimate_cpu_khz(c);
        vmm_cprintf(cdev, " %11d.%03d",
                    udiv32(khz, 1000), umod32(khz, 1000));

        util = udiv64(vmm_scheduler_idle_time(c) * 1000,
                      vmm_scheduler_get_sample_period(c));
        util = (util > 1000) ? 1000 : util;
        util = 1000 - util;
        vmm_cprintf(cdev, " %11d.%01d",
                    udiv32(util, 10), umod32(util, 10));

        util = udiv64(vmm_scheduler_irq_time(c) * 1000,
                      vmm_scheduler_get_sample_period(c));
        util = (util > 1000) ? 1000 : util;
        vmm_cprintf(cdev, " %10d.%01d",
                    udiv32(util, 10), umod32(util, 10));

        util = 1;
        for (p = VMM_VCPU_MIN_PRIORITY; p <= VMM_VCPU_MAX_PRIORITY; p++) {
            util += vmm_scheduler_ready_count(c, p);
        }
        vmm_cprintf(cdev, " %15d ", util);

        vmm_cprintf(cdev, "\n");
    }

    vmm_cprintf(cdev, "----------------------------------------"
                "-------------------------\n");
}