PRIVATE sprof_save_sample(struct proc * p)
{
- struct sprof_sample s;
+ struct sprof_sample *s;
- s.proc = p->p_endpoint;
- s.pc = (void *) p->p_reg.pc;
+ s = (struct sprof_sample *) (sprof_sample_buffer + sprof_info.mem_used);
- /* Store sample (process name and program counter). */
- data_copy(KERNEL, (vir_bytes) &s,
- sprof_ep, sprof_data_addr_vir + sprof_info.mem_used,
- sizeof(s));
+ s->proc = p->p_endpoint;
+ s->pc = (void *) p->p_reg.pc;
- sprof_info.mem_used += sizeof(s);
+ sprof_info.mem_used += sizeof(struct sprof_sample);
}
PRIVATE sprof_save_proc(struct proc * p)
{
- struct sprof_proc s;
+ struct sprof_proc * s;
- s.proc = p->p_endpoint;
- memcpy(s.name, p->p_name, P_NAME_LEN);
+ s = (struct sprof_proc *) (sprof_sample_buffer + sprof_info.mem_used);
- /* Store sample (process name and program counter). */
- data_copy(KERNEL, (vir_bytes) &s,
- sprof_ep, sprof_data_addr_vir + sprof_info.mem_used,
- sizeof(s));
+ s->proc = p->p_endpoint;
+ memcpy(&s->name, p->p_name, P_NAME_LEN);
- sprof_info.mem_used += sizeof(s);
+ sprof_info.mem_used += sizeof(struct sprof_proc);
}
PRIVATE void profile_sample(struct proc * p)
return;
/* Check if enough memory available before writing sample. */
- if (sprof_info.mem_used + sizeof(sprof_info) > sprof_mem_size) {
+ if (sprof_info.mem_used + sizeof(sprof_info) +
+ 2*sizeof(struct sprof_sample) +
+ 2*sizeof(struct sprof_sample) > sprof_mem_size) {
sprof_info.mem_used = -1;
return;
}
#include "arch_watchdog.h"
+#define SAMPLE_BUFFER_SIZE (64 << 20)
+EXTERN char sprof_sample_buffer[SAMPLE_BUFFER_SIZE];
+
EXTERN int sprofiling; /* whether profiling is running */
EXTERN int sprofiling_type; /* whether profiling is running */
EXTERN int sprof_mem_size; /* available user memory for data */
sprof_info.system_samples = 0;
sprof_info.user_samples = 0;
- sprof_mem_size = m_ptr->PROF_MEM_SIZE;
+ sprof_mem_size = m_ptr->PROF_MEM_SIZE < SAMPLE_BUFFER_SIZE ?
+ m_ptr->PROF_MEM_SIZE : SAMPLE_BUFFER_SIZE;
switch (sprofiling_type = m_ptr->PROF_INTR_TYPE) {
case PROF_RTC:
data_copy(KERNEL, (vir_bytes) &sprof_info,
sprof_ep, sprof_info_addr_vir, sizeof(sprof_info));
+ data_copy(KERNEL, (vir_bytes) sprof_sample_buffer,
+ sprof_ep, sprof_data_addr_vir, sprof_info.mem_used);
clean_seen_flag();