Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 224022
b: refs/heads/master
c: dd6414b
h: refs/heads/master
v: v3
  • Loading branch information
Phil Carmody authored and Thomas Gleixner committed Oct 21, 2010
1 parent 8ded0eb commit 3517fea
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2bf1c05e3c406925e498d06da66b4828f0209ea6
refs/heads/master: dd6414b50fa2b1cd247a8aa8f8bd42414b7453e1
25 changes: 25 additions & 0 deletions trunk/include/linux/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ extern struct tvec_base boot_tvec_bases;
#define __TIMER_LOCKDEP_MAP_INITIALIZER(_kn)
#endif

/*
* Note that all tvec_bases are 2 byte aligned and lower bit of
* base in timer_list is guaranteed to be zero. Use the LSB to
* indicate whether the timer is deferrable.
*
* A deferrable timer will work normally when the system is busy, but
* will not cause a CPU to come out of idle just to service it; instead,
* the timer will be serviced when the CPU eventually wakes up with a
* subsequent non-deferrable timer.
*/
#define TBASE_DEFERRABLE_FLAG (0x1)

#define TIMER_INITIALIZER(_function, _expires, _data) { \
.entry = { .prev = TIMER_ENTRY_STATIC }, \
.function = (_function), \
Expand All @@ -59,6 +71,19 @@ extern struct tvec_base boot_tvec_bases;
__FILE__ ":" __stringify(__LINE__)) \
}

#define TBASE_MAKE_DEFERRED(ptr) ((struct tvec_base *) \
((unsigned char *)(ptr) + TBASE_DEFERRABLE_FLAG))

#define TIMER_DEFERRED_INITIALIZER(_function, _expires, _data) {\
.entry = { .prev = TIMER_ENTRY_STATIC }, \
.function = (_function), \
.expires = (_expires), \
.data = (_data), \
.base = TBASE_MAKE_DEFERRED(&boot_tvec_bases), \
__TIMER_LOCKDEP_MAP_INITIALIZER( \
__FILE__ ":" __stringify(__LINE__)) \
}

#define DEFINE_TIMER(_name, _function, _expires, _data) \
struct timer_list _name = \
TIMER_INITIALIZER(_function, _expires, _data)
Expand Down
8 changes: 8 additions & 0 deletions trunk/include/linux/workqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,20 @@ struct execute_work {
.timer = TIMER_INITIALIZER(NULL, 0, 0), \
}

#define __DEFERRED_WORK_INITIALIZER(n, f) { \
.work = __WORK_INITIALIZER((n).work, (f)), \
.timer = TIMER_DEFERRED_INITIALIZER(NULL, 0, 0), \
}

#define DECLARE_WORK(n, f) \
struct work_struct n = __WORK_INITIALIZER(n, f)

#define DECLARE_DELAYED_WORK(n, f) \
struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f)

#define DECLARE_DEFERRED_WORK(n, f) \
struct delayed_work n = __DEFERRED_WORK_INITIALIZER(n, f)

/*
* initialize a work item's function pointer
*/
Expand Down
15 changes: 1 addition & 14 deletions trunk/kernel/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,6 @@ struct tvec_base boot_tvec_bases;
EXPORT_SYMBOL(boot_tvec_bases);
static DEFINE_PER_CPU(struct tvec_base *, tvec_bases) = &boot_tvec_bases;

/*
* Note that all tvec_bases are 2 byte aligned and lower bit of
* base in timer_list is guaranteed to be zero. Use the LSB to
* indicate whether the timer is deferrable.
*
* A deferrable timer will work normally when the system is busy, but
* will not cause a CPU to come out of idle just to service it; instead,
* the timer will be serviced when the CPU eventually wakes up with a
* subsequent non-deferrable timer.
*/
#define TBASE_DEFERRABLE_FLAG (0x1)

/* Functions below help us manage 'deferrable' flag */
static inline unsigned int tbase_get_deferrable(struct tvec_base *base)
{
Expand All @@ -113,8 +101,7 @@ static inline struct tvec_base *tbase_get_base(struct tvec_base *base)

static inline void timer_set_deferrable(struct timer_list *timer)
{
timer->base = ((struct tvec_base *)((unsigned long)(timer->base) |
TBASE_DEFERRABLE_FLAG));
timer->base = TBASE_MAKE_DEFERRED(timer->base);
}

static inline void
Expand Down

0 comments on commit 3517fea

Please sign in to comment.