- kpcd->running = kpc_get_running();
- kpcd->counterc = kpc_get_cpu_counters(0, kpcd->running,
- &kpcd->curcpu, kpcd->counterv);
- if( !sample_config )
+ if (kpc_threads_counting) {
+ kpc_switch_context(old, new);
+ }
+ if (kperf_cswitch_callback_set) {
+ kperf_switch_context(old, new);
+ }
+}
+
+void
+kperf_kpc_cswitch_callback_update(void)
+{
+ kperf_kpc_cswitch_set = kperf_cswitch_callback_set ||
+ kpc_threads_counting;
+}
+
+void
+kperf_kpc_thread_sample(struct kpcdata *kpcd, int sample_config)
+{
+ kpcd->running = kpc_get_running();
+ /* let kpc_get_curthread_counters set the correct count */
+ kpcd->counterc = KPC_MAX_COUNTERS;
+ if (kpc_get_curthread_counters(&kpcd->counterc,
+ kpcd->counterv)) {
+ /* if thread counters aren't ready, default to 0 */
+ memset(kpcd->counterv, 0,
+ sizeof(uint64_t) * kpcd->counterc);
+ }
+ /* help out Instruments */
+ if (!sample_config) {