# Profiling FreeBSD during Boot Time using pmcStat



## Shehbaz (Apr 1, 2014)

I want to profile the FreeBSD Kernel Using pmcstat(8) from boot time. I tried `kgmon` but we can only use `kgmon` once the FreeBSD has booted up and we have the shell prompt. I tried enabling the options in the configuration file:

```
options         HWPMC_HOOKS 
device          hwpmc
```

after which I compiled the kernel, and rebooted the kernel. I then tried to check if `pmcstat` can work. I referred to http://software.intel.com/sites/default/files/profiling_debugging_freebsd_kernel_321772.pdf 


```
% pmccontrol -L
pmccontrol: Initialization of the pmc(3) library failed: No such file or directory
```

I then tried 


```
% sudo kldload pmc
kldload: can't load pmc: File exists
```

I think this output may be relevant :


```
% sudo kldstat
Id Refs Address            Size     Name
 1  105 0xffffffff80100000 c04cb8   kernel
 2    5 0xffffffff80d05000 2ca910   platform.ko
 3    8 0xffffffff82000000 498000   common_kmod.ko
```

Any pointers to using `pmcstat`, or using some other good profiling tool which can give time spent on every function from boot time would be very helpful. 

Thanks,
Shehbaz


----------



## SirDice (Apr 2, 2014)

Thread moved to Development as I think it fits better. It may also get more "developer" views.


----------

