summaryrefslogtreecommitdiffstats
path: root/core/timebase.c
diff options
context:
space:
mode:
authorJoel Stanley <joel@jms.id.au>2014-09-30 12:59:22 +0930
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-10-01 14:22:37 +1000
commit591b683a255792e3ede0fa304ff89dfb6d6c3496 (patch)
tree6a0ac1808cbec85f417ba70645500a2ee33c4f77 /core/timebase.c
parent2558bb220e7939c1f1e4258d8e07225870c1fd30 (diff)
downloadblackbird-skiboot-591b683a255792e3ede0fa304ff89dfb6d6c3496.tar.gz
blackbird-skiboot-591b683a255792e3ede0fa304ff89dfb6d6c3496.zip
core: make time_wait call pollers if on boot CPU
Instead of running the pollers flat out, instead call them once every 5ms. This helps in situations where pollers are taking locks that are also taken by tasks completing on other CPUs. The 5ms time is arbitrary; it was chosen such that most callers of time_wait will call the pollers at least twice. Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'core/timebase.c')
-rw-r--r--core/timebase.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/core/timebase.c b/core/timebase.c
index fb46bcf4..7e3345f8 100644
--- a/core/timebase.c
+++ b/core/timebase.c
@@ -18,15 +18,31 @@
#include <opal.h>
#include <cpu.h>
-void time_wait(unsigned long duration)
+static void time_wait_poll(unsigned long duration)
{
+ unsigned long remaining = duration;
unsigned long end = mftb() + duration;
+ unsigned long period = msecs_to_tb(5);
+
+ while (tb_compare(mftb(), end) != TB_AAFTERB) {
+ /* Call pollers periodically but not continually to avoid
+ * bouncing cachelines due to lock contention. */
+ if (remaining >= period) {
+ opal_run_pollers();
+ time_wait_nopoll(period);
+ remaining -= period;
+ }
- while(tb_compare(mftb(), end) != TB_AAFTERB) {
- opal_run_pollers();
cpu_relax();
- }
+ }
+}
+void time_wait(unsigned long duration)
+{
+ if (this_cpu() != boot_cpu)
+ time_wait_nopoll(duration);
+ else
+ time_wait_poll(duration);
}
void time_wait_nopoll(unsigned long duration)
OpenPOWER on IntegriCloud