Make n_samples per-cpu. Add an atomic variable in_timer_notify and use it

Sat Aug 12 16:13:05 2006  Søren Sandmann  <sandmann@redhat.com>

	* module/sysprof-module.c: Make n_samples per-cpu. Add an atomic
	variable in_timer_notify and use it to lock out simultaneous timer
	interrupts.

	* stackstash.c (decorate_node): Make decorate_node() static

	* TODO
This commit is contained in:
Søren Sandmann
2006-08-12 20:15:52 +00:00
committed by Søren Sandmann Pedersen
parent 060fd343a8
commit c2f754dfb6
4 changed files with 55 additions and 10 deletions

View File

@ -107,6 +107,8 @@ read_frame (void *frame_pointer, StackFrame *frame)
return 0;
}
DEFINE_PER_CPU (int, n_samples);
#ifdef OLD_PROFILE
static int timer_notify(struct notifier_block * self, unsigned long val, void * data)
#else
@ -118,23 +120,28 @@ timer_notify (struct pt_regs *regs)
struct pt_regs * regs = (struct pt_regs *)data;
#endif
void *frame_pointer;
static int n_samples;
SysprofStackTrace *trace = head;
int i;
int is_user;
StackFrame frame;
int result;
static atomic_t in_timer_notify = ATOMIC_INIT(1);
if ((++n_samples % INTERVAL) != 0)
/* 0: locked, 1: unlocked */
if (((++get_cpu_var(n_samples)) % INTERVAL) != 0)
return 0;
if (!atomic_dec_and_test (&in_timer_notify))
goto out;
is_user = user_mode(regs);
if (!current || current->pid == 0 || !current->mm)
return 0;
goto out;
if (is_user && current->state != TASK_RUNNING)
return 0;
goto out;
memset(trace, 0, sizeof (SysprofStackTrace));
@ -170,7 +177,9 @@ timer_notify (struct pt_regs *regs)
head = &stack_traces[0];
wake_up (&wait_for_trace);
out:
atomic_inc (&in_timer_notify);
return 0;
}