Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
- index ab3a42cd29ef..d71a5f09c8a3 100644
- --- a/drivers/cpufreq/Makefile
- +++ b/drivers/cpufreq/Makefile
- @@ -1,5 +1,5 @@
- # CPUfreq core
- -obj-$(CONFIG_CPU_FREQ) += cpufreq.o freq_table.o
- +obj-$(CONFIG_CPU_FREQ) += cpufreq.o freq_table.o hrtimers.o
- # CPUfreq stats
- obj-$(CONFIG_CPU_FREQ_STAT) += cpufreq_stats.o
- diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
- index 0d6fbb3099b4..e320a725ecff 100644
- --- a/drivers/cpufreq/cpufreq.c
- +++ b/drivers/cpufreq/cpufreq.c
- @@ -933,6 +933,22 @@ static ssize_t show_bios_limit(struct cpufreq_policy *policy, char *buf)
- return sprintf(buf, "%u\n", policy->cpuinfo.max_freq);
- }
- +void queue_hrtimers(unsigned int);
- +static ssize_t store_test_delay(struct cpufreq_policy *policy,
- + const char *buf, size_t count)
- +{
- + unsigned int delay;
- + int ret;
- +
- + ret = sscanf(buf, "%u", &delay);
- + if (ret != 1)
- + return -EINVAL;
- +
- + queue_hrtimers(delay);
- +
- + return count;
- +}
- +
- cpufreq_freq_attr_ro_perm(cpuinfo_cur_freq, 0400);
- cpufreq_freq_attr_ro(cpuinfo_min_freq);
- cpufreq_freq_attr_ro(cpuinfo_max_freq);
- @@ -947,6 +963,7 @@ cpufreq_freq_attr_rw(scaling_min_freq);
- cpufreq_freq_attr_rw(scaling_max_freq);
- cpufreq_freq_attr_rw(scaling_governor);
- cpufreq_freq_attr_rw(scaling_setspeed);
- +cpufreq_freq_attr_wo(test_delay);
- static struct attribute *default_attrs[] = {
- &cpuinfo_min_freq.attr,
- @@ -960,6 +977,7 @@ static struct attribute *default_attrs[] = {
- &scaling_driver.attr,
- &scaling_available_governors.attr,
- &scaling_setspeed.attr,
- + &test_delay.attr,
- NULL
- };
- diff --git a/drivers/cpufreq/hrtimers.c b/drivers/cpufreq/hrtimers.c
- new file mode 100644
- index 000000000000..bb37ebed0d8a
- --- /dev/null
- +++ b/drivers/cpufreq/hrtimers.c
- @@ -0,0 +1,41 @@
- +#define pr_fmt(fmt) "hrtimer Migration Tester: " fmt
- +
- +#include <linux/ktime.h>
- +#include <linux/module.h>
- +#include <linux/moduleparam.h>
- +#include <linux/printk.h>
- +#include <linux/smp.h>
- +#include <linux/hrtimer.h>
- +#include <linux/sched/clock.h>
- +
- +#define TIMER_DELAY 5
- +
- +static struct hrtimer hrtimer;
- +u64 start;
- +unsigned int delay;
- +
- +static enum hrtimer_restart hrtimer_fn(struct hrtimer *hrtimer)
- +{
- + u64 diff;
- +
- + diff = local_clock() - start;
- +
- + pr_info("%s: %d: expected: %u, got: %llu\n", __func__, __LINE__, delay, diff);
- +
- + return HRTIMER_NORESTART;
- +}
- +
- +void queue_hrtimers(unsigned int data)
- +{
- + int cpu = raw_smp_processor_id();
- + ktime_t expires = ktime_set(0, data);
- +
- + delay = data;
- + pr_info("%s: queuing hrtimer from cpu: %d\n", __func__, cpu);
- +
- + hrtimer_init(&hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- + hrtimer.function = hrtimer_fn;
- +
- + start = local_clock();
- + hrtimer_start(&hrtimer, expires, HRTIMER_MODE_REL);
- +}
Add Comment
Please, Sign In to add comment