linux/drivers/xen/cpu_hotplug.c
<<
opti v/spa v/form va opti href="../linux+v3ue=10/drivers/xen/cpu_hotplug.c">opti vimg src="../.static/gfx/right.png" alt=">>">opv/spa opvspa class="lxr_search">optiopti vinput typopthidden" namoptnavtarget" 12opti vinput typopttext" namoptsearch" idptsearch">opti vbutt32.typoptsubmit">Searchopti Prefs v/a>opv/spa ti v/div ti vform ac12" ="ajax+*" method="post" onsubmit="return false;">opvinput typopthidden" namoptajax_lookup" idptajax_lookup" 12oti v/form oti vdiv class="headingbott3m">
vdiv idptfile_contents"
   1v/a>#include <linux/notifier.hv/a>>
   2v/a>o   3v/a>#include <xen/xen.hv/a>>
   4v/a>#include <xen/xenbus.hv/a>>
   5v/a>o   6v/a>#include <asm/xen/hyporvisor.hv/a>>
   7v/a>#include <asm/cpu.hv/a>>
   8v/a>o   9v/a>static void va href="+code=enable_hotplug_cpu" class="sref">enable_hotplug_cpuv/a>(int va href="+code=cpu" class="sref">cpuv/a>)o  .6.2a>{o  11v/a>        if (!va href="+code=cpu_present" class="sref">cpu_presentv/a>(va href="+code=cpu" class="sref">cpuv/a>))o  12v/a>                va href="+code=arch_register_cpu" class="sref">arch_register_cpuv/a>(va href="+code=cpu" class="sref">cpuv/a>);
  13v/a>o  14v/a>        va href="+code=set_cpu_present" class="sref">set_cpu_presentv/a>(va href="+code=cpu" class="sref">cpuv/a>, va href="+code=true" class="sref">truev/a>);
  15v/a>}
  16v/a>o  17v/a>static void va href="+code=disable_hotplug_cpu" class="sref">disable_hotplug_cpuv/a>(int va href="+code=cpu" class="sref">cpuv/a>)o  18.2a>{o  19v/a>        if (va href="+code=cpu_present" class="sref">cpu_presentv/a>(va href="+code=cpu" class="sref">cpuv/a>))o  20v/a>                va href="+code=arch_unregister_cpu" class="sref">arch_unregister_cpuv/a>(va href="+code=cpu" class="sref">cpuv/a>);
  21v/a>o  22v/a>        va href="+code=set_cpu_present" class="sref">set_cpu_presentv/a>(va href="+code=cpu" class="sref">cpuv/a>, va href="+code=false" class="sref">falsev/a>);
  23v/a>}
  24v/a>o  25v/a>static int va href="+code=vcpu_online" class="sref">vcpu_onlinev/a>(unsigned int va href="+code=cpu" class="sref">cpuv/a>)o  26.2a>{o  27v/a>        int va href="+code=err" class="sref">errv/a>;
  28v/a>        char va href="+code=dir" class="sref">dirv/a>[32], va href="+code=state" class="sref">statev/a>[32];
  29v/a>o  30v/a>        va href="+code=sprintf" class="sref">sprintfv/a>(va href="+code=dir" class="sref">dirv/a>, vspa
 class="string">"cpu/%u"v/spa
	, va href="+code=cpu" class="sref">cpuv/a>);
  31v/a>        va href="+code=err" class="sref">errv/a> = va href="+code=xenbus_scanf" class="sref">xenbus_scanfv/a>(va href="+code=XBT_NIL" class="sref">XBT_NILv/a>, va href="+code=dir" class="sref">dirv/a>, vspa
 class="string">"availability"v/spa
	, vspa
 class="string">"%s"v/spa
	, va href="+code=state" class="sref">statev/a>);
  32v/a>        if (va href="+code=err" class="sref">errv/a> != 1) {o  33v/a>                if (!va href="+code=xen_initial_domain" class="sref">xen_initial_domainv/a>())o  34v/a>                        va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_ERR" class="sref">KERN_ERRv/a> vspa
 class="string">"XENBUS: Unable to read cpu state\n"v/spa
	);
  35v/a>                return va href="+code=err" class="sref">errv/a>;
  36v/a>        }
  37v/a>o  38v/a>        if (va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=state" class="sref">statev/a>, vspa
 class="string">"online"v/spa
	) == 0)o  39v/a>                return 1;
  40v/a>        else if (va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=state" class="sref">statev/a>, vspa
 class="string">"offline"v/spa
	) == 0)o  41v/a>                return 0;
  42v/a>o  43v/a>        va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_ERR" class="sref">KERN_ERRv/a> vspa
 class="string">"XENBUS: unknown state(%s) on CPU%d\n"v/spa
	, va href="+code=state" class="sref">statev/a>, va href="+code=cpu" class="sref">cpuv/a>);
  44v/a>        return -va href="+code=EINVAL" class="sref">EINVALv/a>;
  45v/a>}
  46v/a>static void va href="+code=vcpu_hotplug" class="sref">vcpu_hotplugv/a>(unsigned int va href="+code=cpu" class="sref">cpuv/a>)o  47.2a>{o  48v/a>        if (!va href="+code=cpu_possible" class="sref">cpu_possiblev/a>(va href="+code=cpu" class="sref">cpuv/a>))o  49v/a>                return;
  50v/a>o  51v/a>        switch (va href="+code=vcpu_online" class="sref">vcpu_onlinev/a>(va href="+code=cpu" class="sref">cpuv/a>)) {o  52v/a>        case 1:o  53v/a>                va href="+code=enable_hotplug_cpu" class="sref">enable_hotplug_cpuv/a>(va href="+code=cpu" class="sref">cpuv/a>);
  54v/a>                break;
  55v/a>        case 0:o  56v/a>                (void)va href="+code=cpu_down" class="sref">cpu_downv/a>(va href="+code=cpu" class="sref">cpuv/a>);
  57v/a>                va href="+code=disable_hotplug_cpu" class="sref">disable_hotplug_cpuv/a>(va href="+code=cpu" class="sref">cpuv/a>);
  58v/a>                break;
  59v/a>        default:o  60v/a>                break;
  61v/a>        }
  62v/a>}
  63v/a>o  64v/a>static void va href="+code=handle_vcpu_hotplug_event" class="sref">handle_vcpu_hotplug_eventv/a>(struct va href="+code=xenbus_watch" class="sref">xenbus_watchv/a> *va href="+code=watch" class="sref">watchv/a>,o  65v/a>                                        const char **va href="+code=vec" class="sref">vecv/a>, unsigned int va href="+code=len" class="sref">lenv/a>)o  66.2a>{o  67v/a>        unsigned int va href="+code=cpu" class="sref">cpuv/a>;
  68v/a>        char *va href="+code=cpustr" class="sref">cpustrv/a>;
  69v/a>        const char *va href="+code=node" class="sref">nodev/a> = va href="+code=vec" class="sref">vecv/a>[va href="+code=XS_WATCH_PATH" class="sref">XS_WATCH_PATHv/a>];
  70v/a>o  71v/a>        va href="+code=cpustr" class="sref">cpustrv/a> = va href="+code=strstr" class="sref">strstrv/a>(va href="+code=node" class="sref">nodev/a>, vspa
 class="string">"cpu/"v/spa
	);
  72v/a>        if (va href="+code=cpustr" class="sref">cpustrv/a> != va href="+code=NULL" class="sref">NULLv/a>) {o  73v/a>                va href="+code=sscanf" class="sref">sscanfv/a>(va href="+code=cpustr" class="sref">cpustrv/a>, vspa
 class="string">"cpu/%u"v/spa
	, &va href="+code=cpu" class="sref">cpuv/a>);
  74v/a>                va href="+code=vcpu_hotplug" class="sref">vcpu_hotplugv/a>(va href="+code=cpu" class="sref">cpuv/a>);
  75v/a>        }
  76v/a>}
  77v/a>o  78v/a>static int va href="+code=setup_cpu_watcher" class="sref">setup_cpu_watcherv/a>(struct va href="+code=notifier_block" class="sref">notifier_blockv/a> *va href="+code=notifier" class="sref">notifierv/a>,o  79v/a>                              unsigned long va href="+code=event" class="sref">eventv/a>, void *va href="+code=data" class="sref">datav/a>)o  86.2a>{o  81v/a>        int va href="+code=cpu" class="sref">cpuv/a>;
  82v/a>        static struct va href="+code=xenbus_watch" class="sref">xenbus_watchv/a> va href="+code=cpu_watch" class="sref">cpu_watchv/a> = {o  83v/a>                .va href="+code=node" class="sref">nodev/a> = vspa
 class="string">"cpu"v/spa
	,o  84v/a>                .va href="+code=callback" class="sref">callbackv/a> = va href="+code=handle_vcpu_hotplug_event" class="sref">handle_vcpu_hotplug_eventv/a>};
  85v/a>o  86v/a>        (void)va href="+code=register_xenbus_watch" class="sref">register_xenbus_watchv/a>(&va href="+code=cpu_watch" class="sref">cpu_watchv/a>);
  87v/a>o  88v/a>        va href="+code=for_each_possible_cpu" class="sref">for_each_possible_cpuv/a>(va href="+code=cpu" class="sref">cpuv/a>) {o  89v/a>                if (va href="+code=vcpu_online" class="sref">vcpu_onlinev/a>(va href="+code=cpu" class="sref">cpuv/a>) == 0) {o  90v/a>                        (void)va href="+code=cpu_down" class="sref">cpu_downv/a>(va href="+code=cpu" class="sref">cpuv/a>);
  91v/a>                        va href="+code=set_cpu_present" class="sref">set_cpu_presentv/a>(va href="+code=cpu" class="sref">cpuv/a>, va href="+code=false" class="sref">falsev/a>);
  92v/a>                }
  93v/a>        }
  94v/a>o  95v/a>        return va href="+code=NOTIFY_DONE" class="sref">NOTIFY_DONEv/a>;
  96v/a>}
  97v/a>o  98v/a>static int va href="+code=__init" class="sref">__initv/a> va href="+code=setup_vcpu_hotplug_event" class="sref">setup_vcpu_hotplug_eventv/a>(void)o  99.2a>{o 100v/a>        static struct va href="+code=notifier_block" class="sref">notifier_blockv/a> va href="+code=xsn_cpu" class="sref">xsn_cpuv/a> = {o 101v/a>                .va href="+code=notifier_call" class="sref">notifier_callv/a> = va href="+code=setup_cpu_watcher" class="sref">setup_cpu_watcherv/a> };
 102v/a>o 103v/a>        if (!va href="+code=xen_pv_domain" class="sref">xen_pv_domainv/a>())o 104v/a>                return -va href="+code=ENODEV" class="sref">ENODEVv/a>;
 105v/a>o 106v/a>        va href="+code=register_xenstore_notifier" class="sref">register_xenstore_notifierv/a>(&va href="+code=xsn_cpu" class="sref">xsn_cpuv/a>);
 107v/a>o 108v/a>        return 0;
 109v/a>}
 110v/a>o 111v/a>va href="+code=arch_initcall" class="sref">arch_initcallv/a>(va href="+code=setup_vcpu_hotplug_event" class="sref">setup_vcpu_hotplug_eventv/a>);
 112v/a>o 113v/a>
The original LXR software by the LXR communityv/a>, this experimental vers.32.by lxr@linux.nov/a>. v/div vdiv class="subfooter"> lxr.linux.no kindly hosted.by Redpill Linpro ASv/a>, provider of Linux consulting and opera12" s sorvices since 1995. v/div v/body v/html