Using the cpc Provider

Examples of cpc provider usage follow.

Example 11-1 Showing Application Instructions on an AMD Platform

The script displays instructions executed by applications on an AMD platform.

cpc:::FR_retired_x86_instr_w_excp_intr-user-10000
{
        @[execname] = count();
}

# ./user-insts.d
dtrace: script './user-insts.d' matched 1 probe
^C
[chop]
  init                                                            138
  dtrace                                                          175
  nis_cachemgr                                                    179
  automountd                                                      183
  intrd                                                           235
  run-mozilla.sh                                                  306
  thunderbird                                                     316
  Xorg                                                            453
  thunderbird-bin                                                2370
  sshd                                                           8114

Example 11-2 Showing Kernel Cycle Usage on an AMD Platform

The following example shows a kernel profiled by cycle usage on an AMD platform.

cpc:::BU_cpu_clk_unhalted-kernel-10000
{
        @[func(arg0)] = count();
}
 
# ./kern-cycles.d                                
dtrace: script './kern-cycles.d' matched 1 probe
^C
[chop]
  genunix`vpm_sync_pages                                       478948
  genunix`vpm_unmap_pages                                      496626
  genunix`vpm_map_pages                                        640785
  unix`mutex_delay_default                                     916703
  unix`hat_kpm_page2va                                         988880
  tmpfs`rdtmp                                                  991252
  unix`hat_page_setattr                                       1077717
  unix`page_try_reclaim_lock                                  1213379
  genunix`free_vpmap                                          1914810
  genunix`get_vpmap                                           2417896
  unix`page_lookup_create                                     3992197
  unix`mutex_enter                                            5595647
  unix`do_copy_fault_nta                                     27803554

Example 11-3 Describing User-Mode Cache Misses on an AMD Platform

This example describes user-mode L2 cache misses and the functions that generated the cache misses on an AMD platform. The predicate ensures that you only sample function names when the probe was fired by the brendan executable.

cpc:::BU_fill_req_missed_L2-all-0x7-10000
/execname == "brendan"/
{
	@[ufunc(arg1)] = count();
}

./brendan-l2miss.d
dtrace: script './brendan-l2miss.d' matched 1 probe
CPU     ID                    FUNCTION:NAME
^C

  brendan`func_gamma                                               930
  brendan`func_beta                                               1578
  brendan`func_alpha                                              2945

You can have the same result with the following probe name format.

cpc:::BU_fill_req_missed_L2-all-umask_0x7-10000
 / execname == "brendan" /
 {
	@[ufunc(arg1)] = count();
 }

Example 11-4 Describing a Generic Event on an AMD Platform

This example describes a generic event PAPI_l2_dcm to indicate the interest in L2 data cache misses instead of the platform event.

cpc:::PAPI_l2_dcm-all-10000
/execname == "brendan"/
{
        @[ufunc(arg1)] = count();
}

# ./brendan-generic-l2miss.d
dtrace: script './brendan-generic-l2miss.d' matched 1 probe
^C

  brendan`func_gamma                                              1681
  brendan`func_beta                                               2521
  brendan`func_alpha                                              5068

Example 11-5 Probing Offcore Events on an Intel Platform

The following example probes offcore event on an Intel platform:

cpc:::off_core_response_0-all-msr_offcore_0x3001-10000
 {
	@[execname] = count();
 }

 # ./off_core_event.d
 dtrace: script './off_core_event.d' matched 1 probe 
 ^C 

fmd                                                         3
fsflush                                                    36
sched                                                     175

Example 11-6 Showing the Use of Multiple Attributes

Multiple attributes are allowed using a minus sign (-) between attributes.

The following example sets two attributes to probe L2 miss event in an AMD platform.

cpc:::BU_fill_req_missed_L2-all-umask_0x7-cmask_0x0-10000
 {
	@[execname] = count();
 }

 # ./l2miss.d
 dtrace: script './l2miss.d' matched 1 probe


automountd                                                   1
dtrace                                                       1
fmd                                                          1
in.routed                                                    1
netcfgd                                                      1
nscd                                                         1
sendmail                                                     1
utmpd                                                        1
kcfd                                                         2
syslogd                                                      2
uname                                                        2
file                                                         3
ls                                                           3
sshd                                                         4
zfs                                                          9
bash                                                        10
ksh93                                                       10
ssh                                                         22
fsflush                                                     34
sched                                                       68
beadm                                                      146