hv: timer: make the timer list be ordered

make the timer list be ordered to speed up expried timer
process and next timer event finding.

Add timer would not schedule timer unless it's the next
timer event.

Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Li, Fei1
2018-04-25 16:47:12 +08:00
committed by Jack Ren
parent 6fc5116776
commit 5df2efad4a
2 changed files with 65 additions and 56 deletions

View File

@@ -48,6 +48,10 @@ struct timer {
void *priv_data; /* func private data */
};
/*
* Don't initialize a timer twice if it has been add to the timer list
* after call add_timer. If u want, delete the timer from the list first.
*/
static inline void initialize_timer(struct timer *timer,
timer_handle_t func,
void *priv_data,
@@ -65,6 +69,9 @@ static inline void initialize_timer(struct timer *timer,
}
}
/*
* Don't call add_timer/del_timer in the timer callback function.
*/
int add_timer(struct timer *timer);
void del_timer(struct timer *timer);