Changeset 7337 in vbox for trunk/src/VBox/Runtime/r0drv
- Timestamp:
- Mar 6, 2008 5:27:51 PM (17 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/linux/mp-r0drv-linux.c
r7325 r7337 32 32 33 33 #include <iprt/mp.h> 34 #include <iprt/cpuset.h> 34 35 #include <iprt/err.h> 35 36 #include <iprt/asm.h> … … 43 44 44 45 45 /** 46 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER 47 * 46 RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu) 47 { 48 return idCpu < NR_CPUS ? idCpu : -1; 49 } 50 51 52 RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu) 53 { 54 return iCpu < NR_CPUS ? iCpu : NIL_RTCPUID; 55 } 56 57 58 RTDECL(RTCPUID) RTMpGetMaxCpuId(void) 59 { 60 return NR_CPUS - 1; //??? 61 } 62 63 64 RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu) 65 { 66 #ifdef CONFIG_SMP 67 if (RT_UNLIKELY(idCpu >= NR_CPUS)) 68 return false; 69 # ifdef cpu_online 70 return cpu_online(idCpu); 71 # else /* 2.4: */ 72 return cpu_online_map & RT_BIT_64(idCpu); 73 # endif 74 #else 75 return idCpu == RTMpCpuId(); 76 #endif 77 } 78 79 80 RTDECL(bool) RTMpDoesCpuExist(RTCPUID idCpu) 81 { 82 #ifdef CONFIG_SMP 83 if (RT_UNLIKELY(idCpu >= NR_CPUS)) 84 return false; 85 # ifdef CONFIG_HOTPLUG_CPU /* introduced & uses cpu_present */ 86 return cpu_present(idCpu); 87 # elif defined(cpu_possible) 88 return cpu_possible(idCpu); 89 # else /* 2.4: */ 90 return idCpu < (RTCPUID)smp_num_cpus; 91 # endif 92 #else 93 return idCpu == RTMpCpuId(); 94 #endif 95 } 96 97 98 RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet) 99 { 100 RTCPUID idCpu; 101 102 RTCpuSetEmpty(pSet); 103 idCpu = RTMpGetMaxCpuId(); 104 do 105 { 106 if (RTMpDoesCpuExist(idCpu)) 107 RTCpuSetAdd(pSet, idCpu); 108 } while (idCpu-- > 0); 109 return pSet; 110 } 111 112 113 RTDECL(RTCPUID) RTMpGetCount(void) 114 { 115 #ifdef CONFIG_SMP 116 # if defined(CONFIG_HOTPLUG_CPU) /* introduced & uses cpu_present */ 117 return num_present_cpus(); 118 # elif defined(num_possible_cpus) 119 return num_possible_cpus(); 120 # elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) 121 return smp_num_cpus; 122 # else 123 RTCPUSET Set; 124 RTMpGetSet(&Set); 125 return RTCpuSetCount(pSet); 126 # endif 127 #else 128 return 1; 129 #endif 130 } 131 132 133 RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet) 134 { 135 #ifdef CONFIG_SMP 136 RTCPUID idCpu; 137 138 RTCpuSetEmpty(pSet); 139 idCpu = RTMpGetMaxCpuId(); 140 do 141 { 142 if (RTMpIsCpuOnline(idCpu)) 143 RTCpuSetAdd(pSet, idCpu); 144 } while (idCpu-- > 0); 145 #else 146 RTCpuSetEmpty(pSet); 147 RTCpuSetAdd(pSet, RTMpCpuId()); 148 #endif 149 return pSet; 150 } 151 152 153 RTDECL(RTCPUID) RTMpGetOnlineCount(void) 154 { 155 #ifdef CONFIG_SMP 156 # if defined(num_online_cpus) 157 return num_online_cpus(); 158 # else 159 RTCPUSET Set; 160 RTMpGetOnlineSet(&Set); 161 return RTCpuSetCount(pSet); 162 # endif 163 #else 164 return 1; 165 #endif 166 } 167 168 169 /** 170 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER 171 * 48 172 * @param pvInfo Pointer to the RTMPARGS package. 49 173 */ … … 52 176 PRTMPARGS pArgs = (PRTMPARGS)pvInfo; 53 177 ASMAtomicIncU32(&pArgs->cHits); 54 pArgs->pfnWorker(smp_process _id(), pArgs->pvUser1, pArgs->pvUser2);178 pArgs->pfnWorker(smp_processor_id(), pArgs->pvUser1, pArgs->pvUser2); 55 179 } 56 180 … … 66 190 Args.cHits = 0; 67 191 68 #if 1 /** @todo the proper checks for 2.6.x. */192 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) 69 193 rc = on_each_cpu(rtmpLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */); 70 194
Note:
See TracChangeset
for help on using the changeset viewer.