VirtualBox

Changeset 74967 in vbox for trunk


Ignore:
Timestamp:
Oct 22, 2018 10:09:05 AM (6 years ago)
Author:
vboxsync
Message:

iprt/mp-r0drv-linux.c: Attempt at fixing !CONFIG_SMP warnings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/linux/mp-r0drv-linux.c

    r70698 r74967  
    4444# define VBOX_NR_CPUMASK_BITS   NR_CPUS
    4545#endif
     46
    4647
    4748RTDECL(RTCPUID) RTMpCpuId(void)
     
    217218}
    218219
    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)
    221223/**
    222224 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER, does hit
     
    231233    ASMAtomicIncU32(&pArgs->cHits);
    232234}
    233 #endif
     235# endif
    234236
    235237
     
    253255}
    254256
     257#endif /* CONFIG_SMP */
    255258
    256259RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
    257260{
    258261    IPRT_LINUX_SAVE_EFL_AC();
    259     int rc;
    260262    RTMPARGS Args;
    261263    RTCPUSET OnlineSet;
    262264    RTCPUID  idCpu;
     265#ifdef CONFIG_SMP
    263266    uint32_t cLoops;
     267#endif
    264268
    265269    RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER;
     
    276280    idCpu = RTMpCpuId();
    277281
     282#ifdef CONFIG_SMP
    278283    if (RTCpuSetCount(&OnlineSet) > 1)
    279284    {
    280285        /* 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 #else
    284         rc = smp_call_function(rtmpLinuxAllWrapper, &Args, 0 /* retry */, 0 /* wait */);
    285 #endif
     286# 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
    286291        Assert(!rc); NOREF(rc);
    287292    }
     293#endif
    288294
    289295    /* Fire the function on this CPU. */
     
    291297    RTCpuSetDel(Args.pWorkerSet, idCpu);
    292298
     299#ifdef CONFIG_SMP
    293300    /* Wait for all of them finish. */
    294301    cLoops = 64000;
     
    307314        ASMNopPause();
    308315    }
     316#endif
    309317
    310318    RTThreadPreemptRestore(&PreemptState);
     
    317325RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
    318326{
     327#ifdef CONFIG_SMP
    319328    IPRT_LINUX_SAVE_EFL_AC();
    320329    int rc;
     
    329338
    330339    RTThreadPreemptDisable(&PreemptState);
    331 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     340# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
    332341    rc = smp_call_function(rtmpLinuxWrapper, &Args, 1 /* wait */);
    333 #else /* older kernels */
     342# else /* older kernels */
    334343    rc = smp_call_function(rtmpLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */);
    335 #endif /* older kernels */
     344# endif /* older kernels */
    336345    RTThreadPreemptRestore(&PreemptState);
    337346
    338347    Assert(rc == 0); NOREF(rc);
    339348    IPRT_LINUX_RESTORE_EFL_AC();
     349#else
     350    RT_NOREF(pfnWorker, pvUser1, pvUser2);
     351#endif
    340352    return VINF_SUCCESS;
    341353}
     
    343355
    344356
    345 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
     357#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) && defined(CONFIG_SMP)
    346358/**
    347359 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER
     
    367379RTDECL(int) RTMpOnPair(RTCPUID idCpu1, RTCPUID idCpu2, uint32_t fFlags, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
    368380{
     381#ifdef CONFIG_SMP
    369382    IPRT_LINUX_SAVE_EFL_AC();
    370383    int rc;
     
    387400         * call wait ourselves.
    388401         */
    389 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
     402# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
    390403        /* 2.6.28 introduces CONFIG_CPUMASK_OFFSTACK */
    391404        cpumask_var_t DstCpuMask;
    392 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     405# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
    393406        cpumask_t   DstCpuMask;
    394 #endif
     407# endif
    395408        RTCPUID     idCpuSelf = RTMpCpuId();
    396409        bool const  fCallSelf = idCpuSelf == idCpu1 || idCpuSelf == idCpu2;
     
    403416        Args.cHits   = 0;
    404417
    405 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     418# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
    406419        if (!zalloc_cpumask_var(&DstCpuMask, GFP_KERNEL))
    407420            return VERR_NO_MEMORY;
    408421        cpumask_set_cpu(idCpu1, DstCpuMask);
    409422        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)
    411424        if (!alloc_cpumask_var(&DstCpuMask, GFP_KERNEL))
    412425            return VERR_NO_MEMORY;
     
    414427        cpumask_set_cpu(idCpu1, DstCpuMask);
    415428        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)
    417430        cpus_clear(DstCpuMask);
    418431        cpu_set(idCpu1, DstCpuMask);
    419432        cpu_set(idCpu2, DstCpuMask);
    420 #endif
    421 
    422 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
     433# endif
     434
     435# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
    423436        smp_call_function_many(DstCpuMask, rtmpLinuxWrapperPostInc, &Args, !fCallSelf /* wait */);
    424437        rc = 0;
    425 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     438# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
    426439        rc = smp_call_function_mask(DstCpuMask, rtmpLinuxWrapperPostInc, &Args, !fCallSelf /* wait */);
    427 #else /* older kernels */
     440# else /* older kernels */
    428441        rc = smp_call_function(rtMpLinuxOnPairWrapper, &Args, 0 /* retry */, !fCallSelf /* wait */);
    429 #endif /* older kernels */
     442# endif /* older kernels */
    430443        Assert(rc == 0);
    431444
     
    454467            rc = VERR_CPU_IPE_1;
    455468
    456 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
     469# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
    457470        free_cpumask_var(DstCpuMask);
    458 #endif
     471# endif
    459472    }
    460473    /*
     
    469482    IPRT_LINUX_RESTORE_EFL_AC();
    470483    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 */
    471489}
    472490RT_EXPORT_SYMBOL(RTMpOnPair);
     
    480498
    481499
    482 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
     500#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) && defined(CONFIG_SMP)
    483501/**
    484502 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER
     
    520538    if (idCpu != RTMpCpuId())
    521539    {
     540#ifdef CONFIG_SMP
    522541        if (RTMpIsCpuOnline(idCpu))
    523542        {
    524 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     543# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
    525544            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)
    527546            rc = smp_call_function_single(idCpu, rtmpLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */);
    528 #else /* older kernels */
     547# else /* older kernels */
    529548            rc = smp_call_function(rtmpOnSpecificLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */);
    530 #endif /* older kernels */
     549# endif /* older kernels */
    531550            Assert(rc == 0);
    532551            rc = Args.cHits ? VINF_SUCCESS : VERR_CPU_OFFLINE;
    533552        }
    534553        else
     554#endif /* CONFIG_SMP */
    535555            rc = VERR_CPU_OFFLINE;
    536556    }
     
    549569
    550570
    551 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     571#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && defined(CONFIG_SMP)
    552572/**
    553573 * Dummy callback used by RTMpPokeCpu.
     
    565585{
    566586#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     587    IPRT_LINUX_SAVE_EFL_AC();
    567588    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;
    584610    IPRT_LINUX_RESTORE_EFL_AC();
    585     return VINF_SUCCESS;
     611    return rc;
    586612
    587613#else  /* older kernels */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette