Convert to new CPU hotplug framework
Subsystems (4)
Boris Ostrovsky
reviewercover Convert to new CPU hotplug framework
New CPU hotplug framework was introduced recently. These patches convert Xen CPU hotplug code to this infrastructure.
The patches (patch 1 specifically) will apply on top of
https://lists.xenproject.org/archives/html/xen-devel/2016-08/msg00562.html
(I will be out of the office starting tomorrow so may not be able to respond to comments right away)
Boris Ostrovsky (2):
xen/x86: Convert to hotplug state machine
xen/events: Convert to hotplug state machine
arch/x86/xen/enlighten.c | 115 +++++++++++++++++++++---------------- drivers/xen/events/events_fifo.c | 34 ++++------- include/linux/cpuhotplug.h | 3 + 3 files changed, 80 insertions(+), 72 deletions(-)
Boris Ostrovsky
reviewerPATCH 1/2 xen/x86: Convert to hotplug state machine
Switch to new CPU hotplug infrastructure.
--- arch/x86/xen/enlighten.c | 115 +++++++++++++++++++++++++------------------- include/linux/cpuhotplug.h | 2 + 2 files changed, 67 insertions(+), 50 deletions(-)
arch/x86/xen/enlighten.c +65 -50
@@ -140,7 +140,9 @@ RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);__read_mostly int xen_have_vector_callback;EXPORT_SYMBOL_GPL (xen_have_vector_callback); -static struct notifier_block xen_cpu_notifier; +static int xen_cpu_up_prepare (unsigned int cpu); +static int xen_cpu_up_online (unsigned int cpu); +static int xen_cpu_up_cancel (unsigned int cpu);/* * Point at some empty memory to start with. We map the real shared_info
@@ -1541,6 +1543,24 @@ static void __init xen_dom0_set_legacy_features(void) x86_platform.legacy.rtc =1 ; } +static int xen_cpuhp_setup (void ) +{ +int rc; + + rc =cpuhp_setup_state_nocalls (CPUHP_XEN_PREPARE , +"XEN_HVM_GUEST_PREPARE" , + xen_cpu_up_prepare, xen_cpu_up_cancel); +if (!rc) { + rc =cpuhp_setup_state_nocalls (CPUHP_AP_XEN_ONLINE , +"XEN_HVM_GUEST_PREPARE" , + xen_cpu_up_online,NULL ); +if (rc) +cpuhp_remove_state_nocalls (CPUHP_XEN_PREPARE ); + } + +return rc; +} +/* First C function to be called on Xen boot */ asmlinkage __visible void __init xen_start_kernel(void) {
@@ -1629,7 +1649,7 @@ asmlinkage __visible void __init xen_start_kernel(void) xen_initial_gdt = &per_cpu (gdt_page,0 );xen_smp_init (); -register_cpu_notifier (&xen_cpu_notifier); +WARN_ON (xen_cpuhp_setup ());#ifdef CONFIG_ACPI_NUMA /*
@@ -1823,63 +1843,58 @@ static void __init init_hvm_pv_info(void) xen_domain_type =XEN_HVM_DOMAIN ; } -static int xen_cpu_notify (struct notifier_block *self,unsigned long action, -void *hcpu) +static int xen_cpu_up_prepare (unsigned int cpu) { -int cpu = (long )hcpu;int rc; -switch (action) { -case CPU_UP_PREPARE : -if (xen_hvm_domain ()) { -/* -* This can happen if CPU was offlined earlier and -* offlining timed out in common_cpu_die(). -*/ -if (cpu_report_state (cpu) ==CPU_DEAD_FROZEN ) { -xen_smp_intr_free (cpu); -xen_uninit_lock_cpu (cpu); - } - -if (cpu_acpi_id (cpu) !=U32_MAX ) -per_cpu (xen_vcpu_id, cpu) =cpu_acpi_id (cpu); -else -per_cpu (xen_vcpu_id, cpu) = cpu; -xen_vcpu_setup (cpu); +if (xen_hvm_domain ()) { +/* +* This can happen if CPU was offlined earlier and +* offlining timed out in common_cpu_die(). +*/ +if (cpu_report_state (cpu) ==CPU_DEAD_FROZEN ) { +xen_smp_intr_free (cpu); +xen_uninit_lock_cpu (cpu); } -if (xen_pv_domain () || - (xen_have_vector_callback && -xen_feature (XENFEAT_hvm_safe_pvclock))) -xen_setup_timer (cpu); +if (cpu_acpi_id (cpu) !=U32_MAX ) +per_cpu (xen_vcpu_id, cpu) =cpu_acpi_id (cpu); +else +per_cpu (xen_vcpu_id, cpu) = cpu; +xen_vcpu_setup (cpu); + } - rc =xen_smp_intr_init (cpu); -if (rc) { -WARN (1 ,"xen_smp_intr_init() for CPU %d failed: %d\n" , - cpu, rc); -return NOTIFY_BAD ; - } +if (xen_pv_domain () || + (xen_have_vector_callback && +xen_feature (XENFEAT_hvm_safe_pvclock))) +xen_setup_timer (cpu); -break ; -case CPU_ONLINE : -xen_init_lock_cpu (cpu); -break ; -case CPU_UP_CANCELED : -xen_smp_intr_free (cpu); -if (xen_pv_domain () || - (xen_have_vector_callback && -xen_feature (XENFEAT_hvm_safe_pvclock))) -xen_teardown_timer (cpu); -break ; -default : -break ; + rc =xen_smp_intr_init (cpu); +if (rc) { +WARN (1 ,"xen_smp_intr_init() for CPU %d failed: %d\n" , + cpu, rc); +return rc; } -return NOTIFY_OK ; +return 0 ; } -static struct notifier_block xen_cpu_notifier = { - .notifier_call = xen_cpu_notify, -}; +static int xen_cpu_up_cancel (unsigned int cpu) +{ +xen_smp_intr_free (cpu); + +if (xen_pv_domain () || + (xen_have_vector_callback && +xen_feature (XENFEAT_hvm_safe_pvclock))) +xen_teardown_timer (cpu); + +return 0 ; +} + +static int xen_cpu_up_online (unsigned int cpu) +{ +xen_init_lock_cpu (cpu); +return 0 ; +}#ifdef CONFIG_KEXEC_CORE static void xen_hvm_shutdown (void )
@@ -1910,7 +1925,7 @@ static void __init xen_hvm_guest_init(void)if (xen_feature (XENFEAT_hvm_callback_vector)) xen_have_vector_callback =1 ;xen_hvm_smp_init (); -register_cpu_notifier (&xen_cpu_notifier); +WARN_ON (xen_cpuhp_setup ());xen_unplug_emulated_devices (); x86_init.irqs.intr_init = xen_init_IRQ;xen_hvm_init_time_ops ();
include/linux/cpuhotplug.h +2 -0
@@ -21,6 +21,7 @@ enum cpuhp_state {CPUHP_X2APIC_PREPARE ,CPUHP_SMPCFD_PREPARE ,CPUHP_RCUTREE_PREP , +CPUHP_XEN_PREPARE ,CPUHP_NOTIFY_PREPARE ,CPUHP_TIMERS_DEAD , CPUHP_BRINGUP_CPU,
@@ -93,6 +94,7 @@ enum cpuhp_state {CPUHP_AP_ONLINE_DYN_END =CPUHP_AP_ONLINE_DYN +30 ,CPUHP_AP_X86_HPET_ONLINE ,CPUHP_AP_X86_KVM_CLK_ONLINE , +CPUHP_AP_XEN_ONLINE ,CPUHP_AP_ACTIVE , CPUHP_ONLINE, };
Signature · 7 lines
1.7.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 1/2] xen/x86: Convert to hotplug state machine
Quoted 14 lines · Boris Ostrovsky
Switch to new CPU hotplug infrastructure.
Signed-off-by Boris Ostrovsky <[email protected]>Suggested-by Sebastian Andrzej Siewior <[email protected]>--- arch/x86/xen/enlighten.c | 115 +++++++++++++++++++++++++------------------- include/linux/cpuhotplug.h | 2 + 2 files changed, 67 insertions(+), 50 deletions(-)arch/x86/xen/enlighten.c +0
-0
arch/x86/xen/enlighten.c static void __init xen_dom0_set_legacy_features(void) · line 1552
Quoted 10 lines
arch/x86/xen/enlighten.c +7
-0@@ -1541,6 +1543,24 @@ static void __init xen_dom0_set_legacy_features(void) x86_platform.legacy.rtc =1 ; } +static int xen_cpuhp_setup (void ) +{ +int rc; + + rc =cpuhp_setup_state_nocalls (CPUHP_XEN_PREPARE , +"XEN_HVM_GUEST_PREPARE" , + xen_cpu_up_prepare, xen_cpu_up_cancel);
The old states UP_CANCEL is different from UP_PREPARE. The latter was invoked only in the error case while your new callback is always invoked. From looking at the code you free memory in xen_cpu_up_cancel() which was allocated in xen_cpu_up_prepare() and therefore I would name it xen_cpu_dead().
If you do find the time, you might manage to rework the code to avoid using the _nocalls() function. If see this right, you use xen_setup_vcpu_info_placement() for the init in the first place. This uses for_each_possible_cpu macro. The cpuhp_setup_state() function would perform the init for all CPUs before they come up.
arch/x86/xen/enlighten.c static void __init xen_dom0_set_legacy_features(void) · line 1554
Quoted 2 lines
arch/x86/xen/enlighten.c +2
-0+if (!rc) { + rc = cpuhp_setup_state_nocalls(CPUHP_AP_XEN_ONLINE,
If there is no need to run this after KVM's CLK callback please use CPUHP_AP_ONLINE_DYN. If there is such a need then please document it.
arch/x86/xen/enlighten.c static void __init xen_dom0_set_legacy_features(void) · line 1566
Quoted 12 lines
arch/x86/xen/enlighten.c +9
-0+"XEN_HVM_GUEST_PREPARE" , + xen_cpu_up_online, NULL); +if (rc) +cpuhp_remove_state_nocalls (CPUHP_XEN_PREPARE ); + } + +return rc; +} +/* First C function to be called on Xen boot */ asmlinkage __visible void __init xen_start_kernel(void) {
Sebastian
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Boris Ostrovsky
reviewerRe: [PATCH 1/2] xen/x86: Convert to hotplug state machine
Quoted 18 lines · Sebastian Andrzej Siewior
Quoted 17 lines · Boris Ostrovsky
Switch to new CPU hotplug infrastructure.
Signed-off-by Boris Ostrovsky <[email protected]>Suggested-by Sebastian Andrzej Siewior <[email protected]>--- arch/x86/xen/enlighten.c | 115 +++++++++++++++++++++++++------------------- include/linux/cpuhotplug.h | 2 + 2 files changed, 67 insertions(+), 50 deletions(-)arch/x86/xen/enlighten.c +0
-0@@ -1541,6 +1543,24 @@ static void __init xen_dom0_set_legacy_features(void) x86_platform.legacy.rtc =1 ; }
Quoted 12 lines
arch/x86/xen/enlighten.c static void __init xen_dom0_set_legacy_features(void) · line 1552
Quoted 7 lines
arch/x86/xen/enlighten.c +7
-0+static int xen_cpuhp_setup (void ) +{ +int rc; + + rc =cpuhp_setup_state_nocalls (CPUHP_XEN_PREPARE , +"XEN_HVM_GUEST_PREPARE" , + xen_cpu_up_prepare, xen_cpu_up_cancel);The old states
UP_CANCELis different fromUP_PREPARE. The latter was invoked only in the error case while your new callback is always invoked. From looking at the code you free memory inxen_cpu_up_cancel()which was allocated inxen_cpu_up_prepare()and therefore I would name itxen_cpu_dead().
Yes, "cancel" is wrong term to use here.
Quoted 5 lines
If you do find the time, you might manage to rework the code to avoid using the
_nocalls()function. If see this right, you usexen_setup_vcpu_info_placement()for the init in the first place. This usesfor_each_possible_cpumacro. Thecpuhp_setup_state()function would perform the init for all CPUs before they come up.
I am not sure I see what this would buy us.
Besides, cpuhp_setup_state() uses for_each_present_cpu().
Quoted 5 lines
arch/x86/xen/enlighten.c static void __init xen_dom0_set_legacy_features(void) · line 1554
Quoted 3 lines
arch/x86/xen/enlighten.c +2
-0+if (!rc) { + rc = cpuhp_setup_state_nocalls(CPUHP_AP_XEN_ONLINE,If there is no need to run this after KVM's CLK callback please use
CPUHP_AP_ONLINE_DYN. If there is such a need then please document it.
OK.
-boris
Quoted 14 lines
arch/x86/xen/enlighten.c static void __init xen_dom0_set_legacy_features(void) · line 1566
Quoted 13 lines
arch/x86/xen/enlighten.c +9
-0+"XEN_HVM_GUEST_PREPARE" , + xen_cpu_up_online, NULL); +if (rc) +cpuhp_remove_state_nocalls (CPUHP_XEN_PREPARE ); + } + +return rc; +} +/* First C function to be called on Xen boot */ asmlinkage __visible void __init xen_start_kernel(void) {Sebastian
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Boris Ostrovsky
reviewerRe: [PATCH 1/2] xen/x86: Convert to hotplug state machine
In reply to Sebastian Andrzej SiewiorQuoted 18 lines · Sebastian Andrzej Siewior
Quoted 17 lines · Boris Ostrovsky
Switch to new CPU hotplug infrastructure.
Signed-off-by Boris Ostrovsky <[email protected]>Suggested-by Sebastian Andrzej Siewior <[email protected]>--- arch/x86/xen/enlighten.c | 115 +++++++++++++++++++++++++------------------- include/linux/cpuhotplug.h | 2 + 2 files changed, 67 insertions(+), 50 deletions(-)arch/x86/xen/enlighten.c +0
-0@@ -1541,6 +1543,24 @@ static void __init xen_dom0_set_legacy_features(void) x86_platform.legacy.rtc =1 ; }
Quoted 12 lines
arch/x86/xen/enlighten.c static void __init xen_dom0_set_legacy_features(void) · line 1552
Quoted 7 lines
arch/x86/xen/enlighten.c +7
-0+static int xen_cpuhp_setup (void ) +{ +int rc; + + rc =cpuhp_setup_state_nocalls (CPUHP_XEN_PREPARE , +"XEN_HVM_GUEST_PREPARE" , + xen_cpu_up_prepare, xen_cpu_up_cancel);The old states
UP_CANCELis different fromUP_PREPARE. The latter was invoked only in the error case while your new callback is always invoked. From looking at the code you free memory inxen_cpu_up_cancel()which was allocated inxen_cpu_up_prepare()and therefore I would name itxen_cpu_dead().
Yes, "cancel" is wrong term to use here.
Quoted 5 lines
If you do find the time, you might manage to rework the code to avoid using the
_nocalls()function. If see this right, you usexen_setup_vcpu_info_placement()for the init in the first place. This usesfor_each_possible_cpumacro. Thecpuhp_setup_state()function would perform the init for all CPUs before they come up.
I am not sure I see what this would buy us.
Besides, cpuhp_setup_state() uses for_each_present_cpu().
Quoted 5 lines
arch/x86/xen/enlighten.c static void __init xen_dom0_set_legacy_features(void) · line 1554
Quoted 3 lines
arch/x86/xen/enlighten.c +2
-0+if (!rc) { + rc = cpuhp_setup_state_nocalls(CPUHP_AP_XEN_ONLINE,If there is no need to run this after KVM's CLK callback please use
CPUHP_AP_ONLINE_DYN. If there is such a need then please document it.
OK.
-boris
Quoted 14 lines
arch/x86/xen/enlighten.c static void __init xen_dom0_set_legacy_features(void) · line 1566
Quoted 13 lines
arch/x86/xen/enlighten.c +9
-0+"XEN_HVM_GUEST_PREPARE" , + xen_cpu_up_online, NULL); +if (rc) +cpuhp_remove_state_nocalls (CPUHP_XEN_PREPARE ); + } + +return rc; +} +/* First C function to be called on Xen boot */ asmlinkage __visible void __init xen_start_kernel(void) {Sebastian
Re: [PATCH 1/2] xen/x86: Convert to hotplug state machine
Quoted 9 lines · Boris Ostrovsky
Quoted 5 lines
If you do find the time, you might manage to rework the code to avoid using the
_nocalls()function. If see this right, you usexen_setup_vcpu_info_placement()for the init in the first place. This usesfor_each_possible_cpumacro. Thecpuhp_setup_state()function would perform the init for all CPUs before they come up.I am not sure I see what this would buy us.
Besides,
cpuhp_setup_state()usesfor_each_present_cpu().
Correct. So you would avoid running the init code on CPUs which are within the for_each_possible_cpu() set but not in for_each_present_cpu().
Assuming a NUMA box with two CPUs, 8 cores each gives you 32 CPUs in Linux with hyper threading. BIOS may report 240 CPUs as the upper limit (possible CPUs) but if you never deploy them you don't need to initialize them… Should they be plugged physically then the for_each_present_cpu() loop will cover them once they come up.
Sebastian
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Boris Ostrovsky
reviewerRe: [PATCH 1/2] xen/x86: Convert to hotplug state machine
Quoted 9 lines · Sebastian Andrzej Siewior
Quoted 8 lines · Boris Ostrovsky
Quoted 5 lines
If you do find the time, you might manage to rework the code to avoid using the
_nocalls()function. If see this right, you usexen_setup_vcpu_info_placement()for the init in the first place. This usesfor_each_possible_cpumacro. Thecpuhp_setup_state()function would perform the init for all CPUs before they come up.I am not sure I see what this would buy us.
Besides,
cpuhp_setup_state()usesfor_each_present_cpu().
Quoted 9 lines
Correct. So you would avoid running the init code on CPUs which are within the
for_each_possible_cpu()set but not infor_each_present_cpu().Assuming a NUMA box with two CPUs, 8 cores each gives you 32 CPUs in Linux with hyper threading. BIOS may report 240 CPUs as the upper limit (possible CPUs) but if you never deploy them you don't need to initialize them… Should they be plugged physically then the
for_each_present_cpu()loop will cover them once they come up.
That's not going to help Xen guests: all possible CPUs are brought up right away and then those that are not in use are unplugged.
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Boris Ostrovsky
reviewerPATCH 2/2 xen/events: Convert to hotplug state machine
In reply to Boris OstrovskyFrom: Sebastian Andrzej Siewior <[email protected]>
Install the callbacks via the state machine.
---
Changes from Sebastian's original version:
* Renamed hotplug state from CPUHP_XEN_EV_PREPEARE to CPUHP_XEN_EVTCHN_PREPARE
* Dropped suggestion in the commit messages about moving evtchn_fifo_alloc_control_block call since I think it is in the right place right now.
drivers/xen/events/events_fifo.c | 34 ++++++++++++---------------------- include/linux/cpuhotplug.h | 1 + 2 files changed, 13 insertions(+), 22 deletions(-)
drivers/xen/events/events_fifo.c +12 -22
@@ -418,30 +418,18 @@ static int evtchn_fifo_alloc_control_block(unsigned cpu)return ret; } -static int evtchn_fifo_cpu_notification (struct notifier_block *self, -unsigned long action, -void *hcpu) +static int xen_evtchn_cpu_prepare (unsigned int cpu) { -int cpu = (long )hcpu; -int ret =0 ; - -switch (action) { -case CPU_UP_PREPARE : -if (!per_cpu (cpu_control_block, cpu)) - ret =evtchn_fifo_alloc_control_block (cpu); -break ; -case CPU_DEAD : -__evtchn_fifo_handle_events (cpu, true); -break ; -default : -break ; - } -return ret <0 ?NOTIFY_BAD :NOTIFY_OK ; +if (!per_cpu (cpu_control_block, cpu)) +return evtchn_fifo_alloc_control_block (cpu); +return 0 ; } -static struct notifier_block evtchn_fifo_cpu_notifier = { - .notifier_call = evtchn_fifo_cpu_notification, -}; +static int xen_evtchn_cpu_dead (unsigned int cpu) +{ +__evtchn_fifo_handle_events (cpu, true); +return 0 ; +}int __init xen_evtchn_fifo_init (void ) {
@@ -456,7 +444,9 @@ int __init xen_evtchn_fifo_init(void) evtchn_ops = &evtchn_ops_fifo; -register_cpu_notifier (&evtchn_fifo_cpu_notifier); +cpuhp_setup_state_nocalls (CPUHP_XEN_EVTCHN_PREPARE , +"CPUHP_XEN_EVTCHN_PREPARE" , + xen_evtchn_cpu_prepare, xen_evtchn_cpu_dead); out:put_cpu ();return ret;
include/linux/cpuhotplug.h +1 -0
@@ -22,6 +22,7 @@ enum cpuhp_state {CPUHP_SMPCFD_PREPARE ,CPUHP_RCUTREE_PREP ,CPUHP_XEN_PREPARE , +CPUHP_XEN_EVTCHN_PREPARE ,CPUHP_NOTIFY_PREPARE ,CPUHP_TIMERS_DEAD , CPUHP_BRINGUP_CPU,
Signature · 7 lines
1.7.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Boris Ostrovsky
reviewerPATCH 2/2 xen/events: Convert to hotplug state machine
In reply to Boris OstrovskyFrom: Sebastian Andrzej Siewior <[email protected]>
Install the callbacks via the state machine.
---
Changes from Sebastian's original version:
* Renamed hotplug state from CPUHP_XEN_EV_PREPEARE to CPUHP_XEN_EVTCHN_PREPARE
* Dropped suggestion in the commit messages about moving evtchn_fifo_alloc_control_block call since I think it is in the right place right now.
drivers/xen/events/events_fifo.c | 34 ++++++++++++---------------------- include/linux/cpuhotplug.h | 1 + 2 files changed, 13 insertions(+), 22 deletions(-)
drivers/xen/events/events_fifo.c +12 -22
@@ -418,30 +418,18 @@ static int evtchn_fifo_alloc_control_block(unsigned cpu)return ret; } -static int evtchn_fifo_cpu_notification (struct notifier_block *self, -unsigned long action, -void *hcpu) +static int xen_evtchn_cpu_prepare (unsigned int cpu) { -int cpu = (long )hcpu; -int ret =0 ; - -switch (action) { -case CPU_UP_PREPARE : -if (!per_cpu (cpu_control_block, cpu)) - ret =evtchn_fifo_alloc_control_block (cpu); -break ; -case CPU_DEAD : -__evtchn_fifo_handle_events (cpu, true); -break ; -default : -break ; - } -return ret <0 ?NOTIFY_BAD :NOTIFY_OK ; +if (!per_cpu (cpu_control_block, cpu)) +return evtchn_fifo_alloc_control_block (cpu); +return 0 ; } -static struct notifier_block evtchn_fifo_cpu_notifier = { - .notifier_call = evtchn_fifo_cpu_notification, -}; +static int xen_evtchn_cpu_dead (unsigned int cpu) +{ +__evtchn_fifo_handle_events (cpu, true); +return 0 ; +}int __init xen_evtchn_fifo_init (void ) {
@@ -456,7 +444,9 @@ int __init xen_evtchn_fifo_init(void) evtchn_ops = &evtchn_ops_fifo; -register_cpu_notifier (&evtchn_fifo_cpu_notifier); +cpuhp_setup_state_nocalls (CPUHP_XEN_EVTCHN_PREPARE , +"CPUHP_XEN_EVTCHN_PREPARE" , + xen_evtchn_cpu_prepare, xen_evtchn_cpu_dead); out:put_cpu ();return ret;
include/linux/cpuhotplug.h +1 -0
@@ -22,6 +22,7 @@ enum cpuhp_state {CPUHP_SMPCFD_PREPARE ,CPUHP_RCUTREE_PREP ,CPUHP_XEN_PREPARE , +CPUHP_XEN_EVTCHN_PREPARE ,CPUHP_NOTIFY_PREPARE ,CPUHP_TIMERS_DEAD , CPUHP_BRINGUP_CPU,
Signature · 1 line
1.7.1
Re: [Xen-devel] [PATCH 2/2] xen/events: Convert to hotplug state machine
Quoted 3 lines · Boris Ostrovsky
From: Sebastian Andrzej Siewior <[email protected]>
Install the callbacks via the state machine.
[...]
drivers/xen/events/events_fifo.c static int evtchn_fifo_alloc_control_block(unsigned cpu) · line 432
Quoted 5 lines
drivers/xen/events/events_fifo.c +5
-0+static int xen_evtchn_cpu_dead (unsigned int cpu) +{ +__evtchn_fifo_handle_events (cpu, true); +return 0 ; +}
I'm not familiar with the new state machine. When this is called, what state is the CPU in?
In particular, local interrupts must be disabled and all non-percpu irqs must have been migrated to other CPUs.
Quoted 26 lines
int
__initxen_evtchn_fifo_init(void)
{drivers/xen/events/events_fifo.c +3
-1@@ -456,7 +444,9 @@ int __init xen_evtchn_fifo_init(void) evtchn_ops = &evtchn_ops_fifo; -register_cpu_notifier (&evtchn_fifo_cpu_notifier); +cpuhp_setup_state_nocalls (CPUHP_XEN_EVTCHN_PREPARE , +"CPUHP_XEN_EVTCHN_PREPARE" , + xen_evtchn_cpu_prepare, xen_evtchn_cpu_dead); out:put_cpu ();return ret;include/linux/cpuhotplug.h +1
-0@@ -22,6 +22,7 @@ enum cpuhp_state {CPUHP_SMPCFD_PREPARE ,CPUHP_RCUTREE_PREP ,CPUHP_XEN_PREPARE , +CPUHP_XEN_EVTCHN_PREPARE ,CPUHP_NOTIFY_PREPARE ,CPUHP_TIMERS_DEAD , CPUHP_BRINGUP_CPU,
Boris Ostrovsky
reviewerRe: [PATCH 2/2] xen/events: Convert to hotplug state machine
Quoted 13 lines · David Vrabel
Quoted 3 lines · Boris Ostrovsky
From: Sebastian Andrzej Siewior <[email protected]>
Install the callbacks via the state machine.
[...]
drivers/xen/events/events_fifo.c static int evtchn_fifo_alloc_control_block(unsigned cpu) · line 432
Quoted 5 lines
drivers/xen/events/events_fifo.c +5
-0+static int xen_evtchn_cpu_dead (unsigned int cpu) +{ +__evtchn_fifo_handle_events (cpu, true); +return 0 ; +}I'm not familiar with the new state machine. When this is called, what state is the CPU in?
Quoted 2 lines
In particular, local interrupts must be disabled and all non-percpu irqs must have been migrated to other CPUs.
This (xen_evtchn_cpu_dead()) is called immediately after notify_dead() on the way down.
The state machine is walking cpuhp_state list and for each member of the list it calls the callback that has been registered for that member.
So when we bring a CPU up first we call xen_evtchn_cpu_prepare() and then in the next iteration of the state machine loop notify_prepare() (because CPUHP_XEN_EVTCHN_PREPARE is immediately before CPUHP_NOTIFY_PREPARE). On the way down it's done in reverse: first notify_dead() and then xen_evtchn_cpu_dead().
In other words, the old notification scheme is part of new state machine:
CPUHP_RCUTREE_PREP,
CPUHP_XEN_PREPARE,
+ CPUHP_XEN_EVTCHN_PREPARE,
CPUHP_NOTIFY_PREPARE, <=== CPU notifiers callback CPUHP_TIMERS_DEAD,
CPUHP_BRINGUP_CPU,
-boris
Quoted 20 lines
Quoted 20 lines
int
__initxen_evtchn_fifo_init(void)
{drivers/xen/events/events_fifo.c +3
-1@@ -456,7 +444,9 @@ int __init xen_evtchn_fifo_init(void) evtchn_ops = &evtchn_ops_fifo; -register_cpu_notifier (&evtchn_fifo_cpu_notifier); +cpuhp_setup_state_nocalls (CPUHP_XEN_EVTCHN_PREPARE , +"CPUHP_XEN_EVTCHN_PREPARE" , + xen_evtchn_cpu_prepare, xen_evtchn_cpu_dead); out:put_cpu ();return ret;include/linux/cpuhotplug.h +0
-0@@ -22,6 +22,7 @@ enum cpuhp_state {
Quoted 8 lines
include/linux/cpuhotplug.h enum cpuhp_state { · line 28
Quoted 8 lines
include/linux/cpuhotplug.h +1
-0CPUHP_SMPCFD_PREPARE ,CPUHP_RCUTREE_PREP ,CPUHP_XEN_PREPARE , +CPUHP_XEN_EVTCHN_PREPARE ,CPUHP_NOTIFY_PREPARE ,CPUHP_TIMERS_DEAD , CPUHP_BRINGUP_CPU,
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Boris Ostrovsky
reviewerRe: [Xen-devel] [PATCH 2/2] xen/events: Convert to hotplug state machine
In reply to David VrabelQuoted 13 lines · David Vrabel
Quoted 3 lines · Boris Ostrovsky
From: Sebastian Andrzej Siewior <[email protected]>
Install the callbacks via the state machine.
[...]
drivers/xen/events/events_fifo.c static int evtchn_fifo_alloc_control_block(unsigned cpu) · line 432
Quoted 5 lines
drivers/xen/events/events_fifo.c +5
-0+static int xen_evtchn_cpu_dead (unsigned int cpu) +{ +__evtchn_fifo_handle_events (cpu, true); +return 0 ; +}I'm not familiar with the new state machine. When this is called, what state is the CPU in?
Quoted 2 lines
In particular, local interrupts must be disabled and all non-percpu irqs must have been migrated to other CPUs.
This (xen_evtchn_cpu_dead()) is called immediately after notify_dead() on the way down.
The state machine is walking cpuhp_state list and for each member of the list it calls the callback that has been registered for that member.
So when we bring a CPU up first we call xen_evtchn_cpu_prepare() and then in the next iteration of the state machine loop notify_prepare() (because CPUHP_XEN_EVTCHN_PREPARE is immediately before CPUHP_NOTIFY_PREPARE). On the way down it's done in reverse: first notify_dead() and then xen_evtchn_cpu_dead().
In other words, the old notification scheme is part of new state machine:
CPUHP_RCUTREE_PREP,
CPUHP_XEN_PREPARE,
+ CPUHP_XEN_EVTCHN_PREPARE,
CPUHP_NOTIFY_PREPARE, <=== CPU notifiers callback CPUHP_TIMERS_DEAD,
CPUHP_BRINGUP_CPU,
-boris
Quoted 28 lines
Quoted 28 lines
int
__initxen_evtchn_fifo_init(void)
{drivers/xen/events/events_fifo.c +3
-1@@ -456,7 +444,9 @@ int __init xen_evtchn_fifo_init(void) evtchn_ops = &evtchn_ops_fifo; -register_cpu_notifier (&evtchn_fifo_cpu_notifier); +cpuhp_setup_state_nocalls (CPUHP_XEN_EVTCHN_PREPARE , +"CPUHP_XEN_EVTCHN_PREPARE" , + xen_evtchn_cpu_prepare, xen_evtchn_cpu_dead); out:put_cpu ();return ret;include/linux/cpuhotplug.h +1
-0@@ -22,6 +22,7 @@ enum cpuhp_state {CPUHP_SMPCFD_PREPARE ,CPUHP_RCUTREE_PREP ,CPUHP_XEN_PREPARE , +CPUHP_XEN_EVTCHN_PREPARE ,CPUHP_NOTIFY_PREPARE ,CPUHP_TIMERS_DEAD , CPUHP_BRINGUP_CPU,
Re: [PATCH 2/2] xen/events: Convert to hotplug state machine
In reply to Boris OstrovskyQuoted 3 lines · Boris Ostrovsky
From: Sebastian Andrzej Siewior <[email protected]>
Install the callbacks via the state machine.
[...]
drivers/xen/events/events_fifo.c static int evtchn_fifo_alloc_control_block(unsigned cpu) · line 432
Quoted 5 lines
drivers/xen/events/events_fifo.c +5
-0+static int xen_evtchn_cpu_dead (unsigned int cpu) +{ +__evtchn_fifo_handle_events (cpu, true); +return 0 ; +}
I'm not familiar with the new state machine. When this is called, what state is the CPU in?
In particular, local interrupts must be disabled and all non-percpu irqs must have been migrated to other CPUs.
Quoted 19 lines
int
__initxen_evtchn_fifo_init(void)
{drivers/xen/events/events_fifo.c +3
-1@@ -456,7 +444,9 @@ int __init xen_evtchn_fifo_init(void) evtchn_ops = &evtchn_ops_fifo; -register_cpu_notifier (&evtchn_fifo_cpu_notifier); +cpuhp_setup_state_nocalls (CPUHP_XEN_EVTCHN_PREPARE , +"CPUHP_XEN_EVTCHN_PREPARE" , + xen_evtchn_cpu_prepare, xen_evtchn_cpu_dead); out:put_cpu ();return ret;include/linux/cpuhotplug.h +0
-0
include/linux/cpuhotplug.h enum cpuhp_state { · line 28
Quoted 7 lines
include/linux/cpuhotplug.h +1
-0@@ -22,6 +22,7 @@ enum cpuhp_state {CPUHP_SMPCFD_PREPARE ,CPUHP_RCUTREE_PREP ,CPUHP_XEN_PREPARE , +CPUHP_XEN_EVTCHN_PREPARE ,CPUHP_NOTIFY_PREPARE ,CPUHP_TIMERS_DEAD , CPUHP_BRINGUP_CPU,
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel