Changeset 54395 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Feb 23, 2015 5:34:01 PM (10 years ago)
- Location:
- trunk/src/VBox/Runtime/r0drv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/linux/mpnotification-r0drv-linux.c
r44529 r54395 5 5 6 6 /* 7 * Copyright (C) 2008-201 1Oracle Corporation7 * Copyright (C) 2008-2015 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 32 32 #include "internal/iprt.h" 33 33 34 #include <iprt/mp.h>35 34 #include <iprt/asm-amd64-x86.h> 36 35 #include <iprt/err.h> … … 70 69 71 70 /** 72 * Notification wrapper that updates CPU states and invokes our notification73 * callbacks.74 *75 * @param idCpu The CPU Id.76 * @param pvUser1 Pointer to the notifier_block (unused).77 * @param pvUser2 The notification event.78 * @remarks This can be invoked in interrupt context.79 */80 static DECLCALLBACK(void) rtMpNotificationLinuxOnCurrentCpu(RTCPUID idCpu, void *pvUser1, void *pvUser2)81 {82 unsigned long ulNativeEvent = *(unsigned long *)pvUser2;83 NOREF(pvUser1);84 85 AssertRelease(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));86 AssertReleaseMsg(idCpu == RTMpCpuId(), /* ASSUMES iCpu == RTCPUID */87 ("idCpu=%u RTMpCpuId=%d ApicId=%d\n", idCpu, RTMpCpuId(), ASMGetApicId() ));88 89 switch (ulNativeEvent)90 {91 # ifdef CPU_DOWN_FAILED92 case CPU_DOWN_FAILED:93 # if defined(CPU_TASKS_FROZEN) && defined(CPU_DOWN_FAILED_FROZEN)94 case CPU_DOWN_FAILED_FROZEN:95 # endif96 # endif97 case CPU_ONLINE:98 # if defined(CPU_TASKS_FROZEN) && defined(CPU_ONLINE_FROZEN)99 case CPU_ONLINE_FROZEN:100 # endif101 rtMpNotificationDoCallbacks(RTMPEVENT_ONLINE, idCpu);102 break;103 104 # ifdef CPU_DOWN_PREPARE105 case CPU_DOWN_PREPARE:106 # if defined(CPU_TASKS_FROZEN) && defined(CPU_DOWN_PREPARE_FROZEN)107 case CPU_DOWN_PREPARE_FROZEN:108 # endif109 rtMpNotificationDoCallbacks(RTMPEVENT_OFFLINE, idCpu);110 break;111 # endif112 }113 }114 115 116 /**117 71 * The native callback. 118 72 * … … 121 75 * @param ulNativeEvent The native event. 122 76 * @param pvCpu The cpu id cast into a pointer value. 77 * 123 78 * @remarks This can fire with preemption enabled and on any CPU. 124 79 */ 125 80 static int rtMpNotificationLinuxCallback(struct notifier_block *pNotifierBlock, unsigned long ulNativeEvent, void *pvCpu) 126 81 { 127 int rc;128 82 bool fProcessEvent = false; 129 83 RTCPUID idCpu = (uintptr_t)pvCpu; … … 188 142 return NOTIFY_DONE; 189 143 190 /* 191 * Reschedule the callbacks to fire on the specific CPU with preemption disabled. 192 */ 193 rc = RTMpOnSpecific(idCpu, rtMpNotificationLinuxOnCurrentCpu, pNotifierBlock, &ulNativeEvent); 194 Assert(RT_SUCCESS(rc)); NOREF(rc); 144 switch (ulNativeEvent) 145 { 146 # ifdef CPU_DOWN_FAILED 147 case CPU_DOWN_FAILED: 148 # if defined(CPU_TASKS_FROZEN) && defined(CPU_DOWN_FAILED_FROZEN) 149 case CPU_DOWN_FAILED_FROZEN: 150 # endif 151 # endif 152 case CPU_ONLINE: 153 # if defined(CPU_TASKS_FROZEN) && defined(CPU_ONLINE_FROZEN) 154 case CPU_ONLINE_FROZEN: 155 # endif 156 rtMpNotificationDoCallbacks(RTMPEVENT_ONLINE, idCpu); 157 break; 158 159 # ifdef CPU_DOWN_PREPARE 160 case CPU_DOWN_PREPARE: 161 # if defined(CPU_TASKS_FROZEN) && defined(CPU_DOWN_PREPARE_FROZEN) 162 case CPU_DOWN_PREPARE_FROZEN: 163 # endif 164 rtMpNotificationDoCallbacks(RTMPEVENT_OFFLINE, idCpu); 165 break; 166 # endif 167 } 168 195 169 return NOTIFY_DONE; 196 170 } -
trunk/src/VBox/Runtime/r0drv/solaris/mpnotification-r0drv-solaris.c
r54294 r54395 5 5 6 6 /* 7 * Copyright (C) 2008-201 2Oracle Corporation7 * Copyright (C) 2008-2015 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 64 64 65 65 /** 66 * PFNRTMPWORKER worker for executing Mp events on the target CPU.67 *68 * @param idCpu The current CPU Id.69 * @param pvArg Opaque pointer to event type (online/offline).70 * @param pvIgnored1 Ignored.71 */72 static void rtMpNotificationSolOnCurrentCpu(RTCPUID idCpu, void *pvArg, void *pvIgnored1)73 {74 NOREF(pvIgnored1);75 NOREF(idCpu);76 77 PRTMPARGS pArgs = (PRTMPARGS)pvArg;78 AssertRelease(pArgs && pArgs->idCpu == RTMpCpuId());79 Assert(pArgs->pvUser1);80 Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));81 82 RTMPEVENT enmMpEvent = *(RTMPEVENT *)pArgs->pvUser1;83 rtMpNotificationDoCallbacks(enmMpEvent, pArgs->idCpu);84 }85 86 87 /**88 66 * Solaris callback function for Mp event notification. 89 67 * 68 * @returns Solaris error code. 90 69 * @param CpuState The current event/state of the CPU. 91 * @param iCpu Which CPU is this event for e.70 * @param iCpu Which CPU is this event for. 92 71 * @param pvArg Ignored. 93 72 * 94 73 * @remarks This function assumes index == RTCPUID. 95 * @returns Solaris error code. 74 * We may -not- be firing on the CPU going online/offline and called 75 * with preemption enabled. 96 76 */ 97 77 static int rtMpNotificationCpuEvent(cpu_setup_t CpuState, int iCpu, void *pvArg) 98 78 { 99 79 RTMPEVENT enmMpEvent; 100 101 RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER;102 RTThreadPreemptDisable(&PreemptState);103 80 104 81 /* … … 119 96 return 0; 120 97 121 /* 122 * Since we don't absolutely need to do CPU bound code in any of the CPU offline 123 * notification hooks, run it on the current CPU. Scheduling a callback to execute 124 * on the CPU going offline at this point is too late and will not work reliably. 125 */ 126 bool fRunningOnTargetCpu = iCpu == RTMpCpuId(); 127 if ( fRunningOnTargetCpu == true 128 || enmMpEvent == RTMPEVENT_OFFLINE) 129 { 130 rtMpNotificationDoCallbacks(enmMpEvent, iCpu); 131 } 132 else 133 { 134 /** @todo We should probably be using thread_affinity_set() here, see 135 * cpu_online() code. */ 136 /* 137 * We're not on the target CPU, schedule (synchronous) the event notification callback 138 * to run on the target CPU i.e. the CPU that was online'd. 139 */ 140 RTMPARGS Args; 141 RT_ZERO(Args); 142 Args.pvUser1 = &enmMpEvent; 143 Args.pvUser2 = NULL; 144 Args.idCpu = iCpu; 145 RTMpOnSpecific(iCpu, rtMpNotificationSolOnCurrentCpu, &Args, NULL /* pvIgnored1 */); 146 } 147 148 RTThreadPreemptRestore(&PreemptState); 149 98 rtMpNotificationDoCallbacks(enmMpEvent, iCpu); 150 99 NOREF(pvArg); 151 100 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.