VirtualBox

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

最後變更 在這個檔案從40227是 40227,由 vboxsync 提交於 13 年 前

VMM/VMMR0 SupDrv Solaris/MpNotification: Fix guru meditation/panics when host CPUs are dynamically offline'd/online'd. More flexibility if offline notifications don't fire on the desired CPU.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 4.5 KB
 
1/* $Id: mpnotification-r0drv-solaris.c 40227 2012-02-23 11:15:37Z 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.alldomusa.eu.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 <iprt/thread.h>
38#include "r0drv/mp-r0drv.h"
39
40
41/*******************************************************************************
42* Global Variables *
43*******************************************************************************/
44/** CPU watch callback handle. */
45static vbi_cpu_watch_t *g_hVbiCpuWatch = NULL;
46/** Set of online cpus that is maintained by the MP callback.
47 * This avoids locking issues querying the set from the kernel as well as
48 * eliminating any uncertainty regarding the online status during the
49 * callback. */
50RTCPUSET g_rtMpSolarisCpuSet;
51
52
53static void rtMpNotificationSolarisOnCurrentCpu(void *pvArgs, void *uIgnored1, void *uIgnored2)
54{
55 NOREF(uIgnored1);
56 NOREF(uIgnored2);
57
58 PRTMPARGS pArgs = (PRTMPARGS)(pvArgs);
59 AssertRelease(pArgs && pArgs->idCpu == RTMpCpuId());
60 Assert(pArgs->pvUser2);
61 Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
62
63 int online = *(int *)pArgs->pvUser2;
64 if (online)
65 {
66 RTCpuSetAdd(&g_rtMpSolarisCpuSet, pArgs->idCpu);
67 rtMpNotificationDoCallbacks(RTMPEVENT_ONLINE, pArgs->idCpu);
68 }
69 else
70 {
71 RTCpuSetDel(&g_rtMpSolarisCpuSet, pArgs->idCpu);
72 rtMpNotificationDoCallbacks(RTMPEVENT_OFFLINE, pArgs->idCpu);
73 }
74}
75
76
77static void rtMpNotificationSolarisCallback(void *pvUser, int iCpu, int online)
78{
79 vbi_preempt_disable();
80
81 RTMPARGS Args;
82 RT_ZERO(Args);
83 Args.pvUser1 = pvUser;
84 Args.pvUser2 = &online;
85 Args.idCpu = iCpu;
86
87 /*
88 * If we're not on the target CPU, schedule (synchronous) the event notification callback
89 * to run on the target CPU i.e. the one pertaining to the MP event.
90 */
91 bool fRunningOnTargetCpu = iCpu == RTMpCpuId(); /* ASSUMES iCpu == RTCPUID */
92 if (fRunningOnTargetCpu)
93 rtMpNotificationSolarisOnCurrentCpu(&Args, NULL /* pvIgnored1 */, NULL /* pvIgnored2 */);
94 else
95 {
96 if (online)
97 vbi_execute_on_one(rtMpNotificationSolarisOnCurrentCpu, &Args, iCpu);
98 else
99 {
100 /*
101 * Since we don't absolutely need to do CPU bound code in any of the CPU offline
102 * notification hooks, run it on the current CPU. Scheduling a callback to execute
103 * on the CPU going offline at this point is too late and will not work reliably.
104 */
105 RTCpuSetDel(&g_rtMpSolarisCpuSet, iCpu);
106 rtMpNotificationDoCallbacks(RTMPEVENT_OFFLINE, iCpu);
107 }
108 }
109
110 vbi_preempt_enable();
111}
112
113
114DECLHIDDEN(int) rtR0MpNotificationNativeInit(void)
115{
116 if (g_hVbiCpuWatch != NULL)
117 return VERR_WRONG_ORDER;
118
119 /*
120 * Register the callback building the online cpu set as we
121 * do so (current_too = 1).
122 */
123 RTCpuSetEmpty(&g_rtMpSolarisCpuSet);
124 g_hVbiCpuWatch = vbi_watch_cpus(rtMpNotificationSolarisCallback, NULL, 1 /*current_too*/);
125
126 return VINF_SUCCESS;
127}
128
129
130DECLHIDDEN(void) rtR0MpNotificationNativeTerm(void)
131{
132 if (g_hVbiCpuWatch != NULL)
133 vbi_ignore_cpus(g_hVbiCpuWatch);
134 g_hVbiCpuWatch = NULL;
135}
136
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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