VirtualBox

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

Last change on this file since 12015 was 12015, checked in by vboxsync, 16 years ago

redhat/centos 5.2 fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/* $Id: mpnotification-r0drv-linux.c 12015 2008-09-03 07:40:40Z 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* Header Files *
33*******************************************************************************/
34#include "the-linux-kernel.h"
35
36#include <iprt/mp.h>
37#include <iprt/err.h>
38#include <iprt/cpuset.h>
39#include "r0drv/mp-r0drv.h"
40
41
42#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 71) && defined(CONFIG_SMP)
43
44/*******************************************************************************
45* Internal Functions *
46*******************************************************************************/
47static int rtMpNotificationLinuxCallback(struct notifier_block *pNotifierBlock, unsigned long ulNativeEvent, void *pvCpu);
48
49
50/*******************************************************************************
51* Global Variables *
52*******************************************************************************/
53/**
54 * The notifier block we use for registering the callback.
55 */
56static struct notifier_block g_NotifierBlock =
57{
58 .notifier_call = rtMpNotificationLinuxCallback,
59 .next = NULL,
60 .priority = 0
61};
62
63#ifdef CPU_DOWN_FAILED
64/**
65 * The set of CPUs we've seen going offline recently.
66 */
67static RTCPUSET g_MpPendingOfflineSet;
68#endif
69
70
71/**
72 * The native callback.
73 *
74 * @returns 0.
75 * @param pNotifierBlock Pointer to g_NotifierBlock.
76 * @param ulNativeEvent The native event.
77 * @param pvCpu The cpu id cast into a pointer value.
78 */
79static int rtMpNotificationLinuxCallback(struct notifier_block *pNotifierBlock, unsigned long ulNativeEvent, void *pvCpu)
80{
81 RTCPUID idCpu = (uintptr_t)pvCpu;
82 NOREF(pNotifierBlock);
83
84 /* ASSUMES iCpu == RTCPUID */
85 switch (ulNativeEvent)
86 {
87#ifdef CPU_DOWN_FAILED
88 case CPU_DOWN_FAILED:
89 /* r=frank: redhat/CentOS ported _some_ of these constants back to their
90 * 2.6.18-92.1.10.el5 kernel but actually don't use them. */
91# if defined(CPU_TASKS_FROZEN) && defined(CPU_DOWN_FAILED_FROZEN)
92 case CPU_DOWN_FAILED_FROZEN:
93# endif
94 if (!RTCpuSetIsMember(&g_MpPendingOfflineSet, idCpu))
95 return 0;
96 /* fall thru */
97#endif
98 case CPU_ONLINE:
99#if defined(CPU_TASKS_FROZEN) && defined(CPU_ONLINE_FROZEN)
100 case CPU_ONLINE_FROZEN:
101#endif
102#ifdef CPU_DOWN_FAILED
103 RTCpuSetDel(&g_MpPendingOfflineSet, idCpu);
104#endif
105 rtMpNotificationDoCallbacks(RTMPEVENT_ONLINE, idCpu);
106 break;
107
108#ifdef CPU_DOWN_PREPARE
109 case CPU_DOWN_PREPARE:
110# if defined(CPU_TASKS_FROZEN) && defined(CPU_DOWN_PREPARE_FROZEN)
111 case CPU_DOWN_PREPARE_FROZEN:
112# endif
113#else
114 case CPU_DEAD:
115# if defined(CPU_TASKS_FROZEN) && defined(CPU_DEAD_FROZEN)
116 case CPU_DEAD_FROZEN:
117# endif
118#endif
119 rtMpNotificationDoCallbacks(RTMPEVENT_OFFLINE, idCpu);
120#ifdef CPU_DOWN_FAILED
121 RTCpuSetAdd(&g_MpPendingOfflineSet, idCpu);
122#endif
123 break;
124 }
125
126 return NOTIFY_DONE;
127}
128
129
130int rtR0MpNotificationNativeInit(void)
131{
132 int rc;
133
134#ifdef CPU_DOWN_FAILED
135 RTCpuSetEmpty(&g_MpPendingOfflineSet);
136#endif
137
138 rc = register_cpu_notifier(&g_NotifierBlock);
139 AssertMsgReturn(!rc, ("%d\n", rc), RTErrConvertFromErrno(rc));
140 return VINF_SUCCESS;
141}
142
143
144void rtR0MpNotificationNativeTerm(void)
145{
146 unregister_cpu_notifier(&g_NotifierBlock);
147}
148
149#else /* Not supported / Not needed */
150
151int rtR0MpNotificationNativeInit(void)
152{
153 return VINF_SUCCESS;
154}
155
156void rtR0MpNotificationNativeTerm(void)
157{
158}
159
160#endif /* Not supported / Not needed */
161
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