Merge tag 'mfd-next-5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
[linux-2.6-microblaze.git] / kernel / torture.c
index 1061492..8562ac1 100644 (file)
@@ -602,18 +602,29 @@ static int stutter_gap;
  */
 bool stutter_wait(const char *title)
 {
-       int spt;
+       ktime_t delay;
+       unsigned int i = 0;
        bool ret = false;
+       int spt;
 
        cond_resched_tasks_rcu_qs();
        spt = READ_ONCE(stutter_pause_test);
        for (; spt; spt = READ_ONCE(stutter_pause_test)) {
-               ret = true;
+               if (!ret) {
+                       sched_set_normal(current, MAX_NICE);
+                       ret = true;
+               }
                if (spt == 1) {
                        schedule_timeout_interruptible(1);
                } else if (spt == 2) {
-                       while (READ_ONCE(stutter_pause_test))
+                       while (READ_ONCE(stutter_pause_test)) {
+                               if (!(i++ & 0xffff)) {
+                                       set_current_state(TASK_INTERRUPTIBLE);
+                                       delay = 10 * NSEC_PER_USEC;
+                                       schedule_hrtimeout(&delay, HRTIMER_MODE_REL);
+                               }
                                cond_resched();
+                       }
                } else {
                        schedule_timeout_interruptible(round_jiffies_relative(HZ));
                }
@@ -629,20 +640,27 @@ EXPORT_SYMBOL_GPL(stutter_wait);
  */
 static int torture_stutter(void *arg)
 {
+       ktime_t delay;
+       DEFINE_TORTURE_RANDOM(rand);
        int wtime;
 
        VERBOSE_TOROUT_STRING("torture_stutter task started");
        do {
                if (!torture_must_stop() && stutter > 1) {
                        wtime = stutter;
-                       if (stutter > HZ + 1) {
+                       if (stutter > 2) {
                                WRITE_ONCE(stutter_pause_test, 1);
-                               wtime = stutter - HZ - 1;
-                               schedule_timeout_interruptible(wtime);
-                               wtime = HZ + 1;
+                               wtime = stutter - 3;
+                               delay = ktime_divns(NSEC_PER_SEC * wtime, HZ);
+                               delay += (torture_random(&rand) >> 3) % NSEC_PER_MSEC;
+                               set_current_state(TASK_INTERRUPTIBLE);
+                               schedule_hrtimeout(&delay, HRTIMER_MODE_REL);
+                               wtime = 2;
                        }
                        WRITE_ONCE(stutter_pause_test, 2);
-                       schedule_timeout_interruptible(wtime);
+                       delay = ktime_divns(NSEC_PER_SEC * wtime, HZ);
+                       set_current_state(TASK_INTERRUPTIBLE);
+                       schedule_hrtimeout(&delay, HRTIMER_MODE_REL);
                }
                WRITE_ONCE(stutter_pause_test, 0);
                if (!torture_must_stop())