VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/solaris/vbi/mpnotification-r0drv-solaris.c@ 37062

Last change on this file since 37062 was 37062, checked in by vboxsync, 14 years ago

VMM: Support for online/offlining of CPUs.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/* $Id: mpnotification-r0drv-solaris.c 37062 2011-05-13 10:18:29Z vboxsync $ */
2/** @file
3 * IPRT - Multiprocessor Event Notifications, Ring-0 Driver, Solaris.
4 */
5
6/*
7 * Copyright (C) 2008 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27/*******************************************************************************
28* Header Files *
29*******************************************************************************/
30#include "../the-solaris-kernel.h"
31#include "internal/iprt.h"
32
33#include <iprt/err.h>
34#include <iprt/mp.h>
35#include <iprt/cpuset.h>
36#include <iprt/string.h>
37#include "r0drv/mp-r0drv.h"
38
39
40/*******************************************************************************
41* Global Variables *
42*******************************************************************************/
43/** CPU watch callback handle. */
44static vbi_cpu_watch_t *g_hVbiCpuWatch = NULL;
45/** Set of online cpus that is maintained by the MP callback.
46 * This avoids locking issues querying the set from the kernel as well as
47 * eliminating any uncertainty regarding the online status during the
48 * callback. */
49RTCPUSET g_rtMpSolarisCpuSet;
50
51
52static void rtMpNotificationSolarisOnCurrentCpu(void *pvArgs, void *uIgnored1, void *uIgnored2)
53{
54 NOREF(uIgnored1);
55 NOREF(uIgnored2);
56
57 PRTMPARGS pArgs = (PRTMPARGS)(pvArgs);
58 AssertRelease(pArgs && pArgs->idCpu == RTMpCpuId());
59 Assert(pArgs->pvUser2);
60 Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
61
62 int online = *(int *)pArgs->pvUser2;
63 if (online)
64 {
65 RTCpuSetAdd(&g_rtMpSolarisCpuSet, pArgs->idCpu);
66 rtMpNotificationDoCallbacks(RTMPEVENT_ONLINE, pArgs->idCpu);
67 }
68 else
69 {
70 RTCpuSetDel(&g_rtMpSolarisCpuSet, pArgs->idCpu);
71 rtMpNotificationDoCallbacks(RTMPEVENT_OFFLINE, pArgs->idCpu);
72 }
73}
74
75
76static void rtMpNotificationSolarisCallback(void *pvUser, int iCpu, int online)
77{
78 vbi_preempt_disable();
79
80 RTMPARGS Args;
81 RT_ZERO(Args);
82 Args.pvUser1 = pvUser;
83 Args.pvUser2 = &online;
84 Args.idCpu = iCpu;
85
86 /*
87 * If we're not on the target CPU, schedule (synchronous) the event notification callback
88 * to run on the target CPU i.e. the one pertaining to the MP event.
89 */
90 bool fRunningOnTargetCpu = iCpu == RTMpCpuId(); /* ASSUMES iCpu == RTCPUID */
91 if (fRunningOnTargetCpu)
92 rtMpNotificationSolarisOnCurrentCpu(&Args, NULL /* pvIgnored1 */, NULL /* pvIgnored2 */);
93 else
94 vbi_execute_on_one(rtMpNotificationSolarisOnCurrentCpu, &Args, iCpu);
95
96 vbi_preempt_enable();
97}
98
99
100DECLHIDDEN(int) rtR0MpNotificationNativeInit(void)
101{
102 if (vbi_revision_level < 2)
103 return VERR_NOT_SUPPORTED;
104 if (g_hVbiCpuWatch != NULL)
105 return VERR_WRONG_ORDER;
106
107 /*
108 * Register the callback building the online cpu set as we
109 * do so (current_too = 1).
110 */
111 RTCpuSetEmpty(&g_rtMpSolarisCpuSet);
112 g_hVbiCpuWatch = vbi_watch_cpus(rtMpNotificationSolarisCallback, NULL, 1 /*current_too*/);
113
114 return VINF_SUCCESS;
115}
116
117
118DECLHIDDEN(void) rtR0MpNotificationNativeTerm(void)
119{
120 if (vbi_revision_level >= 2 && g_hVbiCpuWatch != NULL)
121 vbi_ignore_cpus(g_hVbiCpuWatch);
122 g_hVbiCpuWatch = NULL;
123}
124
Note: See TracBrowser for help on using the repository browser.

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