From: Lai Jiangshan Date: Thu, 15 Sep 2011 15:10:31 +0000 (-0400) Subject: use get_cpu_call_rcu_data() for get_call_rcu_data() X-Git-Tag: v0.6.5~19 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9744f3bb981bc24873b662c35d555197f1cf82b5;p=userspace-rcu.git use get_cpu_call_rcu_data() for get_call_rcu_data() [ Impact: refactor duplicated code ] Signed-off-by: Lai Jiangshan Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu-call-rcu-impl.h b/urcu-call-rcu-impl.h index e0a8fd8..1fbce98 100644 --- a/urcu-call-rcu-impl.h +++ b/urcu-call-rcu-impl.h @@ -435,22 +435,17 @@ struct call_rcu_data *get_default_call_rcu_data(void) */ struct call_rcu_data *get_call_rcu_data(void) { - int curcpu; - static int warned = 0; + struct call_rcu_data *crd; if (thread_call_rcu_data != NULL) return thread_call_rcu_data; - if (maxcpus <= 0) - return get_default_call_rcu_data(); - curcpu = sched_getcpu(); - if (!warned && (curcpu < 0 || maxcpus <= curcpu)) { - fprintf(stderr, "[error] liburcu: gcrd CPU # out of range\n"); - warned = 1; + + if (maxcpus > 0) { + crd = get_cpu_call_rcu_data(sched_getcpu()); + if (crd) + return crd; } - if (curcpu >= 0 && maxcpus > curcpu && - per_cpu_call_rcu_data != NULL && - per_cpu_call_rcu_data[curcpu] != NULL) - return per_cpu_call_rcu_data[curcpu]; + return get_default_call_rcu_data(); }