Thursday, February 5, 2009

Drawing CPU part of boot chart

I'm using kstat for drawing CPU part of boot chart (see my previous posts). I need cpu values for "user","nice","system","idle","iowait" in such order (sample output):
cpu 8 0 141 313 230 0 0 

I've written the small kstat utility and added its call in a bootchartd script (utility writes /var/log/bootchart/proc_stat.log):
#include <kstat.h>
#include <sys/sysinfo.h>
#include <stdio.h>
#include <string.h>

static kstat_ctl_t *kc;
static kstat_t *ksp;

static unsigned int cpu_user, cpu_system, cpu_nice, cpu_idle, cpu_iowait;

int main(int argc, char **argv) {
cpu_stat_t *cpu_stat;

kc = kstat_open();

if (kc != NULL) {

ksp = kstat_lookup(kc, "cpu_stat", 0, "cpu_stat0");
if (ksp != NULL && ksp->ks_type == KSTAT_TYPE_RAW)
if (kstat_read(kc, ksp, NULL) != -1 &&  
ksp->ks_data_size == sizeof(cpu_stat_t))
  cpu_stat = (cpu_stat_t *)ksp->ks_data;
  cpu_system = cpu_stat->cpu_sysinfo.cpu[CPU_KERNEL] ;

 printf("cpu  %d %d %d %d %d 0 0\n",

Sample boot chart for MilaX:

Tuesday, February 3, 2009

Reducing Boot Time

In the last MilaX release (0.3.3) I've tried to reduce boot time from kernel startup to desktop environment up and running. I left only necessary SMF-services for LiveCD and changed startup sequence. The main idea - network services and compressed usr filesystem mounting can start after X server starting.
Here the services list after full booting:
STATE          STIME    FMRI
online         19:49:10 svc:/system/svc/restarter:default
online         19:49:13 svc:/network/datalink-management:default
online         19:49:14 svc:/system/filesystem/usr:default
online         19:49:14 svc:/system/filesystem/root:default
online         19:49:14 svc:/system/utmp:default
online         19:49:21 svc:/system/device/local:default
online         19:49:21 svc:/milestone/devices:default
online         19:49:22 svc:/system/filesystem/minimal:default
online         19:49:22 svc:/system/manifest-import:default
online         19:49:23 svc:/system/rmtmpfiles:default
online         19:49:23 svc:/system/filesystem/local:default
online         19:49:23 svc:/application/xserver:default
online         19:49:24 svc:/system/console-login:default
online         19:49:49 svc:/network/initial:default
online         19:49:57 svc:/network/loopback:default
online         19:49:58 svc:/system/system-log:default
online         19:50:01 svc:/system/cryptosvc:default
online         19:50:04 svc:/system/dbus:default
online         19:50:04 svc:/network/physical:default
online         19:50:06 svc:/system/identity:node
online         19:50:14 svc:/network/rpc/bind:default
online         19:50:18 svc:/system/hal:default
online         19:50:20 svc:/network/inetd:default
online         19:50:25 svc:/network/rpc/gss:default

Bootchart picture offers some details:

Certainly USB-booting yields the best results: for example on my DELL notebook I've booted MilaX from usb stick for 27 seconds. I've not included Moinak's code for compressed ramdisk support in this release, but I hope that I'll make it further.

How to determine PXE mac address when booting illumos via PXELinux/iPXE

In illumos, if you need to determine the interface which was used for booting via PXE then it's possible to use "boot-mac" pro...