Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 26562
b: refs/heads/master
c: 6810b54
h: refs/heads/master
v: v3
  • Loading branch information
Andi Kleen authored and Linus Torvalds committed May 8, 2006
1 parent 882d12b commit 74636d4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 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: ac71d12c990526b01ef6cfe50907ef8530a30331
refs/heads/master: 6810b548b25114607e0814612d84125abccc0a4f
28 changes: 20 additions & 8 deletions trunk/drivers/cpufreq/cpufreq_ondemand.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ static unsigned int dbs_enable; /* number of CPUs using this policy */
static DEFINE_MUTEX (dbs_mutex);
static DECLARE_WORK (dbs_work, do_dbs_timer, NULL);

static struct workqueue_struct *dbs_workq;

struct dbs_tuners {
unsigned int sampling_rate;
unsigned int sampling_down_factor;
Expand Down Expand Up @@ -364,23 +366,29 @@ static void do_dbs_timer(void *data)
mutex_lock(&dbs_mutex);
for_each_online_cpu(i)
dbs_check_cpu(i);
schedule_delayed_work(&dbs_work,
usecs_to_jiffies(dbs_tuners_ins.sampling_rate));
queue_delayed_work(dbs_workq, &dbs_work,
usecs_to_jiffies(dbs_tuners_ins.sampling_rate));
mutex_unlock(&dbs_mutex);
}

static inline void dbs_timer_init(void)
{
INIT_WORK(&dbs_work, do_dbs_timer, NULL);
schedule_delayed_work(&dbs_work,
usecs_to_jiffies(dbs_tuners_ins.sampling_rate));
if (!dbs_workq)
dbs_workq = create_singlethread_workqueue("ondemand");
if (!dbs_workq) {
printk(KERN_ERR "ondemand: Cannot initialize kernel thread\n");
return;
}
queue_delayed_work(dbs_workq, &dbs_work,
usecs_to_jiffies(dbs_tuners_ins.sampling_rate));
return;
}

static inline void dbs_timer_exit(void)
{
cancel_delayed_work(&dbs_work);
return;
if (dbs_workq)
cancel_rearming_delayed_workqueue(dbs_workq, &dbs_work);
}

static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
Expand Down Expand Up @@ -489,8 +497,12 @@ static int __init cpufreq_gov_dbs_init(void)

static void __exit cpufreq_gov_dbs_exit(void)
{
/* Make sure that the scheduled work is indeed not running */
flush_scheduled_work();
/* Make sure that the scheduled work is indeed not running.
Assumes the timer has been cancelled first. */
if (dbs_workq) {
flush_workqueue(dbs_workq);
destroy_workqueue(dbs_workq);
}

cpufreq_unregister_governor(&cpufreq_gov_dbs);
}
Expand Down

0 comments on commit 74636d4

Please sign in to comment.