VirtualBox

Changeset 37294 in vbox


Ignore:
Timestamp:
Jun 1, 2011 2:11:14 PM (14 years ago)
Author:
vboxsync
Message:

Runtime/r0drv/linux: Fixed Mp event notifications.

Location:
trunk/src/VBox/Runtime/r0drv/linux
Files:
2 edited

Legend:

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

    r36951 r37294  
    3636#include <iprt/err.h>
    3737#include <iprt/asm.h>
     38#include <iprt/thread.h>
    3839#include "r0drv/mp-r0drv.h"
    3940
     
    288289    RTMPARGS Args;
    289290
     291    RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER;
    290292    Args.pfnWorker = pfnWorker;
    291293    Args.pvUser1 = pvUser1;
     
    297299        return VERR_CPU_NOT_FOUND;
    298300
    299 # ifdef preempt_disable
    300     preempt_disable();
    301 # endif
     301    RTThreadPreemptDisable(&PreemptState);
    302302    if (idCpu != RTMpCpuId())
    303303    {
     
    322322        rc = VINF_SUCCESS;
    323323    }
    324 # ifdef preempt_enable
    325     preempt_enable();
    326 # endif
     324    RTThreadPreemptRestore(&PreemptState);;
    327325
    328326    NOREF(rc);
  • trunk/src/VBox/Runtime/r0drv/linux/mpnotification-r0drv-linux.c

    r36555 r37294  
    3535#include <iprt/err.h>
    3636#include <iprt/cpuset.h>
     37#include <iprt/thread.h>
    3738#include "r0drv/mp-r0drv.h"
    3839
     
    6869
    6970/**
    70  * The native callback.
    71  *
    72  * @returns 0.
    73  * @param   pNotifierBlock  Pointer to g_NotifierBlock.
    74  * @param   ulNativeEvent   The native event.
    75  * @param   pvCpu           The cpu id cast into a pointer value.
    76  */
    77 static int rtMpNotificationLinuxCallback(struct notifier_block *pNotifierBlock, unsigned long ulNativeEvent, void *pvCpu)
    78 {
    79     RTCPUID idCpu = (uintptr_t)pvCpu;
    80     NOREF(pNotifierBlock);
     71 * Notification wrapper that updates CPU states and invokes our notification
     72 * callbacks.
     73 *
     74 * @param idCpu             The CPU Id.
     75 * @param pvUser1           Pointer to the notifier_block (unused).
     76 * @param pvUser2           The notification event.
     77 * @remarks This can be invoked in interrupt context.
     78 */
     79static void rtMpNotificationLinuxOnCurrentCpu(RTCPUID idCpu, void *pvUser1, void *pvUser2)
     80{
     81    unsigned long ulNativeEvent = *(unsigned long *)pvUser2;
     82    NOREF(pvUser1);
     83
     84    AssertRelease(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
     85    AssertRelease(idCpu == RTMpCpuId());   /* ASSUMES iCpu == RTCPUID */
    8186
    8287    /*
     
    100105#  endif
    101106            if (!RTCpuSetIsMember(&g_MpPendingOfflineSet, idCpu))
    102                 return 0;
     107                return;
    103108        /* fall thru */
    104109# endif
     
    135140            break;
    136141    }
    137 
     142}
     143
     144
     145/**
     146 * The native callback.
     147 *
     148 * @returns NOTIFY_DONE.
     149 * @param   pNotifierBlock  Pointer to g_NotifierBlock.
     150 * @param   ulNativeEvent   The native event.
     151 * @param   pvCpu           The cpu id cast into a pointer value.
     152 * @remarks This can fire with preemption enabled and on any CPU.
     153 */
     154static int rtMpNotificationLinuxCallback(struct notifier_block *pNotifierBlock, unsigned long ulNativeEvent, void *pvCpu)
     155{
     156    int rc;
     157    RTCPUID idCpu = (uintptr_t)pvCpu;
     158    NOREF(pNotifierBlock);
     159
     160    /*
     161     * Reschedule the callbacks to fire on the specific CPU with preemption disabled.
     162     */
     163    rc = RTMpOnSpecific(idCpu, rtMpNotificationLinuxOnCurrentCpu, pNotifierBlock, &ulNativeEvent);
     164    Assert(RT_SUCCESS(rc));
    138165    return NOTIFY_DONE;
    139166}
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