VirtualBox

Changeset 65336 in vbox


Ignore:
Timestamp:
Jan 16, 2017 2:02:35 PM (8 years ago)
Author:
vboxsync
Message:

Runtime: Linux 4.10 removed the register_cpu_notifier interface, switch to cpuhp

File:
1 edited

Legend:

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

    r62477 r65336  
    3838#include "r0drv/mp-r0drv.h"
    3939
    40 
    41 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 71) && defined(CONFIG_SMP)
    42 
    43 
    44 /*********************************************************************************************************************************
    45 *   Internal Functions                                                                                                           *
    46 *********************************************************************************************************************************/
     40#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
     41
     42static enum cpuhp_state g_rtR0MpOnline;
     43
     44/*
     45 * Linux 4.10 completely removed CPU notifiers. So let's switch to CPU hotplug
     46 * notification.
     47 */
     48
     49static int rtR0MpNotificationLinuxOnline(unsigned int cpu)
     50{
     51    RTCPUID idCpu = RTMpCpuIdFromSetIndex(cpu);
     52    rtMpNotificationDoCallbacks(RTMPEVENT_ONLINE, idCpu);
     53    return 0;
     54}
     55
     56static int rtR0MpNotificationLinuxOffline(unsigned int cpu)
     57{
     58    RTCPUID idCpu = RTMpCpuIdFromSetIndex(cpu);
     59    rtMpNotificationDoCallbacks(RTMPEVENT_OFFLINE, idCpu);
     60    return 0;
     61}
     62
     63DECLHIDDEN(int) rtR0MpNotificationNativeInit(void)
     64{
     65    int rc;
     66    IPRT_LINUX_SAVE_EFL_AC();
     67    rc = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "vboxdrv:online",
     68                                   rtR0MpNotificationLinuxOnline, rtR0MpNotificationLinuxOffline);
     69    IPRT_LINUX_RESTORE_EFL_AC();
     70    /*
     71     * cpuhp_setup_state_nocalls() returns a positive state number for
     72     * CPUHP_AP_ONLINE_DYN or -ENOSPC if there is no free slot available
     73     * (see cpuhp_reserve_state / definition of CPUHP_AP_ONLINE_DYN).
     74     */
     75    AssertMsgReturn(rc > 0, ("%d\n", rc), RTErrConvertFromErrno(rc));
     76    g_rtR0MpOnline = rc;
     77    return VINF_SUCCESS;
     78}
     79
     80
     81DECLHIDDEN(void) rtR0MpNotificationNativeTerm(void)
     82{
     83    IPRT_LINUX_SAVE_EFL_AC();
     84    cpuhp_remove_state_nocalls(g_rtR0MpOnline);
     85    IPRT_LINUX_RESTORE_EFL_AC();
     86}
     87
     88#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 71) && defined(CONFIG_SMP)
     89
    4790static int rtMpNotificationLinuxCallback(struct notifier_block *pNotifierBlock, unsigned long ulNativeEvent, void *pvCpu);
    4891
    49 
    50 /*********************************************************************************************************************************
    51 *   Global Variables                                                                                                             *
    52 *********************************************************************************************************************************/
    5392/**
    5493 * The notifier block we use for registering the callback.
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