Re: [ck] [PATCH] Timer Top was: i386 No-Idle-Hz aka Dynamic-Ticks 3

Jens Axboe
2005-08-05T06:46:46Z

On Thu, Aug 04 2005, Daniel Petrini wrote:
> +static LIST_HEAD(timer_list);
> +
> +struct timer_top_info {
> + unsigned int func_pointer;
> + unsigned int long counter;
> + struct list_head list;
> +};
> +
> +struct timer_top_info top_info;
> +
> +int account_timer(unsigned int function, struct timer_top_info * top_info)
> +{
> + struct timer_top_info *top;
> +
> + list_for_each_entry (top, &timer_list, list) {
> + /* if it is in the list increment its count */
> + if (top->func_pointer == function) {
> + top->counter += 1;
> + return 0;
> + }
> + }

What protects this list?

> +
> + /* if you are here then it didnt find so inserts in the list */
> +
> + top = kmalloc(sizeof(struct timer_top_info), GFP_KERNEL);
> + if (!top)
> + return -ENOMEM;

You can't use GFP_KERNEL here, you are inside the timer base lock.

--
Jens Axboe