Thu Aug 27 18:51:20 2020 UTC ()
npftest: Wait at least one tick in each gc busy wait iteration.

Otherwise the busy wait loop runs a little too fast for the gc about
half the times I run the test.

XXX We should really arrange mstohz to round up!


(riastradh)
diff -r1.1 -r1.2 src/usr.sbin/npf/npftest/libnpftest/npf_gc_test.c

cvs diff -r1.1 -r1.2 src/usr.sbin/npf/npftest/libnpftest/npf_gc_test.c (expand / switch to unified diff)

--- src/usr.sbin/npf/npftest/libnpftest/npf_gc_test.c 2020/05/30 14:16:57 1.1
+++ src/usr.sbin/npf/npftest/libnpftest/npf_gc_test.c 2020/08/27 18:51:20 1.2
@@ -212,27 +212,27 @@ run_worker_tests(npf_t *npf) @@ -212,27 +212,27 @@ run_worker_tests(npf_t *npf)
212 test_npf = kmem_zalloc(sizeof(npf_t), KM_SLEEP); 212 test_npf = kmem_zalloc(sizeof(npf_t), KM_SLEEP);
213 atomic_store_release(&test_npf->arg, &task_done); 213 atomic_store_release(&test_npf->arg, &task_done);
214 test_npf->ebr = npf_ebr_create(); 214 test_npf->ebr = npf_ebr_create();
215 215
216 error = npf_worker_addfunc(test_npf, worker_test_task); 216 error = npf_worker_addfunc(test_npf, worker_test_task);
217 assert(error == 0); 217 assert(error == 0);
218 218
219 /* Enlist the NPF instance. */ 219 /* Enlist the NPF instance. */
220 npf_worker_enlist(test_npf); 220 npf_worker_enlist(test_npf);
221 221
222 /* Wait for the task to be done. */ 222 /* Wait for the task to be done. */
223 while (!atomic_load_acquire(&task_done) && retry--) { 223 while (!atomic_load_acquire(&task_done) && retry--) {
224 npf_worker_signal(test_npf); 224 npf_worker_signal(test_npf);
225 kpause("gctest", false, mstohz(1), NULL); 225 kpause("gctest", false, MAX(1, mstohz(1)), NULL);
226 } 226 }
227 227
228 CHECK_TRUE(atomic_load_acquire(&task_done)); 228 CHECK_TRUE(atomic_load_acquire(&task_done));
229 npf_worker_discharge(test_npf); 229 npf_worker_discharge(test_npf);
230 230
231 /* Clear the parameter and signal again. */ 231 /* Clear the parameter and signal again. */
232 atomic_store_release(&test_npf->arg, NULL); 232 atomic_store_release(&test_npf->arg, NULL);
233 npf_worker_signal(test_npf); 233 npf_worker_signal(test_npf);
234 234
235 npf_ebr_destroy(test_npf->ebr); 235 npf_ebr_destroy(test_npf->ebr);
236 kmem_free(test_npf, sizeof(npf_t)); // npfk_destroy() 236 kmem_free(test_npf, sizeof(npf_t)); // npfk_destroy()
237 } 237 }
238 238