Example #1
0
int os_pqos_proc_stop(perf_ctl_t *ctl, perf_task_t *task)
{
	task_pqos_cmt_t *t = (task_pqos_cmt_t *)task;
	track_proc_t *proc;
	track_lwp_t *lwp = NULL;
	boolean_t end;

	if (t->pid == 0)
		proc_pqos_func(NULL, os_pqos_cmt_proc_free);
	else {
		if ((proc = proc_find(t->pid)) == NULL)
			return -1;

		if (t->lwpid == 0)
			os_pqos_cmt_proc_free(proc, NULL, &end);
		else {
			if ((lwp = proc_lwp_find(proc, t->lwpid)) == NULL) {
				proc_refcount_dec(proc);
				return -1;
			}

			os_pqos_cmt_lwp_free(lwp, NULL, &end);
		}

		if (lwp != NULL)
			lwp_refcount_dec(lwp);

		proc_refcount_dec(proc);
	}

	return (0);
}
Example #2
0
static int
pqos_cmt_start(perf_ctl_t *ctl, int pid, int lwpid, int flags)
{
	track_proc_t *proc;
	track_lwp_t *lwp = NULL;
	perf_pqos_t *pqos;
	int ret = -1;

	if ((proc = proc_find(pid)) == NULL)
		return -1;

	if (lwpid == 0) {
		pqos = &proc->pqos;
	} else {
		if ((lwp = proc_lwp_find(proc, lwpid)) == NULL) {
			proc_refcount_dec(proc);
			return -1;
		}

		pqos = &lwp->pqos;
		proc->lwp_pqosed = B_TRUE;
	}

	memset(pqos, 0, sizeof(perf_pqos_t));
	os_pqos_cmt_init(pqos);

	if (flags & PERF_PQOS_FLAG_LLC) {
		if (pf_pqos_occupancy_setup(pqos, pid, lwpid) != 0)
			goto L_EXIT;
	}

	if (flags & PERF_PQOS_FLAG_TOTAL_BW) {
		if (pf_pqos_totalbw_setup(pqos, pid, lwpid) != 0)
			goto L_EXIT;
	}

	if (flags & PERF_PQOS_FLAG_LOCAL_BW) {
		if (pf_pqos_localbw_setup(pqos, pid, lwpid) != 0)
			goto L_EXIT;
	}

	/* ctl->last_ms_pqos = current_ms(); */

	if (pf_pqos_start(pqos) == 0)
		ret = 0;

L_EXIT:
	if (ret != 0)
		pf_pqos_resource_free(pqos);

	if (lwp != NULL)
		lwp_refcount_dec(lwp);

	proc_refcount_dec(proc);

	return ret;
}
Example #3
0
static boolean_t
latnode_data_show(track_proc_t *proc, dyn_latnode_t *dyn, map_entry_t *entry,
	boolean_t *note_out)
{
	win_reg_t *reg;
	track_lwp_t *lwp = NULL;
	char content[WIN_LINECHAR_MAX], intval_buf[16], size_str[32];

	*note_out = B_FALSE;

	if ((dyn->lwpid != 0) &&
	    (lwp = proc_lwp_find(proc, dyn->lwpid)) == NULL) {
		win_warn_msg(WARN_INVALID_LWPID);
		win_note_show(NOTE_INVALID_LWPID);
		*note_out = B_TRUE;
		return (B_FALSE);
	}

	reg = &dyn->msg;
	reg_erase(reg);
	disp_intval(intval_buf, 16);
	(void) snprintf(content, sizeof (content),
	    "Break down of memory area for physical memory on node (interval: %s)",
	    intval_buf);
	reg_line_write(reg, 1, ALIGN_LEFT, content);
	dump_write("\n*** %s\n", content);
	reg_refresh_nout(reg);

	reg = &dyn->note;
	reg_erase(reg);	
	win_size2str(dyn->size, size_str, sizeof (size_str));
	if (lwp != NULL) {
		(void) snprintf(content, sizeof (content),
		    "Memory area(%"PRIX64", %s), thread(%d)",
		    dyn->addr, size_str, lwp->id);
	} else {
		(void) snprintf(content, sizeof (content),
		    "Memory area(%"PRIX64", %s), process(%d)",
		    dyn->addr, size_str, proc->pid);
	}

	reg_line_write(reg, 1, ALIGN_LEFT, content);
	dump_write("\n*** %s\n", content);
	reg_refresh_nout(reg);

	latnode_data_get(proc, lwp, dyn);

	if (lwp != NULL) {
		lwp_refcount_dec(lwp);
	}

	return (B_TRUE);
}
Example #4
0
static int
cpu_ll_smpl(perf_cpu_t *cpu, void *arg)
{
	task_ll_t *task = (task_ll_t *)arg;
	pf_ll_rec_t *record;
	track_proc_t *proc;
	track_lwp_t *lwp;
	int record_num, i;

	pf_ll_record(cpu, s_ll_recbuf, &record_num);
	if (record_num == 0) {
		return (0);
	}

	for (i = 0; i < record_num; i++) {
		record = &s_ll_recbuf[i];
		if ((task->pid != 0) && (task->pid != record->pid)) {
			continue;
		}
		
		if ((task->pid != 0) && (task->lwpid != 0) &&
			(task->lwpid != record->tid)) {
			continue;
		}

		if ((proc = proc_find(record->pid)) == NULL) {
			return (0);
		}

		if ((lwp = proc_lwp_find(proc, record->tid)) == NULL) {
			proc_refcount_dec(proc);
			return (0);
		}

		pthread_mutex_lock(&proc->mutex);

		llrec_add(&proc->llrec_grp, record);
		llrec_add(&lwp->llrec_grp, record);

 		pthread_mutex_unlock(&proc->mutex);
 		lwp_refcount_dec(lwp);
 		proc_refcount_dec(proc);		
	}

	return (0);
}
Example #5
0
int
os_pqos_cmt_smpl(perf_ctl_t *ctl, perf_task_t *task, int *intval_ms)
{
	task_pqos_cmt_t *t = (task_pqos_cmt_t *)task;
	track_proc_t *proc;
	track_lwp_t *lwp = NULL;
	boolean_t end;

	proc_enum_update(0);

	if (t->pid == 0)
		proc_pqos_func(NULL, os_pqos_cmt_proc_smpl);
	else {
		if ((proc = proc_find(t->pid)) == NULL) {
			disp_pqos_cmt_data_ready(0);
			return -1;
		}

		if (t->lwpid == 0)
			os_pqos_cmt_proc_smpl(proc, NULL, &end);
		else {
			if ((lwp = proc_lwp_find(proc, t->lwpid)) == NULL) {
				proc_refcount_dec(proc);
				disp_pqos_cmt_data_ready(0);
				return -1;
			}

			os_pqos_cmt_lwp_smpl(lwp, NULL, &end);
		}

		if (lwp != NULL)
			lwp_refcount_dec(lwp);

		proc_refcount_dec(proc);
	}

	*intval_ms = current_ms() - ctl->last_ms_pqos;
	ctl->last_ms_pqos = current_ms();
	disp_pqos_cmt_data_ready(*intval_ms);

	return (0);
}
Example #6
0
static void
llcallchain_data_show(dyn_win_t *win, boolean_t *note_out)
{
	dyn_llcallchain_t *dyn;
	pid_t pid;
	int lwpid;
	uint64_t size;
	track_proc_t *proc;
	track_lwp_t *lwp = NULL;
	win_reg_t *reg;
	char content[WIN_LINECHAR_MAX], intval_buf[16];
	char size_str[32];

	dyn = (dyn_llcallchain_t *)(win->dyn);
	pid = dyn->pid;
	lwpid = dyn->lwpid;
	size = dyn->size;
	*note_out = B_FALSE;

	if ((proc = proc_find(pid)) == NULL) {
		win_warn_msg(WARN_INVALID_PID);
		win_note_show(NOTE_INVALID_PID);
		*note_out = B_TRUE;
		return;
	}

	if ((lwpid > 0) && ((lwp = proc_lwp_find(proc, lwpid)) == NULL)) {
		proc_refcount_dec(proc);
		win_warn_msg(WARN_INVALID_LWPID);
		win_note_show(NOTE_INVALID_LWPID);
		*note_out = B_TRUE;
		return;
	}

	reg = &dyn->msg;
	reg_erase(reg);	
	disp_intval(intval_buf, 16);
	win_size2str(size, size_str, sizeof (size_str));

	if (lwp == NULL) {
		(void) snprintf(content, WIN_LINECHAR_MAX,
			"Call-chain when process accesses the memory area (pid: %d)"
	    	" (interval: %s)", pid, intval_buf);
	} else {
		(void) snprintf(content, WIN_LINECHAR_MAX,
			"Call-chain when thread accesses the memory area (lwpid: %d)"
	    	" (interval: %s)", lwpid, intval_buf);
	}

	dump_write("\n*** %s\n", content);
	reg_line_write(reg, 1, ALIGN_LEFT, content);
	reg_refresh_nout(reg);

	llcallchain_bufinfo_show(dyn, proc, lwp);
	llcallchain_list_show(dyn, proc, lwp);
	
	if (lwp != NULL) {
		lwp_refcount_dec(lwp);
	}

	proc_refcount_dec(proc);
}
Example #7
0
static int
cpu_profiling_smpl(perf_cpu_t *cpu, void *arg)
{
	pf_profiling_rec_t *record;
	track_proc_t *proc;
	track_lwp_t *lwp;
	node_t *node;
	count_value_t diff;
	int i, j, record_num;

	if (!event_valid(cpu)) {
		return (0);
	}	

	/*
	 * The record is grouped by pid/tid.
	 */
	pf_profiling_record(cpu, s_profiling_recbuf, &record_num);	
	if (record_num == 0) {
		return (0);
	}

	if ((node = node_by_cpu(cpu->cpuid)) == NULL) {
		return (0);
	}
	
	countval_diff_base(cpu, &s_profiling_recbuf[0]);

	for (i = 1; i < record_num; i++) {
		record = &s_profiling_recbuf[i];
		countval_diff(cpu, record, &diff);

		if ((proc = proc_find(record->pid)) == NULL) {
			return (0);
		}

		if ((lwp = proc_lwp_find(proc, record->tid)) == NULL) {
			proc_refcount_dec(proc);
			return (0);
		}

 		pthread_mutex_lock(&proc->mutex);
		for (j = 0; j < COUNT_NUM; j++) {
			if (!s_partpause_enabled) {
				proc_countval_update(proc, cpu->cpuid, j, diff.counts[j]);			
				lwp_countval_update(lwp, cpu->cpuid, j, diff.counts[j]);
				node_countval_update(node, j, diff.counts[j]);
			}

			if ((record->ip_num > 0) &&
				(diff.counts[j] >= g_sample_period[j][g_precise])) {

				/*
				 * The event is overflowed. The call-chain represents
				 * the context when event is overflowed.
				 */
				chain_add(&proc->count_chain, j, diff.counts[j], record->ips,
					record->ip_num);

				chain_add(&lwp->count_chain, j, diff.counts[j], record->ips,
					record->ip_num);
			}
		}		

 		pthread_mutex_unlock(&proc->mutex);
 		lwp_refcount_dec(lwp);
 		proc_refcount_dec(proc);
	}

	return (0);
}