From mboxrd@z Thu Jan 1 00:00:00 1970 From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers) Date: Thu, 15 Sep 2011 11:08:50 -0400 Subject: [ltt-dev] [PATCH 03/10] use get_cpu_call_rcu_data() for get_call_rcu_data() In-Reply-To: <2e8c002c93f9f0105fef603f48c13aa8c2b6d807.1316064655.git.laijs@cn.fujitsu.com> References: <2e8c002c93f9f0105fef603f48c13aa8c2b6d807.1316064655.git.laijs@cn.fujitsu.com> Message-ID: <20110915150850.GD3813@Krystal> * Lai Jiangshan (laijs at cn.fujitsu.com) wrote: > Signed-off-by: Lai Jiangshan [ Impact: refactor duplicated code ] Merged, thanks! Mathieu > --- > urcu-call-rcu-impl.h | 19 +++++++------------ > 1 files changed, 7 insertions(+), 12 deletions(-) > > 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(); > } > > -- > 1.7.4.4 > -- Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com