Re: 2.6.23-rc2-mm1: rcutorture xtime usage

Paul E. McKenney
2007-08-11T04:47:23Z

On Fri, Aug 10, 2007 at 05:29:49PM -0700, Paul E. McKenney wrote:
>
> Errmmm... No joy.
>
> ERROR: "cpu_clock" [kernel/rcutorture.ko] undefined!
>
> Turns out that cpu_clock also ain't exported, and rcutorture.c is
> a module. Would adding an EXPORT_SYMBOL_GPL() as in the patch below
> be acceptable?

Except that the old xtime symbol was EXPORT_SYMBOL() rather than my
proposed EXPORT_SYMBOL_GPL() for the equivalent new cpu_clock().

Sigh!!! I will leave this one for others to sort out.

Andrew, please consider this patch withdrawn and apply the version that
does not rely on time for entropy. Please let me know if you would like
me to resend it.

Thanx, Paul

> If not, I have a tested patch to rcutorture.c that leverages statistical
> counters. Your choice.
>
> Thanx, Paul
>
> Add an EXPORT_SYMBOL_GPL() for cpu_clock() and make rcutorture.c use it.
> Compiles, but not yet tested.
>
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
>
> rcutorture.c | 8 ++------
> sched.c | 2 ++
> 2 files changed, 4 insertions(+), 6 deletions(-)
>
> diff -urpNa -X dontdiff linux-2.6.23-rc2/kernel/rcutorture.c linux-2.6.23-rc2-rcutorturesched/kernel/rcutorture.c
> --- linux-2.6.23-rc2/kernel/rcutorture.c 2007-08-03 19:49:55.000000000 -0700
> +++ linux-2.6.23-rc2-rcutorturesched/kernel/rcutorture.c 2007-08-10 17:15:22.000000000 -0700
> @@ -42,7 +42,6 @@
> #include <linux/notifier.h>
> #include <linux/freezer.h>
> #include <linux/cpu.h>
> -#include <linux/random.h>
> #include <linux/delay.h>
> #include <linux/byteorder/swabb.h>
> #include <linux/stat.h>
> @@ -166,16 +165,13 @@ struct rcu_random_state {
>
> /*
> * Crude but fast random-number generator. Uses a linear congruential
> - * generator, with occasional help from get_random_bytes().
> + * generator, with occasional help from cpu_clock().
> */
> static unsigned long
> rcu_random(struct rcu_random_state *rrsp)
> {
> - long refresh;
> -
> if (--rrsp->rrs_count < 0) {
> - get_random_bytes(&refresh, sizeof(refresh));
> - rrsp->rrs_state += refresh;
> + rrsp->rrs_state += (unsigned long)cpu_clock(smp_processor_id());
> rrsp->rrs_count = RCU_RANDOM_REFRESH;
> }
> rrsp->rrs_state = rrsp->rrs_state * RCU_RANDOM_MULT + RCU_RANDOM_ADD;
> diff -urpNa -X dontdiff linux-2.6.23-rc2/kernel/sched.c linux-2.6.23-rc2-rcutorturesched/kernel/sched.c
> --- linux-2.6.23-rc2/kernel/sched.c 2007-08-03 19:49:55.000000000 -0700
> +++ linux-2.6.23-rc2-rcutorturesched/kernel/sched.c 2007-08-10 17:22:57.000000000 -0700
> @@ -394,6 +394,8 @@ unsigned long long cpu_clock(int cpu)
> return now;
> }
>
> +EXPORT_SYMBOL_GPL(cpu_clock);
> +
> #ifdef CONFIG_FAIR_GROUP_SCHED
> /* Change a task's ->cfs_rq if it moves across CPUs */
> static inline void set_task_cfs_rq(struct task_struct *p)