FreeBSD Bugzilla – Attachment 180352 Details for
Bug 217408
Crash on boot due to race between vt_upgrade() and vt_resume_flush_timer()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
This patch makes it more likely we will hit the race condition on bootup. It can be used for seeing the bug and testing fixes.
ncd-3560-repro.diff (text/plain), 5.69 KB, created by
Jonathan T. Looney
on 2017-02-28 00:09:24 UTC
(
hide
)
Description:
This patch makes it more likely we will hit the race condition on bootup. It can be used for seeing the bug and testing fixes.
Filename:
MIME Type:
Creator:
Jonathan T. Looney
Created:
2017-02-28 00:09:24 UTC
Size:
5.69 KB
patch
obsolete
>Index: sys/dev/vt/vt_core.c >=================================================================== >--- sys/dev/vt/vt_core.c (revision 313561) >+++ sys/dev/vt/vt_core.c (working copy) >@@ -36,9 +36,12 @@ > #include "opt_compat.h" > > #include <sys/param.h> >+#include <sys/systm.h> >+#include <sys/bus.h> > #include <sys/consio.h> > #include <sys/eventhandler.h> > #include <sys/fbio.h> >+#include <sys/interrupt.h> > #include <sys/kbio.h> > #include <sys/kdb.h> > #include <sys/kernel.h> >@@ -50,7 +53,8 @@ > #include <sys/proc.h> > #include <sys/random.h> > #include <sys/reboot.h> >-#include <sys/systm.h> >+#include <sys/sched.h> >+#include <sys/smp.h> > #include <sys/terminal.h> > > #include <dev/kbd/kbdreg.h> >@@ -281,7 +285,7 @@ > /* Default to initial value. */ > ms = 1000 / VT_TIMERFREQ; > >- callout_schedule(&vd->vd_timer, hz / (1000 / ms)); >+ callout_schedule_delay(&vd->vd_timer, hz / (1000 / ms)); > } > > void >@@ -1565,6 +1569,46 @@ > return (0); > } > >+static void *mycookie; >+static bool vt_intr_init = false; >+volatile int in_change_font = 0; >+static int change_font_cpu; >+ >+ >+static void >+vt_dummy_intr(void *arg __unused) >+{ >+ int count = 1000; >+ >+ while (count-- && in_change_font && curcpu != change_font_cpu) >+ printf("testing.\n"); >+ if (curcpu == change_font_cpu) >+ printf("exiting early due to same CPU\n"); >+} >+ >+static void >+do_vt_intr_init(void) >+{ >+ struct intr_event *ie; >+ char name[16]; >+ int cpu; >+ >+ if (vt_intr_init) >+ return; >+ vt_intr_init = true; >+ CPU_FOREACH(cpu) { >+ if (cpu == curcpu) >+ continue; >+ snprintf(name, sizeof(name), "test (%d)", cpu); >+ ie = NULL; >+ if (!swi_add(&ie, name, vt_dummy_intr, NULL, SWI_TTY, >+ INTR_MPSAFE, &mycookie)) { >+ intr_event_bind(ie, cpu); >+ break; >+ } >+ } >+} >+ > static int > vt_change_font(struct vt_window *vw, struct vt_font *vf) > { >@@ -2605,6 +2649,7 @@ > } > > } >+ do_vt_intr_init(); > VT_LOCK(vd); > if (vd->vd_curwindow == NULL) > vd->vd_curwindow = vd->vd_windows[VT_CONSWINDOW]; >@@ -2614,14 +2659,20 @@ > /* Attach keyboard. */ > vt_allocate_keyboard(vd); > >+ change_font_cpu = curcpu; >+ atomic_add_acq_int(&in_change_font, 1); >+ swi_sched(mycookie, 0); >+ > /* Init 25 Hz timer. */ > callout_init_mtx(&vd->vd_timer, &vd->vd_lock, 0); > > /* Start timer when everything ready. */ > vd->vd_flags |= VDF_ASYNC; >- callout_reset(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd); >+ callout_reset_delay(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd); > vd->vd_timer_armed = 1; > register_handlers = 1; >+ >+ atomic_store_rel_int(&in_change_font, 0); > } > > VT_UNLOCK(vd); >Index: sys/kern/kern_timeout.c >=================================================================== >--- sys/kern/kern_timeout.c (revision 313561) >+++ sys/kern/kern_timeout.c (working copy) >@@ -1014,8 +1014,8 @@ > * callout_deactivate() - marks the callout as having been serviced > */ > int >-callout_reset_sbt_on(struct callout *c, sbintime_t sbt, sbintime_t prec, >- void (*ftn)(void *), void *arg, int cpu, int flags) >+callout_reset_sbt_on_(struct callout *c, sbintime_t sbt, sbintime_t prec, >+ void (*ftn)(void *), void *arg, int cpu, int flags, bool delay) > { > sbintime_t to_sbt, precision; > struct callout_cpu *cc; >@@ -1149,6 +1149,8 @@ > } > #endif > >+ if (delay) >+ DELAY(10000); > callout_cc_add(c, cc, to_sbt, precision, ftn, arg, cpu, flags); > CTR6(KTR_CALLOUT, "%sscheduled %p func %p arg %p in %d.%08x", > cancelled ? "re" : "", c, c->c_func, c->c_arg, (int)(to_sbt >> 32), >@@ -1174,6 +1176,12 @@ > } > > int >+callout_schedule_delay(struct callout *c, int to_ticks) >+{ >+ return callout_reset_on_delay(c, to_ticks, c->c_func, c->c_arg, c->c_cpu); >+} >+ >+int > _callout_stop_safe(struct callout *c, int flags, void (*drain)(void *)) > { > struct callout_cpu *cc, *old_cc; >Index: sys/sys/callout.h >=================================================================== >--- sys/sys/callout.h (revision 313561) >+++ sys/sys/callout.h (working copy) >@@ -100,8 +100,11 @@ > _callout_init_lock((c), ((rw) != NULL) ? &(rw)->lock_object : \ > NULL, (flags)) > #define callout_pending(c) ((c)->c_iflags & CALLOUT_PENDING) >-int callout_reset_sbt_on(struct callout *, sbintime_t, sbintime_t, >- void (*)(void *), void *, int, int); >+int callout_reset_sbt_on_(struct callout *, sbintime_t, sbintime_t, >+ void (*)(void *), void *, int, int, bool); >+#define callout_reset_sbt_on(c, sbt, pr, fn, arg, cpu, flags) \ >+ callout_reset_sbt_on_((c), (sbt), (pr), (fn), (arg), (cpu), (flags),\ >+ false) > #define callout_reset_sbt(c, sbt, pr, fn, arg, flags) \ > callout_reset_sbt_on((c), (sbt), (pr), (fn), (arg), -1, (flags)) > #define callout_reset_sbt_curcpu(c, sbt, pr, fn, arg, flags) \ >@@ -110,8 +113,13 @@ > #define callout_reset_on(c, to_ticks, fn, arg, cpu) \ > callout_reset_sbt_on((c), tick_sbt * (to_ticks), 0, (fn), (arg), \ > (cpu), C_HARDCLOCK) >+#define callout_reset_on_delay(c, to_ticks, fn, arg, cpu) \ >+ callout_reset_sbt_on_((c), tick_sbt * (to_ticks), 0, (fn), (arg), \ >+ (cpu), C_HARDCLOCK, true) > #define callout_reset(c, on_tick, fn, arg) \ > callout_reset_on((c), (on_tick), (fn), (arg), -1) >+#define callout_reset_delay(c, on_tick, fn, arg) \ >+ callout_reset_on_delay((c), (on_tick), (fn), (arg), -1) > #define callout_reset_curcpu(c, on_tick, fn, arg) \ > callout_reset_on((c), (on_tick), (fn), (arg), PCPU_GET(cpuid)) > #define callout_schedule_sbt_on(c, sbt, pr, cpu, flags) \ >@@ -122,6 +130,7 @@ > #define callout_schedule_sbt_curcpu(c, sbt, pr, flags) \ > callout_schedule_sbt_on((c), (sbt), (pr), PCPU_GET(cpuid), (flags)) > int callout_schedule(struct callout *, int); >+int callout_schedule_delay(struct callout *, int); > int callout_schedule_on(struct callout *, int, int); > #define callout_schedule_curcpu(c, on_tick) \ > callout_schedule_on((c), (on_tick), PCPU_GET(cpuid))
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 217408
: 180352