From 84e11fbc2ecc103d5f1ca02dea2588754cb03438 Mon Sep 17 00:00:00 2001 From: Bosko Milekic Date: Sun, 28 Jan 2001 03:41:01 +0000 Subject: [PATCH] Move the setting of curproc to idleproc up earlier in ap_init(). The problem is that a mutex lock, prior to this change, is acquired before the curproc is set to idleproc, so we mess ourselves up by calling the mutex lock routine with curproc == NULL. Moving it up after the aps_ready spin-wait has us hopefully setting it after idleproc is setup. Solved by: jake (the allmighty) :-) --- sys/amd64/amd64/mp_machdep.c | 12 ++++++------ sys/amd64/amd64/mptable.c | 12 ++++++------ sys/amd64/include/mptable.h | 12 ++++++------ sys/i386/i386/mp_machdep.c | 12 ++++++------ sys/i386/i386/mptable.c | 12 ++++++------ sys/i386/include/mptable.h | 12 ++++++------ sys/kern/subr_smp.c | 12 ++++++------ 7 files changed, 42 insertions(+), 42 deletions(-) diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index b9e96fe6e0c..95ad79ab300 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -2266,6 +2266,12 @@ ap_init(void) while (!aps_ready) /* spin */ ; + /* + * Set curproc to our per-cpu idleproc so that mutexes have + * something unique to lock with. + */ + PCPU_SET(curproc, PCPU_GET(idleproc)); + /* lock against other AP's that are waking up */ mtx_enter(&ap_boot_mtx, MTX_SPIN); @@ -2322,12 +2328,6 @@ ap_init(void) while (smp_started == 0) ; /* nothing */ - /* - * Set curproc to our per-cpu idleproc so that mutexes have - * something unique to lock with. - */ - PCPU_SET(curproc, PCPU_GET(idleproc)); - microuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); diff --git a/sys/amd64/amd64/mptable.c b/sys/amd64/amd64/mptable.c index b9e96fe6e0c..95ad79ab300 100644 --- a/sys/amd64/amd64/mptable.c +++ b/sys/amd64/amd64/mptable.c @@ -2266,6 +2266,12 @@ ap_init(void) while (!aps_ready) /* spin */ ; + /* + * Set curproc to our per-cpu idleproc so that mutexes have + * something unique to lock with. + */ + PCPU_SET(curproc, PCPU_GET(idleproc)); + /* lock against other AP's that are waking up */ mtx_enter(&ap_boot_mtx, MTX_SPIN); @@ -2322,12 +2328,6 @@ ap_init(void) while (smp_started == 0) ; /* nothing */ - /* - * Set curproc to our per-cpu idleproc so that mutexes have - * something unique to lock with. - */ - PCPU_SET(curproc, PCPU_GET(idleproc)); - microuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); diff --git a/sys/amd64/include/mptable.h b/sys/amd64/include/mptable.h index b9e96fe6e0c..95ad79ab300 100644 --- a/sys/amd64/include/mptable.h +++ b/sys/amd64/include/mptable.h @@ -2266,6 +2266,12 @@ ap_init(void) while (!aps_ready) /* spin */ ; + /* + * Set curproc to our per-cpu idleproc so that mutexes have + * something unique to lock with. + */ + PCPU_SET(curproc, PCPU_GET(idleproc)); + /* lock against other AP's that are waking up */ mtx_enter(&ap_boot_mtx, MTX_SPIN); @@ -2322,12 +2328,6 @@ ap_init(void) while (smp_started == 0) ; /* nothing */ - /* - * Set curproc to our per-cpu idleproc so that mutexes have - * something unique to lock with. - */ - PCPU_SET(curproc, PCPU_GET(idleproc)); - microuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index b9e96fe6e0c..95ad79ab300 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -2266,6 +2266,12 @@ ap_init(void) while (!aps_ready) /* spin */ ; + /* + * Set curproc to our per-cpu idleproc so that mutexes have + * something unique to lock with. + */ + PCPU_SET(curproc, PCPU_GET(idleproc)); + /* lock against other AP's that are waking up */ mtx_enter(&ap_boot_mtx, MTX_SPIN); @@ -2322,12 +2328,6 @@ ap_init(void) while (smp_started == 0) ; /* nothing */ - /* - * Set curproc to our per-cpu idleproc so that mutexes have - * something unique to lock with. - */ - PCPU_SET(curproc, PCPU_GET(idleproc)); - microuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); diff --git a/sys/i386/i386/mptable.c b/sys/i386/i386/mptable.c index b9e96fe6e0c..95ad79ab300 100644 --- a/sys/i386/i386/mptable.c +++ b/sys/i386/i386/mptable.c @@ -2266,6 +2266,12 @@ ap_init(void) while (!aps_ready) /* spin */ ; + /* + * Set curproc to our per-cpu idleproc so that mutexes have + * something unique to lock with. + */ + PCPU_SET(curproc, PCPU_GET(idleproc)); + /* lock against other AP's that are waking up */ mtx_enter(&ap_boot_mtx, MTX_SPIN); @@ -2322,12 +2328,6 @@ ap_init(void) while (smp_started == 0) ; /* nothing */ - /* - * Set curproc to our per-cpu idleproc so that mutexes have - * something unique to lock with. - */ - PCPU_SET(curproc, PCPU_GET(idleproc)); - microuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); diff --git a/sys/i386/include/mptable.h b/sys/i386/include/mptable.h index b9e96fe6e0c..95ad79ab300 100644 --- a/sys/i386/include/mptable.h +++ b/sys/i386/include/mptable.h @@ -2266,6 +2266,12 @@ ap_init(void) while (!aps_ready) /* spin */ ; + /* + * Set curproc to our per-cpu idleproc so that mutexes have + * something unique to lock with. + */ + PCPU_SET(curproc, PCPU_GET(idleproc)); + /* lock against other AP's that are waking up */ mtx_enter(&ap_boot_mtx, MTX_SPIN); @@ -2322,12 +2328,6 @@ ap_init(void) while (smp_started == 0) ; /* nothing */ - /* - * Set curproc to our per-cpu idleproc so that mutexes have - * something unique to lock with. - */ - PCPU_SET(curproc, PCPU_GET(idleproc)); - microuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index b9e96fe6e0c..95ad79ab300 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -2266,6 +2266,12 @@ ap_init(void) while (!aps_ready) /* spin */ ; + /* + * Set curproc to our per-cpu idleproc so that mutexes have + * something unique to lock with. + */ + PCPU_SET(curproc, PCPU_GET(idleproc)); + /* lock against other AP's that are waking up */ mtx_enter(&ap_boot_mtx, MTX_SPIN); @@ -2322,12 +2328,6 @@ ap_init(void) while (smp_started == 0) ; /* nothing */ - /* - * Set curproc to our per-cpu idleproc so that mutexes have - * something unique to lock with. - */ - PCPU_SET(curproc, PCPU_GET(idleproc)); - microuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks);