/* probe locking header file
- * Copyright (C) 2009 Red Hat Inc.
+ * Copyright (C) 2009-2010 Red Hat Inc.
*
* This file is part of systemtap, and is free software. You can
* redistribute it and/or modify it under the terms of the GNU General
while (!write_trylock(locks[i].lock)) {
if (++retries > MAXTRYLOCK)
goto skip;
- ndelay (TRYLOCKDELAY);
+ udelay (TRYLOCKDELAY);
}
else
while (!read_trylock(locks[i].lock)) {
if (++retries > MAXTRYLOCK)
goto skip;
- ndelay (TRYLOCKDELAY);
+ udelay (TRYLOCKDELAY);
}
}
return 1;
return ret;
}
+
+#ifndef STP_TIMELOCKDELAY
+#define STP_TIMELOCKDELAY 100 /* ns */
+#endif
+#ifndef STP_TIMELOCKTRIES
+#define STP_TIMELOCKTRIES 10 /* total 1 us */
+#endif
+
static int64_t
_stp_gettimeofday_ns(void)
{
if (!stp_time)
return -1;
- preempt_disable();
+ preempt_disable(); /* XXX: why? Isn't this is only run from probe handlers? */
time = per_cpu_ptr(stp_time, smp_processor_id());
seq = read_seqbegin(&time->lock);
base = time->base_ns;
last = time->base_cycles;
freq = time->freq;
- while (unlikely(read_seqretry(&time->lock, seq))) {
- if (unlikely(++i >= MAXTRYLOCK))
- return 0;
- ndelay(TRYLOCKDELAY);
+ while (unlikely(read_seqretry(&time->lock, seq))) {
+ if (/* very */ unlikely(++i >= STP_TIMELOCKTRIES)) {
+ preempt_enable_no_resched();
+ _stp_warn ("_stp_gettimofday_ns seqlock timeout; see STP_TIMELOCK*");
+ return 0;
+ }
+ ndelay(STP_TIMELOCKDELAY);
seq = read_seqbegin(&time->lock);
base = time->base_ns;
last = time->base_cycles;
s.op->newline() << "#ifndef MAXACTION_INTERRUPTIBLE";
s.op->newline() << "#define MAXACTION_INTERRUPTIBLE (MAXACTION * 10)";
s.op->newline() << "#endif";
- s.op->newline() << "#ifndef MAXTRYLOCK";
- s.op->newline() << "#define MAXTRYLOCK MAXACTION";
- s.op->newline() << "#endif";
s.op->newline() << "#ifndef TRYLOCKDELAY";
- s.op->newline() << "#define TRYLOCKDELAY 100";
+ s.op->newline() << "#define TRYLOCKDELAY 10 /* microseconds */";
+ s.op->newline() << "#endif";
+ s.op->newline() << "#ifndef MAXTRYLOCK";
+ s.op->newline() << "#define MAXTRYLOCK 100 /* 1 millisecond total */";
s.op->newline() << "#endif";
s.op->newline() << "#ifndef MAXMAPENTRIES";
s.op->newline() << "#define MAXMAPENTRIES 2048";