History

torture: Periodically pause in stutter_wait()

Running locktorture scenario LOCK05 results in hangs: tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --torture lock --duration 3 --configs LOCK05 The lock_torture_writer() kthreads set themselves to MAX_NICE while running SCHED_OTHER. Other locktorture kthreads run at default niceness, also SCHED_OTHER. This results in these other locktorture kthreads indefinitely preempting the lock_torture_writer() kthreads. Note that the cond_resched() in the stutter_wait() function's loop is ineffective because this scenario is built with CONFIG_PREEMPT=y. It is not clear that such indefinite preemption is supposed to happen, but in the meantime this commit prevents kthreads running in stutter_wait() from being completely CPU-bound, thus allowing the other threads to get some CPU in a timely fashion. This commit also uses hrtimers to provide very short sleeps to avoid degrading the sudden-on testing that stutter is supposed to provide.

Paul E. McKenney committed 6 years ago

Commit 19012b71 parent 3480d671 file · +14 −2Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/torture.c+14−2
@@ -602,8 +602,11 @@ static int stutter_gap; · 601 unmodified lines
602602 */
603603 bool stutter_wait(const char *title)
604604 {
605− int spt;
605+ ktime_t delay;
606+ unsigned int i = 0;
607+ int oldnice;
606608 bool ret = false;
609+ int spt;
607610
608611 cond_resched_tasks_rcu_qs();
609612 spt = READ_ONCE(stutter_pause_test);
@@ -612,8 +615,17 @@ bool stutter_wait(const char *title) · 2 unmodified lines
612615 if (spt == 1) {
613616 schedule_timeout_interruptible(1);
614617 } else if (spt == 2) {
615− while (READ_ONCE(stutter_pause_test))
618+ oldnice = task_nice(current);
619+ set_user_nice(current, MAX_NICE);
620+ while (READ_ONCE(stutter_pause_test)) {
621+ if (!(i++ & 0xffff)) {
622+ set_current_state(TASK_INTERRUPTIBLE);
623+ delay = 10 * NSEC_PER_USEC;
624+ schedule_hrtimeout(&delay, HRTIMER_MODE_REL);
625+ }
616626 cond_resched();
627+ }
628+ set_user_nice(current, oldnice);
617629 } else {
618630 schedule_timeout_interruptible(round_jiffies_relative(HZ));
619631 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t