mptable.h (71818) | mptable.h (72200) |
---|---|
1/* 2 * Copyright (c) 1996, by Steve Passe 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 8 unchanged lines hidden (view full) --- 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 * | 1/* 2 * Copyright (c) 1996, by Steve Passe 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 8 unchanged lines hidden (view full) --- 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 * |
25 * $FreeBSD: head/sys/i386/include/mptable.h 71818 2001-01-30 04:02:28Z peter $ | 25 * $FreeBSD: head/sys/i386/include/mptable.h 72200 2001-02-09 06:11:45Z bmilekic $ |
26 */ 27 28#include "opt_cpu.h" 29#include "opt_user_ldt.h" 30 31#ifdef SMP 32#include <machine/smptests.h> 33#else --- 2229 unchanged lines hidden (view full) --- 2263 2264 /* 2265 * Set curproc to our per-cpu idleproc so that mutexes have 2266 * something unique to lock with. 2267 */ 2268 PCPU_SET(curproc, PCPU_GET(idleproc)); 2269 2270 /* lock against other AP's that are waking up */ | 26 */ 27 28#include "opt_cpu.h" 29#include "opt_user_ldt.h" 30 31#ifdef SMP 32#include <machine/smptests.h> 33#else --- 2229 unchanged lines hidden (view full) --- 2263 2264 /* 2265 * Set curproc to our per-cpu idleproc so that mutexes have 2266 * something unique to lock with. 2267 */ 2268 PCPU_SET(curproc, PCPU_GET(idleproc)); 2269 2270 /* lock against other AP's that are waking up */ |
2271 mtx_enter(&ap_boot_mtx, MTX_SPIN); | 2271 mtx_lock_spin(&ap_boot_mtx); |
2272 2273 /* BSP may have changed PTD while we're waiting for the lock */ 2274 cpu_invltlb(); 2275 2276 smp_cpus++; 2277 2278#if defined(I586_CPU) && !defined(NO_F00F_HACK) 2279 lidt(&r_idt); --- 32 unchanged lines hidden (view full) --- 2312 */ 2313 if (smp_cpus == mp_ncpus) { 2314 invltlb_ok = 1; 2315 smp_started = 1; /* enable IPI's, tlb shootdown, freezes etc */ 2316 smp_active = 1; /* historic */ 2317 } 2318 2319 /* let other AP's wake up now */ | 2272 2273 /* BSP may have changed PTD while we're waiting for the lock */ 2274 cpu_invltlb(); 2275 2276 smp_cpus++; 2277 2278#if defined(I586_CPU) && !defined(NO_F00F_HACK) 2279 lidt(&r_idt); --- 32 unchanged lines hidden (view full) --- 2312 */ 2313 if (smp_cpus == mp_ncpus) { 2314 invltlb_ok = 1; 2315 smp_started = 1; /* enable IPI's, tlb shootdown, freezes etc */ 2316 smp_active = 1; /* historic */ 2317 } 2318 2319 /* let other AP's wake up now */ |
2320 mtx_exit(&ap_boot_mtx, MTX_SPIN); | 2320 mtx_unlock_spin(&ap_boot_mtx); |
2321 2322 /* wait until all the AP's are up */ 2323 while (smp_started == 0) 2324 ; /* nothing */ 2325 2326 microuptime(PCPU_PTR(switchtime)); 2327 PCPU_SET(switchticks, ticks); 2328 2329 /* ok, now grab sched_lock and enter the scheduler */ 2330 enable_intr(); | 2321 2322 /* wait until all the AP's are up */ 2323 while (smp_started == 0) 2324 ; /* nothing */ 2325 2326 microuptime(PCPU_PTR(switchtime)); 2327 PCPU_SET(switchticks, ticks); 2328 2329 /* ok, now grab sched_lock and enter the scheduler */ 2330 enable_intr(); |
2331 mtx_enter(&sched_lock, MTX_SPIN); | 2331 mtx_lock_spin(&sched_lock); |
2332 cpu_throw(); /* doesn't return */ 2333 2334 panic("scheduler returned us to ap_init"); 2335} 2336 2337#ifdef BETTER_CLOCK 2338 2339#define CHECKSTATE_USER 0 --- 317 unchanged lines hidden (view full) --- 2657 */ 2658 2659 CTR1(KTR_SMP, "forward_signal(%p)", p); 2660 2661 if (!smp_started || !invltlb_ok || cold || panicstr) 2662 return; 2663 if (!forward_signal_enabled) 2664 return; | 2332 cpu_throw(); /* doesn't return */ 2333 2334 panic("scheduler returned us to ap_init"); 2335} 2336 2337#ifdef BETTER_CLOCK 2338 2339#define CHECKSTATE_USER 0 --- 317 unchanged lines hidden (view full) --- 2657 */ 2658 2659 CTR1(KTR_SMP, "forward_signal(%p)", p); 2660 2661 if (!smp_started || !invltlb_ok || cold || panicstr) 2662 return; 2663 if (!forward_signal_enabled) 2664 return; |
2665 mtx_enter(&sched_lock, MTX_SPIN); | 2665 mtx_lock_spin(&sched_lock); |
2666 while (1) { 2667 if (p->p_stat != SRUN) { | 2666 while (1) { 2667 if (p->p_stat != SRUN) { |
2668 mtx_exit(&sched_lock, MTX_SPIN); | 2668 mtx_unlock_spin(&sched_lock); |
2669 return; 2670 } 2671 id = p->p_oncpu; | 2669 return; 2670 } 2671 id = p->p_oncpu; |
2672 mtx_exit(&sched_lock, MTX_SPIN); | 2672 mtx_unlock_spin(&sched_lock); |
2673 if (id == 0xff) 2674 return; 2675 map = (1<<id); 2676 checkstate_need_ast |= map; 2677 selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED); 2678 i = 0; 2679 while ((checkstate_need_ast & map) != 0) { 2680 /* spin */ 2681 i++; 2682 if (i > 100000) { 2683#if 0 2684 printf("forward_signal: dropped ast 0x%x\n", 2685 checkstate_need_ast & map); 2686#endif 2687 break; 2688 } 2689 } | 2673 if (id == 0xff) 2674 return; 2675 map = (1<<id); 2676 checkstate_need_ast |= map; 2677 selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED); 2678 i = 0; 2679 while ((checkstate_need_ast & map) != 0) { 2680 /* spin */ 2681 i++; 2682 if (i > 100000) { 2683#if 0 2684 printf("forward_signal: dropped ast 0x%x\n", 2685 checkstate_need_ast & map); 2686#endif 2687 break; 2688 } 2689 } |
2690 mtx_enter(&sched_lock, MTX_SPIN); | 2690 mtx_lock_spin(&sched_lock); |
2691 if (id == p->p_oncpu) { | 2691 if (id == p->p_oncpu) { |
2692 mtx_exit(&sched_lock, MTX_SPIN); | 2692 mtx_unlock_spin(&sched_lock); |
2693 return; 2694 } 2695 } 2696} 2697 2698void 2699forward_roundrobin(void) 2700{ --- 161 unchanged lines hidden (view full) --- 2862void 2863smp_rendezvous(void (* setup_func)(void *), 2864 void (* action_func)(void *), 2865 void (* teardown_func)(void *), 2866 void *arg) 2867{ 2868 2869 /* obtain rendezvous lock */ | 2693 return; 2694 } 2695 } 2696} 2697 2698void 2699forward_roundrobin(void) 2700{ --- 161 unchanged lines hidden (view full) --- 2862void 2863smp_rendezvous(void (* setup_func)(void *), 2864 void (* action_func)(void *), 2865 void (* teardown_func)(void *), 2866 void *arg) 2867{ 2868 2869 /* obtain rendezvous lock */ |
2870 mtx_enter(&smp_rv_mtx, MTX_SPIN); | 2870 mtx_lock_spin(&smp_rv_mtx); |
2871 2872 /* set static function pointers */ 2873 smp_rv_setup_func = setup_func; 2874 smp_rv_action_func = action_func; 2875 smp_rv_teardown_func = teardown_func; 2876 smp_rv_func_arg = arg; 2877 smp_rv_waiters[0] = 0; 2878 smp_rv_waiters[1] = 0; 2879 2880 /* 2881 * signal other processors, which will enter the IPI with interrupts off 2882 */ 2883 all_but_self_ipi(XRENDEZVOUS_OFFSET); 2884 2885 /* call executor function */ 2886 smp_rendezvous_action(); 2887 2888 /* release lock */ | 2871 2872 /* set static function pointers */ 2873 smp_rv_setup_func = setup_func; 2874 smp_rv_action_func = action_func; 2875 smp_rv_teardown_func = teardown_func; 2876 smp_rv_func_arg = arg; 2877 smp_rv_waiters[0] = 0; 2878 smp_rv_waiters[1] = 0; 2879 2880 /* 2881 * signal other processors, which will enter the IPI with interrupts off 2882 */ 2883 all_but_self_ipi(XRENDEZVOUS_OFFSET); 2884 2885 /* call executor function */ 2886 smp_rendezvous_action(); 2887 2888 /* release lock */ |
2889 mtx_exit(&smp_rv_mtx, MTX_SPIN); | 2889 mtx_unlock_spin(&smp_rv_mtx); |
2890} 2891 2892void 2893release_aps(void *dummy __unused) 2894{ 2895 atomic_store_rel_int(&aps_ready, 1); 2896} 2897 2898SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL); | 2890} 2891 2892void 2893release_aps(void *dummy __unused) 2894{ 2895 atomic_store_rel_int(&aps_ready, 1); 2896} 2897 2898SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL); |