- Timestamp:
- Oct 22, 2018 10:09:05 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/linux/mp-r0drv-linux.c
r70698 r74967 44 44 # define VBOX_NR_CPUMASK_BITS NR_CPUS 45 45 #endif 46 46 47 47 48 RTDECL(RTCPUID) RTMpCpuId(void) … … 217 218 } 218 219 219 220 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) 220 #ifdef CONFIG_SMP 221 222 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) 221 223 /** 222 224 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER, does hit … … 231 233 ASMAtomicIncU32(&pArgs->cHits); 232 234 } 233 # endif235 # endif 234 236 235 237 … … 253 255 } 254 256 257 #endif /* CONFIG_SMP */ 255 258 256 259 RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2) 257 260 { 258 261 IPRT_LINUX_SAVE_EFL_AC(); 259 int rc;260 262 RTMPARGS Args; 261 263 RTCPUSET OnlineSet; 262 264 RTCPUID idCpu; 265 #ifdef CONFIG_SMP 263 266 uint32_t cLoops; 267 #endif 264 268 265 269 RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER; … … 276 280 idCpu = RTMpCpuId(); 277 281 282 #ifdef CONFIG_SMP 278 283 if (RTCpuSetCount(&OnlineSet) > 1) 279 284 { 280 285 /* Fire the function on all other CPUs without waiting for completion. */ 281 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)282 rc = smp_call_function(rtmpLinuxAllWrapper, &Args, 0 /* wait */);283 # else284 rc = smp_call_function(rtmpLinuxAllWrapper, &Args, 0 /* retry */, 0 /* wait */);285 # endif286 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) 287 int rc = smp_call_function(rtmpLinuxAllWrapper, &Args, 0 /* wait */); 288 # else 289 int rc = smp_call_function(rtmpLinuxAllWrapper, &Args, 0 /* retry */, 0 /* wait */); 290 # endif 286 291 Assert(!rc); NOREF(rc); 287 292 } 293 #endif 288 294 289 295 /* Fire the function on this CPU. */ … … 291 297 RTCpuSetDel(Args.pWorkerSet, idCpu); 292 298 299 #ifdef CONFIG_SMP 293 300 /* Wait for all of them finish. */ 294 301 cLoops = 64000; … … 307 314 ASMNopPause(); 308 315 } 316 #endif 309 317 310 318 RTThreadPreemptRestore(&PreemptState); … … 317 325 RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2) 318 326 { 327 #ifdef CONFIG_SMP 319 328 IPRT_LINUX_SAVE_EFL_AC(); 320 329 int rc; … … 329 338 330 339 RTThreadPreemptDisable(&PreemptState); 331 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)340 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) 332 341 rc = smp_call_function(rtmpLinuxWrapper, &Args, 1 /* wait */); 333 # else /* older kernels */342 # else /* older kernels */ 334 343 rc = smp_call_function(rtmpLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */); 335 # endif /* older kernels */344 # endif /* older kernels */ 336 345 RTThreadPreemptRestore(&PreemptState); 337 346 338 347 Assert(rc == 0); NOREF(rc); 339 348 IPRT_LINUX_RESTORE_EFL_AC(); 349 #else 350 RT_NOREF(pfnWorker, pvUser1, pvUser2); 351 #endif 340 352 return VINF_SUCCESS; 341 353 } … … 343 355 344 356 345 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) 357 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) && defined(CONFIG_SMP) 346 358 /** 347 359 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER … … 367 379 RTDECL(int) RTMpOnPair(RTCPUID idCpu1, RTCPUID idCpu2, uint32_t fFlags, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2) 368 380 { 381 #ifdef CONFIG_SMP 369 382 IPRT_LINUX_SAVE_EFL_AC(); 370 383 int rc; … … 387 400 * call wait ourselves. 388 401 */ 389 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)402 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) 390 403 /* 2.6.28 introduces CONFIG_CPUMASK_OFFSTACK */ 391 404 cpumask_var_t DstCpuMask; 392 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)405 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) 393 406 cpumask_t DstCpuMask; 394 # endif407 # endif 395 408 RTCPUID idCpuSelf = RTMpCpuId(); 396 409 bool const fCallSelf = idCpuSelf == idCpu1 || idCpuSelf == idCpu2; … … 403 416 Args.cHits = 0; 404 417 405 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)418 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) 406 419 if (!zalloc_cpumask_var(&DstCpuMask, GFP_KERNEL)) 407 420 return VERR_NO_MEMORY; 408 421 cpumask_set_cpu(idCpu1, DstCpuMask); 409 422 cpumask_set_cpu(idCpu2, DstCpuMask); 410 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)423 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) 411 424 if (!alloc_cpumask_var(&DstCpuMask, GFP_KERNEL)) 412 425 return VERR_NO_MEMORY; … … 414 427 cpumask_set_cpu(idCpu1, DstCpuMask); 415 428 cpumask_set_cpu(idCpu2, DstCpuMask); 416 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)429 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) 417 430 cpus_clear(DstCpuMask); 418 431 cpu_set(idCpu1, DstCpuMask); 419 432 cpu_set(idCpu2, DstCpuMask); 420 # endif421 422 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)433 # endif 434 435 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) 423 436 smp_call_function_many(DstCpuMask, rtmpLinuxWrapperPostInc, &Args, !fCallSelf /* wait */); 424 437 rc = 0; 425 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)438 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) 426 439 rc = smp_call_function_mask(DstCpuMask, rtmpLinuxWrapperPostInc, &Args, !fCallSelf /* wait */); 427 # else /* older kernels */440 # else /* older kernels */ 428 441 rc = smp_call_function(rtMpLinuxOnPairWrapper, &Args, 0 /* retry */, !fCallSelf /* wait */); 429 # endif /* older kernels */442 # endif /* older kernels */ 430 443 Assert(rc == 0); 431 444 … … 454 467 rc = VERR_CPU_IPE_1; 455 468 456 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)469 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) 457 470 free_cpumask_var(DstCpuMask); 458 # endif471 # endif 459 472 } 460 473 /* … … 469 482 IPRT_LINUX_RESTORE_EFL_AC(); 470 483 return rc; 484 485 #else /* !CONFIG_SMP */ 486 RT_NOREF(idCpu1, idCpu2, fFlags, pfnWorker, pvUser1, pvUser2); 487 return VERR_CPU_NOT_FOUND; 488 #endif /* !CONFIG_SMP */ 471 489 } 472 490 RT_EXPORT_SYMBOL(RTMpOnPair); … … 480 498 481 499 482 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) 500 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) && defined(CONFIG_SMP) 483 501 /** 484 502 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER … … 520 538 if (idCpu != RTMpCpuId()) 521 539 { 540 #ifdef CONFIG_SMP 522 541 if (RTMpIsCpuOnline(idCpu)) 523 542 { 524 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)543 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) 525 544 rc = smp_call_function_single(idCpu, rtmpLinuxWrapper, &Args, 1 /* wait */); 526 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)545 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) 527 546 rc = smp_call_function_single(idCpu, rtmpLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */); 528 # else /* older kernels */547 # else /* older kernels */ 529 548 rc = smp_call_function(rtmpOnSpecificLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */); 530 # endif /* older kernels */549 # endif /* older kernels */ 531 550 Assert(rc == 0); 532 551 rc = Args.cHits ? VINF_SUCCESS : VERR_CPU_OFFLINE; 533 552 } 534 553 else 554 #endif /* CONFIG_SMP */ 535 555 rc = VERR_CPU_OFFLINE; 536 556 } … … 549 569 550 570 551 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) 571 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && defined(CONFIG_SMP) 552 572 /** 553 573 * Dummy callback used by RTMpPokeCpu. … … 565 585 { 566 586 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) 587 IPRT_LINUX_SAVE_EFL_AC(); 567 588 int rc; 568 IPRT_LINUX_SAVE_EFL_AC(); 569 570 if (!RTMpIsCpuPossible(idCpu)) 571 return VERR_CPU_NOT_FOUND; 572 if (!RTMpIsCpuOnline(idCpu)) 573 return VERR_CPU_OFFLINE; 574 575 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) 576 rc = smp_call_function_single(idCpu, rtmpLinuxPokeCpuCallback, NULL, 0 /* wait */); 577 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) 578 rc = smp_call_function_single(idCpu, rtmpLinuxPokeCpuCallback, NULL, 0 /* retry */, 0 /* wait */); 579 # else /* older kernels */ 580 # error oops 581 # endif /* older kernels */ 582 NOREF(rc); 583 Assert(rc == 0); 589 if (RTMpIsCpuPossible(idCpu)) 590 { 591 if (RTMpIsCpuOnline(idCpu)) 592 { 593 # ifdef CONFIG_SMP 594 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) 595 rc = smp_call_function_single(idCpu, rtmpLinuxPokeCpuCallback, NULL, 0 /* wait */); 596 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) 597 rc = smp_call_function_single(idCpu, rtmpLinuxPokeCpuCallback, NULL, 0 /* retry */, 0 /* wait */); 598 # else /* older kernels */ 599 # error oops 600 # endif /* older kernels */ 601 Assert(rc == 0); 602 # endif /* CONFIG_SMP */ 603 rc = VINF_SUCCESS; 604 } 605 else 606 rc = VERR_CPU_OFFLINE; 607 } 608 else 609 rc = VERR_CPU_NOT_FOUND; 584 610 IPRT_LINUX_RESTORE_EFL_AC(); 585 return VINF_SUCCESS;611 return rc; 586 612 587 613 #else /* older kernels */
Note:
See TracChangeset
for help on using the changeset viewer.