VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/linux/mpnotification-r0drv-linux.c@ 9318

Last change on this file since 9318 was 9313, checked in by vboxsync, 17 years ago

NOTIFY_DONE.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/* $Id: mpnotification-r0drv-linux.c 9313 2008-06-02 15:29:36Z vboxsync $ */
2/** @file
3 * IPRT - Multiprocessor Event Notifications, Ring-0 Driver, Linux.
4 */
5
6/*
7 * Copyright (C) 2008 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 *
30 */
31
32/*******************************************************************************
33* Header Files *
34*******************************************************************************/
35#include "the-linux-kernel.h"
36
37#include <iprt/mp.h>
38#include <iprt/err.h>
39#include <iprt/cpuset.h>
40#include "r0drv/mp-r0drv.h"
41
42
43#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 71) && defined(CONFIG_SMP)
44
45/*******************************************************************************
46* Internal Functions *
47*******************************************************************************/
48static int rtMpNotificationLinuxCallback(struct notifier_block *pNotifierBlock, unsigned long ulNativeEvent, void *pvCpu);
49
50
51/*******************************************************************************
52* Global Variables *
53*******************************************************************************/
54/**
55 * The notifier block we use for registering the callback.
56 */
57static struct notifier_block g_NotifierBlock =
58{
59 .notifier_call = rtMpNotificationLinuxCallback,
60 .next = NULL,
61 .priority = 0
62};
63
64#ifdef CPU_DOWN_FAILED
65/**
66 * The set of CPUs we've seen going offline recently.
67 */
68static RTCPUSET g_MpPendingOfflineSet;
69#endif
70
71
72/**
73 * The native callback.
74 *
75 * @returns 0.
76 * @param pNotifierBlock Pointer to g_NotifierBlock.
77 * @param ulNativeEvent The native event.
78 * @param pvCpu The cpu id cast into a pointer value.
79 */
80static int rtMpNotificationLinuxCallback(struct notifier_block *pNotifierBlock, unsigned long ulNativeEvent, void *pvCpu)
81{
82 RTCPUID idCpu = (uintptr_t)pvCpu;
83 NOREF(pNotifierBlock);
84
85 /* ASSUMES iCpu == RTCPUID */
86 switch (ulNativeEvent)
87 {
88#ifdef CPU_DOWN_FAILED
89 case CPU_DOWN_FAILED:
90# ifdef CPU_TASKS_FROZEN
91 case CPU_DOWN_FAILED_FROZEN:
92# endif
93 if (!RTCpuSetIsMember(&g_MpPendingOfflineSet, idCpu))
94 return 0;
95 /* fall thru */
96#endif
97 case CPU_ONLINE:
98# ifdef CPU_TASKS_FROZEN
99 case CPU_ONLINE_FROZEN:
100# endif
101 RTCpuSetDel(&g_MpPendingOfflineSet, idCpu);
102 rtMpNotificationDoCallbacks(RTMPEVENT_ONLINE, idCpu);
103 break;
104
105#ifdef CPU_DOWN_PREPARE
106 case CPU_DOWN_PREPARE:
107# ifdef CPU_TASKS_FROZEN
108 case CPU_DOWN_PREPARE_FROZEN:
109# endif
110#else
111 case CPU_DEAD:
112# ifdef CPU_TASKS_FROZEN
113 case CPU_DEAD_FROZEN:
114# endif
115#endif
116 rtMpNotificationDoCallbacks(RTMPEVENT_OFFLINE, idCpu);
117 RTCpuSetAdd(&g_MpPendingOfflineSet, idCpu);
118 break;
119 }
120
121 return NOTIFY_DONE;
122}
123
124
125int rtR0MpNotificationNativeInit(void *pvOS)
126{
127 int rc;
128 NOREF(pvOS);
129
130#ifdef CPU_DOWN_FAILED
131 RTCpuSetEmpty(&g_MpPendingOfflineSet);
132#endif
133
134 rc = register_cpu_notifier(&g_NotifierBlock);
135 AssertMsgReturn(!rc, ("%d\n", rc), RTErrConvertFromErrno(rc));
136 return VINF_SUCCESS;
137}
138
139
140void rtR0MpNotificationNativeTerm(void *pvOS)
141{
142 unregister_cpu_notifier(&g_NotifierBlock);
143}
144
145#else /* Not supported / Not needed */
146
147int rtR0MpNotificationNativeInit(void *pvOS)
148{
149 NOREF(pvOS);
150 return VINF_SUCCESS;
151}
152
153void rtR0MpNotificationNativeTerm(void *pvOS)
154{
155 NOREF(pvOS);
156}
157
158#endif /* Not supported / Not needed */
159
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