Re: [PATCH 1/2] hrtimers: extend hrtimer base code to handle morethen 2 clockids

From: Thomas Gleixner
Date: Tue Feb 01 2011 - 09:10:34 EST


On Mon, 31 Jan 2011, John Stultz wrote:
> @@ -53,11 +53,10 @@
> /*
> * The timer bases:
> *
> - * Note: If we want to add new timer bases, we have to skip the two
> - * clock ids captured by the cpu-timers. We do this by holding empty
> - * entries rather than doing math adjustment of the clock ids.
> - * This ensures that we capture erroneous accesses to these clock ids
> - * rather than moving them into the range of valid clock id's.
> + * There are more clockids then hrtimer bases. Thus, we index

s/then/than/

> + * into the timer bases by the hrtimer_base_type enum. When trying
> + * to reach a base using a clockid, hrtimer_clockid_to_base()
> + * is used to convert from clockid to the proper hrtimer_base_type.
> */
> DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
> {
> @@ -77,6 +76,24 @@ DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
> }
> };
>
> +static int hrtimer_clock_to_base_table[MAX_CLOCKS];
> +
> +static inline int hrtimer_clockid_to_base(clockid_t clock_id)
> +{
> + int ret = hrtimer_clock_to_base_table[clock_id];
> +
> + if(ret == -1) {
> + WARN_ON(1);
> + /* We just hit an invalid clock base,
> + * but returning -1 isn't safe, so
> + * return the _REALTIME base
> + */

How can this happen ?

> + return HRTIMER_BASE_REALTIME;
> + }
> + return ret;
> +}

Thanks,

tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/