vireshk

Untitled

Jul 19th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
  2. index ab3a42cd29ef..d71a5f09c8a3 100644
  3. --- a/drivers/cpufreq/Makefile
  4. +++ b/drivers/cpufreq/Makefile
  5. @@ -1,5 +1,5 @@
  6. # CPUfreq core
  7. -obj-$(CONFIG_CPU_FREQ) += cpufreq.o freq_table.o
  8. +obj-$(CONFIG_CPU_FREQ) += cpufreq.o freq_table.o hrtimers.o
  9.  
  10. # CPUfreq stats
  11. obj-$(CONFIG_CPU_FREQ_STAT) += cpufreq_stats.o
  12. diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
  13. index 0d6fbb3099b4..e320a725ecff 100644
  14. --- a/drivers/cpufreq/cpufreq.c
  15. +++ b/drivers/cpufreq/cpufreq.c
  16. @@ -933,6 +933,22 @@ static ssize_t show_bios_limit(struct cpufreq_policy *policy, char *buf)
  17. return sprintf(buf, "%u\n", policy->cpuinfo.max_freq);
  18. }
  19.  
  20. +void queue_hrtimers(unsigned int);
  21. +static ssize_t store_test_delay(struct cpufreq_policy *policy,
  22. + const char *buf, size_t count)
  23. +{
  24. + unsigned int delay;
  25. + int ret;
  26. +
  27. + ret = sscanf(buf, "%u", &delay);
  28. + if (ret != 1)
  29. + return -EINVAL;
  30. +
  31. + queue_hrtimers(delay);
  32. +
  33. + return count;
  34. +}
  35. +
  36. cpufreq_freq_attr_ro_perm(cpuinfo_cur_freq, 0400);
  37. cpufreq_freq_attr_ro(cpuinfo_min_freq);
  38. cpufreq_freq_attr_ro(cpuinfo_max_freq);
  39. @@ -947,6 +963,7 @@ cpufreq_freq_attr_rw(scaling_min_freq);
  40. cpufreq_freq_attr_rw(scaling_max_freq);
  41. cpufreq_freq_attr_rw(scaling_governor);
  42. cpufreq_freq_attr_rw(scaling_setspeed);
  43. +cpufreq_freq_attr_wo(test_delay);
  44.  
  45. static struct attribute *default_attrs[] = {
  46. &cpuinfo_min_freq.attr,
  47. @@ -960,6 +977,7 @@ static struct attribute *default_attrs[] = {
  48. &scaling_driver.attr,
  49. &scaling_available_governors.attr,
  50. &scaling_setspeed.attr,
  51. + &test_delay.attr,
  52. NULL
  53. };
  54.  
  55. diff --git a/drivers/cpufreq/hrtimers.c b/drivers/cpufreq/hrtimers.c
  56. new file mode 100644
  57. index 000000000000..bb37ebed0d8a
  58. --- /dev/null
  59. +++ b/drivers/cpufreq/hrtimers.c
  60. @@ -0,0 +1,41 @@
  61. +#define pr_fmt(fmt) "hrtimer Migration Tester: " fmt
  62. +
  63. +#include <linux/ktime.h>
  64. +#include <linux/module.h>
  65. +#include <linux/moduleparam.h>
  66. +#include <linux/printk.h>
  67. +#include <linux/smp.h>
  68. +#include <linux/hrtimer.h>
  69. +#include <linux/sched/clock.h>
  70. +
  71. +#define TIMER_DELAY 5
  72. +
  73. +static struct hrtimer hrtimer;
  74. +u64 start;
  75. +unsigned int delay;
  76. +
  77. +static enum hrtimer_restart hrtimer_fn(struct hrtimer *hrtimer)
  78. +{
  79. + u64 diff;
  80. +
  81. + diff = local_clock() - start;
  82. +
  83. + pr_info("%s: %d: expected: %u, got: %llu\n", __func__, __LINE__, delay, diff);
  84. +
  85. + return HRTIMER_NORESTART;
  86. +}
  87. +
  88. +void queue_hrtimers(unsigned int data)
  89. +{
  90. + int cpu = raw_smp_processor_id();
  91. + ktime_t expires = ktime_set(0, data);
  92. +
  93. + delay = data;
  94. + pr_info("%s: queuing hrtimer from cpu: %d\n", __func__, cpu);
  95. +
  96. + hrtimer_init(&hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
  97. + hrtimer.function = hrtimer_fn;
  98. +
  99. + start = local_clock();
  100. + hrtimer_start(&hrtimer, expires, HRTIMER_MODE_REL);
  101. +}
Add Comment
Please, Sign In to add comment