Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'smp-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull SMP hotplug notifier removal from Thomas Gleixner:
"This is the final cleanup of the hotplug notifier infrastructure. The
series has been reintgrated in the last two days because there came a
new driver using the old infrastructure via the SCSI tree.

Summary:

- convert the last leftover drivers utilizing notifiers

- fixup for a completely broken hotplug user

- prevent setup of already used states

- removal of the notifiers

- treewide cleanup of hotplug state names

- consolidation of state space

There is a sphinx based documentation pending, but that needs review
from the documentation folks"

* 'smp-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
irqchip/armada-xp: Consolidate hotplug state space
irqchip/gic: Consolidate hotplug state space
coresight/etm3/4x: Consolidate hotplug state space
cpu/hotplug: Cleanup state names
cpu/hotplug: Remove obsolete cpu hotplug register/unregister functions
staging/lustre/libcfs: Convert to hotplug state machine
scsi/bnx2i: Convert to hotplug state machine
scsi/bnx2fc: Convert to hotplug state machine
cpu/hotplug: Prevent overwriting of callbacks
x86/msr: Remove bogus cleanup from the error path
bus: arm-ccn: Prevent hotplug callback leak
perf/x86/intel/cstate: Prevent hotplug callback leak
ARM/imx/mmcd: Fix broken cpu hotplug handling
scsi: qedi: Convert to hotplug state machine

+311 -692
+1 -1
arch/arm/kernel/smp_twd.c
··· 339 339 } 340 340 341 341 cpuhp_setup_state_nocalls(CPUHP_AP_ARM_TWD_STARTING, 342 - "AP_ARM_TWD_STARTING", 342 + "arm/timer/twd:starting", 343 343 twd_timer_starting_cpu, twd_timer_dying_cpu); 344 344 345 345 twd_get_clock(np);
+22 -12
arch/arm/mach-imx/mmdc.c
··· 60 60 61 61 #define to_mmdc_pmu(p) container_of(p, struct mmdc_pmu, pmu) 62 62 63 + static enum cpuhp_state cpuhp_mmdc_state; 63 64 static int ddr_type; 64 65 65 66 struct fsl_mmdc_devtype_data { ··· 452 451 { 453 452 struct mmdc_pmu *pmu_mmdc = platform_get_drvdata(pdev); 454 453 454 + cpuhp_state_remove_instance_nocalls(cpuhp_mmdc_state, &pmu_mmdc->node); 455 455 perf_pmu_unregister(&pmu_mmdc->pmu); 456 - cpuhp_remove_state_nocalls(CPUHP_ONLINE); 457 456 kfree(pmu_mmdc); 458 457 return 0; 459 458 } ··· 473 472 return -ENOMEM; 474 473 } 475 474 475 + /* The first instance registers the hotplug state */ 476 + if (!cpuhp_mmdc_state) { 477 + ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, 478 + "perf/arm/mmdc:online", NULL, 479 + mmdc_pmu_offline_cpu); 480 + if (ret < 0) { 481 + pr_err("cpuhp_setup_state_multi failed\n"); 482 + goto pmu_free; 483 + } 484 + cpuhp_mmdc_state = ret; 485 + } 486 + 476 487 mmdc_num = mmdc_pmu_init(pmu_mmdc, mmdc_base, &pdev->dev); 477 488 if (mmdc_num == 0) 478 489 name = "mmdc"; ··· 498 485 HRTIMER_MODE_REL); 499 486 pmu_mmdc->hrtimer.function = mmdc_pmu_timer_handler; 500 487 501 - cpuhp_state_add_instance_nocalls(CPUHP_ONLINE, 502 - &pmu_mmdc->node); 503 - cpumask_set_cpu(smp_processor_id(), &pmu_mmdc->cpu); 504 - ret = cpuhp_setup_state_multi(CPUHP_AP_NOTIFY_ONLINE, 505 - "MMDC_ONLINE", NULL, 506 - mmdc_pmu_offline_cpu); 507 - if (ret) { 508 - pr_err("cpuhp_setup_state_multi failure\n"); 509 - goto pmu_register_err; 510 - } 488 + cpumask_set_cpu(raw_smp_processor_id(), &pmu_mmdc->cpu); 489 + 490 + /* Register the pmu instance for cpu hotplug */ 491 + cpuhp_state_add_instance_nocalls(cpuhp_mmdc_state, &pmu_mmdc->node); 511 492 512 493 ret = perf_pmu_register(&(pmu_mmdc->pmu), name, -1); 513 - platform_set_drvdata(pdev, pmu_mmdc); 514 494 if (ret) 515 495 goto pmu_register_err; 496 + 497 + platform_set_drvdata(pdev, pmu_mmdc); 516 498 return 0; 517 499 518 500 pmu_register_err: 519 501 pr_warn("MMDC Perf PMU failed (%d), disabled\n", ret); 502 + cpuhp_state_remove_instance_nocalls(cpuhp_mmdc_state, &pmu_mmdc->node); 520 503 hrtimer_cancel(&pmu_mmdc->hrtimer); 504 + pmu_free: 521 505 kfree(pmu_mmdc); 522 506 return ret; 523 507 }
+1 -1
arch/arm/mach-mvebu/coherency.c
··· 148 148 of_node_put(cpu_config_np); 149 149 150 150 cpuhp_setup_state_nocalls(CPUHP_AP_ARM_MVEBU_COHERENCY, 151 - "AP_ARM_MVEBU_COHERENCY", 151 + "arm/mvebu/coherency:starting", 152 152 armada_xp_clear_l2_starting, NULL); 153 153 exit: 154 154 set_cpu_coherent();
+1 -1
arch/arm/mm/cache-l2x0-pmu.c
··· 563 563 564 564 cpumask_set_cpu(0, &pmu_cpu); 565 565 ret = cpuhp_setup_state_nocalls(CPUHP_AP_PERF_ARM_L2X0_ONLINE, 566 - "AP_PERF_ARM_L2X0_ONLINE", NULL, 566 + "perf/arm/l2x0:online", NULL, 567 567 l2x0_pmu_offline_cpu); 568 568 if (ret) 569 569 goto out_pmu;
+1 -1
arch/arm/mm/cache-l2x0.c
··· 683 683 684 684 if (aux & L310_AUX_CTRL_FULL_LINE_ZERO) 685 685 cpuhp_setup_state(CPUHP_AP_ARM_L2X0_STARTING, 686 - "AP_ARM_L2X0_STARTING", l2c310_starting_cpu, 686 + "arm/l2x0:starting", l2c310_starting_cpu, 687 687 l2c310_dying_cpu); 688 688 } 689 689
+1 -1
arch/arm/vfp/vfpmodule.c
··· 799 799 } 800 800 801 801 cpuhp_setup_state_nocalls(CPUHP_AP_ARM_VFP_STARTING, 802 - "AP_ARM_VFP_STARTING", vfp_starting_cpu, 802 + "arm/vfp:starting", vfp_starting_cpu, 803 803 vfp_dying_cpu); 804 804 805 805 vfp_vector = vfp_support_entry;
+1 -1
arch/arm/xen/enlighten.c
··· 412 412 pvclock_gtod_register_notifier(&xen_pvclock_gtod_notifier); 413 413 414 414 return cpuhp_setup_state(CPUHP_AP_ARM_XEN_STARTING, 415 - "AP_ARM_XEN_STARTING", xen_starting_cpu, 415 + "arm/xen:starting", xen_starting_cpu, 416 416 xen_dying_cpu); 417 417 } 418 418 early_initcall(xen_guest_init);
+1 -1
arch/arm64/kernel/armv8_deprecated.c
··· 640 640 } 641 641 642 642 cpuhp_setup_state_nocalls(CPUHP_AP_ARM64_ISNDEP_STARTING, 643 - "AP_ARM64_ISNDEP_STARTING", 643 + "arm64/isndep:starting", 644 644 run_all_insn_set_hw_mode, NULL); 645 645 register_insn_emulation_sysctl(ctl_abi); 646 646
+1 -1
arch/arm64/kernel/debug-monitors.c
··· 140 140 static int debug_monitors_init(void) 141 141 { 142 142 return cpuhp_setup_state(CPUHP_AP_ARM64_DEBUG_MONITORS_STARTING, 143 - "CPUHP_AP_ARM64_DEBUG_MONITORS_STARTING", 143 + "arm64/debug_monitors:starting", 144 144 clear_os_lock, NULL); 145 145 } 146 146 postcore_initcall(debug_monitors_init);
+1 -1
arch/arm64/kernel/hw_breakpoint.c
··· 1001 1001 * debugger will leave the world in a nice state for us. 1002 1002 */ 1003 1003 ret = cpuhp_setup_state(CPUHP_AP_PERF_ARM_HW_BREAKPOINT_STARTING, 1004 - "CPUHP_AP_PERF_ARM_HW_BREAKPOINT_STARTING", 1004 + "perf/arm64/hw_breakpoint:starting", 1005 1005 hw_breakpoint_reset, NULL); 1006 1006 if (ret) 1007 1007 pr_err("failed to register CPU hotplug notifier: %d\n", ret);
+1 -1
arch/blackfin/kernel/perf_event.c
··· 475 475 476 476 ret = perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW); 477 477 if (!ret) 478 - cpuhp_setup_state(CPUHP_PERF_BFIN, "PERF_BFIN", 478 + cpuhp_setup_state(CPUHP_PERF_BFIN,"perf/bfin:starting", 479 479 bfin_pmu_prepare_cpu, NULL); 480 480 return ret; 481 481 }
+1 -1
arch/metag/kernel/perf/perf_event.c
··· 868 868 metag_out32(0, PERF_COUNT(1)); 869 869 870 870 cpuhp_setup_state(CPUHP_AP_PERF_METAG_STARTING, 871 - "AP_PERF_METAG_STARTING", metag_pmu_starting_cpu, 871 + "perf/metag:starting", metag_pmu_starting_cpu, 872 872 NULL); 873 873 874 874 ret = perf_pmu_register(&pmu, metag_pmu->name, PERF_TYPE_RAW);
+1 -1
arch/mips/kernel/pm-cps.c
··· 713 713 pr_warn("pm-cps: no CPC, clock & power gating unavailable\n"); 714 714 } 715 715 716 - return cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "AP_PM_CPS_CPU_ONLINE", 716 + return cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mips/cps_pm:online", 717 717 cps_pm_online_cpu, NULL); 718 718 } 719 719 arch_initcall(cps_pm_init);
+1 -1
arch/mips/oprofile/op_model_loongson3.c
··· 186 186 { 187 187 on_each_cpu(reset_counters, NULL, 1); 188 188 cpuhp_setup_state_nocalls(CPUHP_AP_MIPS_OP_LOONGSON3_STARTING, 189 - "AP_MIPS_OP_LOONGSON3_STARTING", 189 + "mips/oprofile/loongson3:starting", 190 190 loongson3_starting_cpu, loongson3_dying_cpu); 191 191 save_perf_irq = perf_irq; 192 192 perf_irq = loongson3_perfcount_handler;
+1 -1
arch/powerpc/mm/numa.c
··· 944 944 * _nocalls() + manual invocation is used because cpuhp is not yet 945 945 * initialized for the boot CPU. 946 946 */ 947 - cpuhp_setup_state_nocalls(CPUHP_POWER_NUMA_PREPARE, "POWER_NUMA_PREPARE", 947 + cpuhp_setup_state_nocalls(CPUHP_POWER_NUMA_PREPARE, "powerpc/numa:prepare", 948 948 ppc_numa_cpu_prepare, ppc_numa_cpu_dead); 949 949 for_each_present_cpu(cpu) 950 950 numa_setup_cpu(cpu);
+1 -1
arch/powerpc/perf/core-book3s.c
··· 2189 2189 #endif /* CONFIG_PPC64 */ 2190 2190 2191 2191 perf_pmu_register(&power_pmu, "cpu", PERF_TYPE_RAW); 2192 - cpuhp_setup_state(CPUHP_PERF_POWER, "PERF_POWER", 2192 + cpuhp_setup_state(CPUHP_PERF_POWER, "perf/powerpc:prepare", 2193 2193 power_pmu_prepare_cpu, NULL); 2194 2194 return 0; 2195 2195 }
+1 -1
arch/s390/kernel/perf_cpum_cf.c
··· 711 711 return rc; 712 712 } 713 713 return cpuhp_setup_state(CPUHP_AP_PERF_S390_CF_ONLINE, 714 - "AP_PERF_S390_CF_ONLINE", 714 + "perf/s390/cf:online", 715 715 s390_pmu_online_cpu, s390_pmu_offline_cpu); 716 716 } 717 717 early_initcall(cpumf_pmu_init);
+1 -1
arch/s390/kernel/perf_cpum_sf.c
··· 1623 1623 goto out; 1624 1624 } 1625 1625 1626 - cpuhp_setup_state(CPUHP_AP_PERF_S390_SF_ONLINE, "AP_PERF_S390_SF_ONLINE", 1626 + cpuhp_setup_state(CPUHP_AP_PERF_S390_SF_ONLINE, "perf/s390/sf:online", 1627 1627 s390_pmu_sf_online_cpu, s390_pmu_sf_offline_cpu); 1628 1628 out: 1629 1629 return err;
+1 -1
arch/x86/entry/vdso/vma.c
··· 371 371 372 372 /* notifier priority > KVM */ 373 373 return cpuhp_setup_state(CPUHP_AP_X86_VDSO_VMA_ONLINE, 374 - "AP_X86_VDSO_VMA_ONLINE", vgetcpu_online, NULL); 374 + "x86/vdso/vma:online", vgetcpu_online, NULL); 375 375 } 376 376 subsys_initcall(init_vdso); 377 377 #endif /* CONFIG_X86_64 */
+1 -1
arch/x86/events/amd/ibs.c
··· 1010 1010 * all online cpus. 1011 1011 */ 1012 1012 cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_IBS_STARTING, 1013 - "AP_PERF_X86_AMD_IBS_STARTING", 1013 + "perf/x86/amd/ibs:STARTING", 1014 1014 x86_pmu_amd_ibs_starting_cpu, 1015 1015 x86_pmu_amd_ibs_dying_cpu); 1016 1016
+1 -1
arch/x86/events/amd/power.c
··· 291 291 292 292 293 293 cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_POWER_ONLINE, 294 - "AP_PERF_X86_AMD_POWER_ONLINE", 294 + "perf/x86/amd/power:online", 295 295 power_cpu_init, power_cpu_exit); 296 296 297 297 ret = perf_pmu_register(&pmu_class, "power", -1);
+3 -3
arch/x86/events/amd/uncore.c
··· 527 527 * Install callbacks. Core will call them for each online cpu. 528 528 */ 529 529 if (cpuhp_setup_state(CPUHP_PERF_X86_AMD_UNCORE_PREP, 530 - "PERF_X86_AMD_UNCORE_PREP", 530 + "perf/x86/amd/uncore:prepare", 531 531 amd_uncore_cpu_up_prepare, amd_uncore_cpu_dead)) 532 532 goto fail_l2; 533 533 534 534 if (cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_UNCORE_STARTING, 535 - "AP_PERF_X86_AMD_UNCORE_STARTING", 535 + "perf/x86/amd/uncore:starting", 536 536 amd_uncore_cpu_starting, NULL)) 537 537 goto fail_prep; 538 538 if (cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_UNCORE_ONLINE, 539 - "AP_PERF_X86_AMD_UNCORE_ONLINE", 539 + "perf/x86/amd/uncore:online", 540 540 amd_uncore_cpu_online, 541 541 amd_uncore_cpu_down_prepare)) 542 542 goto fail_start;
+3 -3
arch/x86/events/core.c
··· 1820 1820 * Install callbacks. Core will call them for each online 1821 1821 * cpu. 1822 1822 */ 1823 - err = cpuhp_setup_state(CPUHP_PERF_X86_PREPARE, "PERF_X86_PREPARE", 1823 + err = cpuhp_setup_state(CPUHP_PERF_X86_PREPARE, "perf/x86:prepare", 1824 1824 x86_pmu_prepare_cpu, x86_pmu_dead_cpu); 1825 1825 if (err) 1826 1826 return err; 1827 1827 1828 1828 err = cpuhp_setup_state(CPUHP_AP_PERF_X86_STARTING, 1829 - "AP_PERF_X86_STARTING", x86_pmu_starting_cpu, 1829 + "perf/x86:starting", x86_pmu_starting_cpu, 1830 1830 x86_pmu_dying_cpu); 1831 1831 if (err) 1832 1832 goto out; 1833 1833 1834 - err = cpuhp_setup_state(CPUHP_AP_PERF_X86_ONLINE, "AP_PERF_X86_ONLINE", 1834 + err = cpuhp_setup_state(CPUHP_AP_PERF_X86_ONLINE, "perf/x86:online", 1835 1835 x86_pmu_online_cpu, NULL); 1836 1836 if (err) 1837 1837 goto out1;
+2 -2
arch/x86/events/intel/cqm.c
··· 1747 1747 * is enabled to avoid notifier leak. 1748 1748 */ 1749 1749 cpuhp_setup_state(CPUHP_AP_PERF_X86_CQM_STARTING, 1750 - "AP_PERF_X86_CQM_STARTING", 1750 + "perf/x86/cqm:starting", 1751 1751 intel_cqm_cpu_starting, NULL); 1752 - cpuhp_setup_state(CPUHP_AP_PERF_X86_CQM_ONLINE, "AP_PERF_X86_CQM_ONLINE", 1752 + cpuhp_setup_state(CPUHP_AP_PERF_X86_CQM_ONLINE, "perf/x86/cqm:online", 1753 1753 NULL, intel_cqm_cpu_exit); 1754 1754 1755 1755 out:
+7 -7
arch/x86/events/intel/cstate.c
··· 594 594 595 595 static inline void cstate_cleanup(void) 596 596 { 597 + cpuhp_remove_state_nocalls(CPUHP_AP_PERF_X86_CSTATE_ONLINE); 598 + cpuhp_remove_state_nocalls(CPUHP_AP_PERF_X86_CSTATE_STARTING); 599 + 597 600 if (has_cstate_core) 598 601 perf_pmu_unregister(&cstate_core_pmu); 599 602 ··· 609 606 int err; 610 607 611 608 cpuhp_setup_state(CPUHP_AP_PERF_X86_CSTATE_STARTING, 612 - "AP_PERF_X86_CSTATE_STARTING", cstate_cpu_init, 613 - NULL); 609 + "perf/x86/cstate:starting", cstate_cpu_init, NULL); 614 610 cpuhp_setup_state(CPUHP_AP_PERF_X86_CSTATE_ONLINE, 615 - "AP_PERF_X86_CSTATE_ONLINE", NULL, cstate_cpu_exit); 611 + "perf/x86/cstate:online", NULL, cstate_cpu_exit); 616 612 617 613 if (has_cstate_core) { 618 614 err = perf_pmu_register(&cstate_core_pmu, cstate_core_pmu.name, -1); 619 615 if (err) { 620 616 has_cstate_core = false; 621 617 pr_info("Failed to register cstate core pmu\n"); 618 + cstate_cleanup(); 622 619 return err; 623 620 } 624 621 } ··· 632 629 return err; 633 630 } 634 631 } 635 - 636 - return err; 632 + return 0; 637 633 } 638 634 639 635 static int __init cstate_pmu_init(void) ··· 657 655 658 656 static void __exit cstate_pmu_exit(void) 659 657 { 660 - cpuhp_remove_state_nocalls(CPUHP_AP_PERF_X86_CSTATE_ONLINE); 661 - cpuhp_remove_state_nocalls(CPUHP_AP_PERF_X86_CSTATE_STARTING); 662 658 cstate_cleanup(); 663 659 } 664 660 module_exit(cstate_pmu_exit);
+2 -2
arch/x86/events/intel/rapl.c
··· 803 803 * Install callbacks. Core will call them for each online cpu. 804 804 */ 805 805 806 - ret = cpuhp_setup_state(CPUHP_PERF_X86_RAPL_PREP, "PERF_X86_RAPL_PREP", 806 + ret = cpuhp_setup_state(CPUHP_PERF_X86_RAPL_PREP, "perf/x86/rapl:prepare", 807 807 rapl_cpu_prepare, NULL); 808 808 if (ret) 809 809 goto out; 810 810 811 811 ret = cpuhp_setup_state(CPUHP_AP_PERF_X86_RAPL_ONLINE, 812 - "AP_PERF_X86_RAPL_ONLINE", 812 + "perf/x86/rapl:online", 813 813 rapl_cpu_online, rapl_cpu_offline); 814 814 if (ret) 815 815 goto out1;
+5 -5
arch/x86/events/intel/uncore.c
··· 1398 1398 */ 1399 1399 if (!cret) { 1400 1400 ret = cpuhp_setup_state(CPUHP_PERF_X86_UNCORE_PREP, 1401 - "PERF_X86_UNCORE_PREP", 1402 - uncore_cpu_prepare, NULL); 1401 + "perf/x86/intel/uncore:prepare", 1402 + uncore_cpu_prepare, NULL); 1403 1403 if (ret) 1404 1404 goto err; 1405 1405 } else { 1406 1406 cpuhp_setup_state_nocalls(CPUHP_PERF_X86_UNCORE_PREP, 1407 - "PERF_X86_UNCORE_PREP", 1407 + "perf/x86/intel/uncore:prepare", 1408 1408 uncore_cpu_prepare, NULL); 1409 1409 } 1410 1410 first_init = 1; 1411 1411 cpuhp_setup_state(CPUHP_AP_PERF_X86_UNCORE_STARTING, 1412 - "AP_PERF_X86_UNCORE_STARTING", 1412 + "perf/x86/uncore:starting", 1413 1413 uncore_cpu_starting, uncore_cpu_dying); 1414 1414 first_init = 0; 1415 1415 cpuhp_setup_state(CPUHP_AP_PERF_X86_UNCORE_ONLINE, 1416 - "AP_PERF_X86_UNCORE_ONLINE", 1416 + "perf/x86/uncore:online", 1417 1417 uncore_event_cpu_online, uncore_event_cpu_offline); 1418 1418 return 0; 1419 1419
+1 -1
arch/x86/kernel/apb_timer.c
··· 234 234 if (intel_mid_timer_options == INTEL_MID_TIMER_LAPIC_APBT || 235 235 !apb_timer_block_enabled) 236 236 return 0; 237 - return cpuhp_setup_state(CPUHP_X86_APB_DEAD, "X86_APB_DEAD", NULL, 237 + return cpuhp_setup_state(CPUHP_X86_APB_DEAD, "x86/apb:dead", NULL, 238 238 apbt_cpu_dead); 239 239 } 240 240 fs_initcall(apbt_late_init);
+1 -1
arch/x86/kernel/apic/x2apic_cluster.c
··· 191 191 if (!x2apic_mode) 192 192 return 0; 193 193 194 - ret = cpuhp_setup_state(CPUHP_X2APIC_PREPARE, "X2APIC_PREPARE", 194 + ret = cpuhp_setup_state(CPUHP_X2APIC_PREPARE, "x86/x2apic:prepare", 195 195 x2apic_prepare_cpu, x2apic_dead_cpu); 196 196 if (ret < 0) { 197 197 pr_err("Failed to register X2APIC_PREPARE\n");
+2 -2
arch/x86/kernel/hpet.c
··· 1051 1051 return 0; 1052 1052 1053 1053 /* This notifier should be called after workqueue is ready */ 1054 - ret = cpuhp_setup_state(CPUHP_AP_X86_HPET_ONLINE, "AP_X86_HPET_ONLINE", 1054 + ret = cpuhp_setup_state(CPUHP_AP_X86_HPET_ONLINE, "x86/hpet:online", 1055 1055 hpet_cpuhp_online, NULL); 1056 1056 if (ret) 1057 1057 return ret; 1058 - ret = cpuhp_setup_state(CPUHP_X86_HPET_DEAD, "X86_HPET_DEAD", NULL, 1058 + ret = cpuhp_setup_state(CPUHP_X86_HPET_DEAD, "x86/hpet:dead", NULL, 1059 1059 hpet_cpuhp_dead); 1060 1060 if (ret) 1061 1061 goto err_cpuhp;
-1
arch/x86/kernel/msr.c
··· 224 224 return 0; 225 225 226 226 out_class: 227 - cpuhp_remove_state(cpuhp_msr_state); 228 227 class_destroy(msr_class); 229 228 out_chrdev: 230 229 __unregister_chrdev(MSR_MAJOR, 0, NR_CPUS, "cpu/msr");
+1 -1
arch/x86/kernel/tboot.c
··· 408 408 tboot_create_trampoline(); 409 409 410 410 atomic_set(&ap_wfs_count, 0); 411 - cpuhp_setup_state(CPUHP_AP_X86_TBOOT_DYING, "AP_X86_TBOOT_DYING", NULL, 411 + cpuhp_setup_state(CPUHP_AP_X86_TBOOT_DYING, "x86/tboot:dying", NULL, 412 412 tboot_dying_cpu); 413 413 #ifdef CONFIG_DEBUG_FS 414 414 debugfs_create_file("tboot_log", S_IRUSR,
+1 -1
arch/x86/kvm/x86.c
··· 5855 5855 } 5856 5856 pr_debug("kvm: max_tsc_khz = %ld\n", max_tsc_khz); 5857 5857 5858 - cpuhp_setup_state(CPUHP_AP_X86_KVM_CLK_ONLINE, "AP_X86_KVM_CLK_ONLINE", 5858 + cpuhp_setup_state(CPUHP_AP_X86_KVM_CLK_ONLINE, "x86/kvm/clk:online", 5859 5859 kvmclock_cpu_online, kvmclock_cpu_down_prep); 5860 5860 } 5861 5861
+2 -2
arch/x86/xen/enlighten.c
··· 1529 1529 int rc; 1530 1530 1531 1531 rc = cpuhp_setup_state_nocalls(CPUHP_XEN_PREPARE, 1532 - "XEN_HVM_GUEST_PREPARE", 1532 + "x86/xen/hvm_guest:prepare", 1533 1533 xen_cpu_up_prepare, xen_cpu_dead); 1534 1534 if (rc >= 0) { 1535 1535 rc = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, 1536 - "XEN_HVM_GUEST_ONLINE", 1536 + "x86/xen/hvm_guest:online", 1537 1537 xen_cpu_up_online, NULL); 1538 1538 if (rc < 0) 1539 1539 cpuhp_remove_state_nocalls(CPUHP_XEN_PREPARE);
+1 -1
arch/xtensa/kernel/perf_event.c
··· 422 422 int irq = irq_create_mapping(NULL, XCHAL_PROFILING_INTERRUPT); 423 423 424 424 ret = cpuhp_setup_state(CPUHP_AP_PERF_XTENSA_STARTING, 425 - "AP_PERF_XTENSA_STARTING", xtensa_pmu_setup, 425 + "perf/xtensa:starting", xtensa_pmu_setup, 426 426 NULL); 427 427 if (ret) { 428 428 pr_err("xtensa_pmu: failed to register CPU-hotplug.\n");
+1 -1
drivers/bus/arm-cci.c
··· 1796 1796 int ret; 1797 1797 1798 1798 ret = cpuhp_setup_state_multi(CPUHP_AP_PERF_ARM_CCI_ONLINE, 1799 - "AP_PERF_ARM_CCI_ONLINE", NULL, 1799 + "perf/arm/cci:online", NULL, 1800 1800 cci_pmu_offline_cpu); 1801 1801 if (ret) 1802 1802 return ret;
+5 -2
drivers/bus/arm-ccn.c
··· 1562 1562 int i, ret; 1563 1563 1564 1564 ret = cpuhp_setup_state_multi(CPUHP_AP_PERF_ARM_CCN_ONLINE, 1565 - "AP_PERF_ARM_CCN_ONLINE", NULL, 1565 + "perf/arm/ccn:online", NULL, 1566 1566 arm_ccn_pmu_offline_cpu); 1567 1567 if (ret) 1568 1568 return ret; ··· 1570 1570 for (i = 0; i < ARRAY_SIZE(arm_ccn_pmu_events); i++) 1571 1571 arm_ccn_pmu_events_attrs[i] = &arm_ccn_pmu_events[i].attr.attr; 1572 1572 1573 - return platform_driver_register(&arm_ccn_driver); 1573 + ret = platform_driver_register(&arm_ccn_driver); 1574 + if (ret) 1575 + cpuhp_remove_multi_state(CPUHP_AP_PERF_ARM_CCN_ONLINE); 1576 + return ret; 1574 1577 } 1575 1578 1576 1579 static void __exit arm_ccn_exit(void)
+1 -1
drivers/clocksource/arc_timer.c
··· 309 309 } 310 310 311 311 ret = cpuhp_setup_state(CPUHP_AP_ARC_TIMER_STARTING, 312 - "AP_ARC_TIMER_STARTING", 312 + "clockevents/arc/timer:starting", 313 313 arc_timer_starting_cpu, 314 314 arc_timer_dying_cpu); 315 315 if (ret) {
+1 -1
drivers/clocksource/arm_arch_timer.c
··· 738 738 739 739 /* Register and immediately configure the timer on the boot CPU */ 740 740 err = cpuhp_setup_state(CPUHP_AP_ARM_ARCH_TIMER_STARTING, 741 - "AP_ARM_ARCH_TIMER_STARTING", 741 + "clockevents/arm/arch_timer:starting", 742 742 arch_timer_starting_cpu, arch_timer_dying_cpu); 743 743 if (err) 744 744 goto out_unreg_cpupm;
+1 -1
drivers/clocksource/arm_global_timer.c
··· 316 316 goto out_irq; 317 317 318 318 err = cpuhp_setup_state(CPUHP_AP_ARM_GLOBAL_TIMER_STARTING, 319 - "AP_ARM_GLOBAL_TIMER_STARTING", 319 + "clockevents/arm/global_timer:starting", 320 320 gt_starting_cpu, gt_dying_cpu); 321 321 if (err) 322 322 goto out_irq;
+1 -1
drivers/clocksource/dummy_timer.c
··· 34 34 static int __init dummy_timer_register(void) 35 35 { 36 36 return cpuhp_setup_state(CPUHP_AP_DUMMY_TIMER_STARTING, 37 - "AP_DUMMY_TIMER_STARTING", 37 + "clockevents/dummy_timer:starting", 38 38 dummy_timer_starting_cpu, NULL); 39 39 } 40 40 early_initcall(dummy_timer_register);
+1 -1
drivers/clocksource/exynos_mct.c
··· 552 552 553 553 /* Install hotplug callbacks which configure the timer on this CPU */ 554 554 err = cpuhp_setup_state(CPUHP_AP_EXYNOS4_MCT_TIMER_STARTING, 555 - "AP_EXYNOS4_MCT_TIMER_STARTING", 555 + "clockevents/exynos4/mct_timer:starting", 556 556 exynos4_mct_starting_cpu, 557 557 exynos4_mct_dying_cpu); 558 558 if (err)
+1 -1
drivers/clocksource/jcore-pit.c
··· 240 240 } 241 241 242 242 cpuhp_setup_state(CPUHP_AP_JCORE_TIMER_STARTING, 243 - "AP_JCORE_TIMER_STARTING", 243 + "clockevents/jcore:starting", 244 244 jcore_pit_local_init, NULL); 245 245 246 246 return 0;
+1 -1
drivers/clocksource/metag_generic.c
··· 154 154 155 155 /* Hook cpu boot to configure the CPU's timers */ 156 156 return cpuhp_setup_state(CPUHP_AP_METAG_TIMER_STARTING, 157 - "AP_METAG_TIMER_STARTING", 157 + "clockevents/metag:starting", 158 158 arch_timer_starting_cpu, NULL); 159 159 }
+2 -2
drivers/clocksource/mips-gic-timer.c
··· 120 120 } 121 121 122 122 cpuhp_setup_state(CPUHP_AP_MIPS_GIC_TIMER_STARTING, 123 - "AP_MIPS_GIC_TIMER_STARTING", gic_starting_cpu, 124 - gic_dying_cpu); 123 + "clockevents/mips/gic/timer:starting", 124 + gic_starting_cpu, gic_dying_cpu); 125 125 return 0; 126 126 } 127 127
+1 -1
drivers/clocksource/qcom-timer.c
··· 182 182 } else { 183 183 /* Install and invoke hotplug callbacks */ 184 184 res = cpuhp_setup_state(CPUHP_AP_QCOM_TIMER_STARTING, 185 - "AP_QCOM_TIMER_STARTING", 185 + "clockevents/qcom/timer:starting", 186 186 msm_local_timer_starting_cpu, 187 187 msm_local_timer_dying_cpu); 188 188 if (res) {
+1 -1
drivers/clocksource/time-armada-370-xp.c
··· 320 320 } 321 321 322 322 res = cpuhp_setup_state(CPUHP_AP_ARMADA_TIMER_STARTING, 323 - "AP_ARMADA_TIMER_STARTING", 323 + "clockevents/armada:starting", 324 324 armada_370_xp_timer_starting_cpu, 325 325 armada_370_xp_timer_dying_cpu); 326 326 if (res) {
+1 -1
drivers/clocksource/timer-atlas7.c
··· 221 221 222 222 /* Install and invoke hotplug callbacks */ 223 223 return cpuhp_setup_state(CPUHP_AP_MARCO_TIMER_STARTING, 224 - "AP_MARCO_TIMER_STARTING", 224 + "clockevents/marco:starting", 225 225 sirfsoc_local_timer_starting_cpu, 226 226 sirfsoc_local_timer_dying_cpu); 227 227 }
+2 -2
drivers/hwtracing/coresight/coresight-etm3x.c
··· 804 804 805 805 if (!etm_count++) { 806 806 cpuhp_setup_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING, 807 - "AP_ARM_CORESIGHT_STARTING", 807 + "arm/coresight:starting", 808 808 etm_starting_cpu, etm_dying_cpu); 809 809 ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, 810 - "AP_ARM_CORESIGHT_ONLINE", 810 + "arm/coresight:online", 811 811 etm_online_cpu, NULL); 812 812 if (ret < 0) 813 813 goto err_arch_supported;
+4 -4
drivers/hwtracing/coresight/coresight-etm4x.c
··· 986 986 dev_err(dev, "ETM arch init failed\n"); 987 987 988 988 if (!etm4_count++) { 989 - cpuhp_setup_state_nocalls(CPUHP_AP_ARM_CORESIGHT4_STARTING, 990 - "AP_ARM_CORESIGHT4_STARTING", 989 + cpuhp_setup_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING, 990 + "arm/coresight4:starting", 991 991 etm4_starting_cpu, etm4_dying_cpu); 992 992 ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, 993 - "AP_ARM_CORESIGHT4_ONLINE", 993 + "arm/coresight4:online", 994 994 etm4_online_cpu, NULL); 995 995 if (ret < 0) 996 996 goto err_arch_supported; ··· 1037 1037 1038 1038 err_arch_supported: 1039 1039 if (--etm4_count == 0) { 1040 - cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT4_STARTING); 1040 + cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING); 1041 1041 if (hp_online) 1042 1042 cpuhp_remove_state_nocalls(hp_online); 1043 1043 }
+3 -3
drivers/irqchip/irq-armada-370-xp.c
··· 578 578 #ifdef CONFIG_SMP 579 579 set_smp_cross_call(armada_mpic_send_doorbell); 580 580 cpuhp_setup_state_nocalls(CPUHP_AP_IRQ_ARMADA_XP_STARTING, 581 - "AP_IRQ_ARMADA_XP_STARTING", 581 + "irqchip/armada/ipi:starting", 582 582 armada_xp_mpic_starting_cpu, NULL); 583 583 #endif 584 584 } else { 585 585 #ifdef CONFIG_SMP 586 - cpuhp_setup_state_nocalls(CPUHP_AP_IRQ_ARMADA_CASC_STARTING, 587 - "AP_IRQ_ARMADA_CASC_STARTING", 586 + cpuhp_setup_state_nocalls(CPUHP_AP_IRQ_ARMADA_XP_STARTING, 587 + "irqchip/armada/cascade:starting", 588 588 mpic_cascaded_starting_cpu, NULL); 589 589 #endif 590 590 irq_set_chained_handler(parent_irq,
+1 -1
drivers/irqchip/irq-bcm2836.c
··· 245 245 #ifdef CONFIG_SMP 246 246 /* Unmask IPIs to the boot CPU. */ 247 247 cpuhp_setup_state(CPUHP_AP_IRQ_BCM2836_STARTING, 248 - "AP_IRQ_BCM2836_STARTING", bcm2836_cpu_starting, 248 + "irqchip/bcm2836:starting", bcm2836_cpu_starting, 249 249 bcm2836_cpu_dying); 250 250 251 251 set_smp_cross_call(bcm2836_arm_irqchip_send_ipi);
+3 -3
drivers/irqchip/irq-gic-v3.c
··· 632 632 static void gic_smp_init(void) 633 633 { 634 634 set_smp_cross_call(gic_raise_softirq); 635 - cpuhp_setup_state_nocalls(CPUHP_AP_IRQ_GICV3_STARTING, 636 - "AP_IRQ_GICV3_STARTING", gic_starting_cpu, 637 - NULL); 635 + cpuhp_setup_state_nocalls(CPUHP_AP_IRQ_GIC_STARTING, 636 + "irqchip/arm/gicv3:starting", 637 + gic_starting_cpu, NULL); 638 638 } 639 639 640 640 static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
+1 -1
drivers/irqchip/irq-gic.c
··· 1191 1191 set_smp_cross_call(gic_raise_softirq); 1192 1192 #endif 1193 1193 cpuhp_setup_state_nocalls(CPUHP_AP_IRQ_GIC_STARTING, 1194 - "AP_IRQ_GIC_STARTING", 1194 + "irqchip/arm/gic:starting", 1195 1195 gic_starting_cpu, NULL); 1196 1196 set_handle_irq(gic_handle_irq); 1197 1197 if (static_key_true(&supports_deactivate))
+1 -1
drivers/irqchip/irq-hip04.c
··· 407 407 set_handle_irq(hip04_handle_irq); 408 408 409 409 hip04_irq_dist_init(&hip04_data); 410 - cpuhp_setup_state(CPUHP_AP_IRQ_HIP04_STARTING, "AP_IRQ_HIP04_STARTING", 410 + cpuhp_setup_state(CPUHP_AP_IRQ_HIP04_STARTING, "irqchip/hip04:starting", 411 411 hip04_irq_starting_cpu, NULL); 412 412 return 0; 413 413 }
+1 -1
drivers/leds/trigger/ledtrig-cpu.c
··· 127 127 128 128 register_syscore_ops(&ledtrig_cpu_syscore_ops); 129 129 130 - ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "AP_LEDTRIG_STARTING", 130 + ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "leds/trigger:starting", 131 131 ledtrig_online_cpu, ledtrig_prepare_down_cpu); 132 132 if (ret < 0) 133 133 pr_err("CPU hotplug notifier for ledtrig-cpu could not be registered: %d\n",
+2 -2
drivers/net/virtio_net.c
··· 2484 2484 { 2485 2485 int ret; 2486 2486 2487 - ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, "AP_VIRT_NET_ONLINE", 2487 + ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, "virtio/net:online", 2488 2488 virtnet_cpu_online, 2489 2489 virtnet_cpu_down_prep); 2490 2490 if (ret < 0) 2491 2491 goto out; 2492 2492 virtionet_online = ret; 2493 - ret = cpuhp_setup_state_multi(CPUHP_VIRT_NET_DEAD, "VIRT_NET_DEAD", 2493 + ret = cpuhp_setup_state_multi(CPUHP_VIRT_NET_DEAD, "virtio/net:dead", 2494 2494 NULL, virtnet_cpu_dead); 2495 2495 if (ret) 2496 2496 goto err_dead;
+1 -1
drivers/perf/arm_pmu.c
··· 1084 1084 int ret; 1085 1085 1086 1086 ret = cpuhp_setup_state_multi(CPUHP_AP_PERF_ARM_STARTING, 1087 - "AP_PERF_ARM_STARTING", 1087 + "perf/arm/pmu:starting", 1088 1088 arm_perf_starting_cpu, NULL); 1089 1089 if (ret) 1090 1090 pr_err("CPU hotplug notifier for ARM PMU could not be registered: %d\n",
+34 -47
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
··· 127 127 MODULE_PARM_DESC(log_fka, " Print message to kernel log when fcoe is " 128 128 "initiating a FIP keep alive when debug logging is enabled."); 129 129 130 - static int bnx2fc_cpu_callback(struct notifier_block *nfb, 131 - unsigned long action, void *hcpu); 132 - /* notification function for CPU hotplug events */ 133 - static struct notifier_block bnx2fc_cpu_notifier = { 134 - .notifier_call = bnx2fc_cpu_callback, 135 - }; 136 - 137 130 static inline struct net_device *bnx2fc_netdev(const struct fc_lport *lport) 138 131 { 139 132 return ((struct bnx2fc_interface *) ··· 2615 2622 kthread_stop(thread); 2616 2623 } 2617 2624 2618 - /** 2619 - * bnx2fc_cpu_callback - Handler for CPU hotplug events 2620 - * 2621 - * @nfb: The callback data block 2622 - * @action: The event triggering the callback 2623 - * @hcpu: The index of the CPU that the event is for 2624 - * 2625 - * This creates or destroys per-CPU data for fcoe 2626 - * 2627 - * Returns NOTIFY_OK always. 2628 - */ 2629 - static int bnx2fc_cpu_callback(struct notifier_block *nfb, 2630 - unsigned long action, void *hcpu) 2631 - { 2632 - unsigned cpu = (unsigned long)hcpu; 2633 2625 2634 - switch (action) { 2635 - case CPU_ONLINE: 2636 - case CPU_ONLINE_FROZEN: 2637 - printk(PFX "CPU %x online: Create Rx thread\n", cpu); 2638 - bnx2fc_percpu_thread_create(cpu); 2639 - break; 2640 - case CPU_DEAD: 2641 - case CPU_DEAD_FROZEN: 2642 - printk(PFX "CPU %x offline: Remove Rx thread\n", cpu); 2643 - bnx2fc_percpu_thread_destroy(cpu); 2644 - break; 2645 - default: 2646 - break; 2647 - } 2648 - return NOTIFY_OK; 2626 + static int bnx2fc_cpu_online(unsigned int cpu) 2627 + { 2628 + printk(PFX "CPU %x online: Create Rx thread\n", cpu); 2629 + bnx2fc_percpu_thread_create(cpu); 2630 + return 0; 2631 + } 2632 + 2633 + static int bnx2fc_cpu_dead(unsigned int cpu) 2634 + { 2635 + printk(PFX "CPU %x offline: Remove Rx thread\n", cpu); 2636 + bnx2fc_percpu_thread_destroy(cpu); 2637 + return 0; 2649 2638 } 2650 2639 2651 2640 static int bnx2fc_slave_configure(struct scsi_device *sdev) ··· 2638 2663 scsi_change_queue_depth(sdev, bnx2fc_queue_depth); 2639 2664 return 0; 2640 2665 } 2666 + 2667 + static enum cpuhp_state bnx2fc_online_state; 2641 2668 2642 2669 /** 2643 2670 * bnx2fc_mod_init - module init entry point ··· 2701 2724 spin_lock_init(&p->fp_work_lock); 2702 2725 } 2703 2726 2704 - cpu_notifier_register_begin(); 2727 + get_online_cpus(); 2705 2728 2706 - for_each_online_cpu(cpu) { 2729 + for_each_online_cpu(cpu) 2707 2730 bnx2fc_percpu_thread_create(cpu); 2708 - } 2709 2731 2710 - /* Initialize per CPU interrupt thread */ 2711 - __register_hotcpu_notifier(&bnx2fc_cpu_notifier); 2732 + rc = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, 2733 + "scsi/bnx2fc:online", 2734 + bnx2fc_cpu_online, NULL); 2735 + if (rc < 0) 2736 + goto stop_threads; 2737 + bnx2fc_online_state = rc; 2712 2738 2713 - cpu_notifier_register_done(); 2739 + cpuhp_setup_state_nocalls(CPUHP_SCSI_BNX2FC_DEAD, "scsi/bnx2fc:dead", 2740 + NULL, bnx2fc_cpu_dead); 2741 + put_online_cpus(); 2714 2742 2715 2743 cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb); 2716 2744 2717 2745 return 0; 2718 2746 2747 + stop_threads: 2748 + for_each_online_cpu(cpu) 2749 + bnx2fc_percpu_thread_destroy(cpu); 2750 + put_online_cpus(); 2751 + kthread_stop(l2_thread); 2719 2752 free_wq: 2720 2753 destroy_workqueue(bnx2fc_wq); 2721 2754 release_bt: ··· 2784 2797 if (l2_thread) 2785 2798 kthread_stop(l2_thread); 2786 2799 2787 - cpu_notifier_register_begin(); 2788 - 2800 + get_online_cpus(); 2789 2801 /* Destroy per cpu threads */ 2790 2802 for_each_online_cpu(cpu) { 2791 2803 bnx2fc_percpu_thread_destroy(cpu); 2792 2804 } 2793 2805 2794 - __unregister_hotcpu_notifier(&bnx2fc_cpu_notifier); 2806 + cpuhp_remove_state_nocalls(bnx2fc_online_state); 2807 + cpuhp_remove_state_nocalls(CPUHP_SCSI_BNX2FC_DEAD); 2795 2808 2796 - cpu_notifier_register_done(); 2809 + put_online_cpus(); 2797 2810 2798 2811 destroy_workqueue(bnx2fc_wq); 2799 2812 /*
+31 -49
drivers/scsi/bnx2i/bnx2i_init.c
··· 70 70 71 71 DEFINE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu); 72 72 73 - static int bnx2i_cpu_callback(struct notifier_block *nfb, 74 - unsigned long action, void *hcpu); 75 - /* notification function for CPU hotplug events */ 76 - static struct notifier_block bnx2i_cpu_notifier = { 77 - .notifier_call = bnx2i_cpu_callback, 78 - }; 79 - 80 - 81 73 /** 82 74 * bnx2i_identify_device - identifies NetXtreme II device type 83 75 * @hba: Adapter structure pointer ··· 453 461 kthread_stop(thread); 454 462 } 455 463 456 - 457 - /** 458 - * bnx2i_cpu_callback - Handler for CPU hotplug events 459 - * 460 - * @nfb: The callback data block 461 - * @action: The event triggering the callback 462 - * @hcpu: The index of the CPU that the event is for 463 - * 464 - * This creates or destroys per-CPU data for iSCSI 465 - * 466 - * Returns NOTIFY_OK always. 467 - */ 468 - static int bnx2i_cpu_callback(struct notifier_block *nfb, 469 - unsigned long action, void *hcpu) 464 + static int bnx2i_cpu_online(unsigned int cpu) 470 465 { 471 - unsigned cpu = (unsigned long)hcpu; 472 - 473 - switch (action) { 474 - case CPU_ONLINE: 475 - case CPU_ONLINE_FROZEN: 476 - printk(KERN_INFO "bnx2i: CPU %x online: Create Rx thread\n", 477 - cpu); 478 - bnx2i_percpu_thread_create(cpu); 479 - break; 480 - case CPU_DEAD: 481 - case CPU_DEAD_FROZEN: 482 - printk(KERN_INFO "CPU %x offline: Remove Rx thread\n", cpu); 483 - bnx2i_percpu_thread_destroy(cpu); 484 - break; 485 - default: 486 - break; 487 - } 488 - return NOTIFY_OK; 466 + pr_info("bnx2i: CPU %x online: Create Rx thread\n", cpu); 467 + bnx2i_percpu_thread_create(cpu); 468 + return 0; 489 469 } 490 470 471 + static int bnx2i_cpu_dead(unsigned int cpu) 472 + { 473 + pr_info("CPU %x offline: Remove Rx thread\n", cpu); 474 + bnx2i_percpu_thread_destroy(cpu); 475 + return 0; 476 + } 477 + 478 + static enum cpuhp_state bnx2i_online_state; 491 479 492 480 /** 493 481 * bnx2i_mod_init - module init entry point ··· 511 539 p->iothread = NULL; 512 540 } 513 541 514 - cpu_notifier_register_begin(); 542 + get_online_cpus(); 515 543 516 544 for_each_online_cpu(cpu) 517 545 bnx2i_percpu_thread_create(cpu); 518 546 519 - /* Initialize per CPU interrupt thread */ 520 - __register_hotcpu_notifier(&bnx2i_cpu_notifier); 547 + err = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, 548 + "scsi/bnx2i:online", 549 + bnx2i_cpu_online, NULL); 550 + if (err < 0) 551 + goto remove_threads; 552 + bnx2i_online_state = err; 521 553 522 - cpu_notifier_register_done(); 523 - 554 + cpuhp_setup_state_nocalls(CPUHP_SCSI_BNX2I_DEAD, "scsi/bnx2i:dead", 555 + NULL, bnx2i_cpu_dead); 556 + put_online_cpus(); 524 557 return 0; 525 558 559 + remove_threads: 560 + for_each_online_cpu(cpu) 561 + bnx2i_percpu_thread_destroy(cpu); 562 + put_online_cpus(); 563 + cnic_unregister_driver(CNIC_ULP_ISCSI); 526 564 unreg_xport: 527 565 iscsi_unregister_transport(&bnx2i_iscsi_transport); 528 566 out: ··· 569 587 } 570 588 mutex_unlock(&bnx2i_dev_lock); 571 589 572 - cpu_notifier_register_begin(); 590 + get_online_cpus(); 573 591 574 592 for_each_online_cpu(cpu) 575 593 bnx2i_percpu_thread_destroy(cpu); 576 594 577 - __unregister_hotcpu_notifier(&bnx2i_cpu_notifier); 578 - 579 - cpu_notifier_register_done(); 595 + cpuhp_remove_state_nocalls(bnx2i_online_state); 596 + cpuhp_remove_state_nocalls(CPUHP_SCSI_BNX2I_DEAD); 597 + put_online_cpus(); 580 598 581 599 iscsi_unregister_transport(&bnx2i_iscsi_transport); 582 600 cnic_unregister_driver(CNIC_ULP_ISCSI);
+32 -64
drivers/scsi/qedi/qedi_main.c
··· 1612 1612 return 0; 1613 1613 } 1614 1614 1615 - static void qedi_percpu_thread_create(unsigned int cpu) 1615 + static int qedi_cpu_online(unsigned int cpu) 1616 1616 { 1617 - struct qedi_percpu_s *p; 1617 + struct qedi_percpu_s *p = this_cpu_ptr(&qedi_percpu); 1618 1618 struct task_struct *thread; 1619 - 1620 - p = &per_cpu(qedi_percpu, cpu); 1621 1619 1622 1620 thread = kthread_create_on_node(qedi_percpu_io_thread, (void *)p, 1623 1621 cpu_to_node(cpu), 1624 1622 "qedi_thread/%d", cpu); 1625 - if (likely(!IS_ERR(thread))) { 1626 - kthread_bind(thread, cpu); 1627 - p->iothread = thread; 1628 - wake_up_process(thread); 1629 - } 1623 + if (IS_ERR(thread)) 1624 + return PTR_ERR(thread); 1625 + 1626 + kthread_bind(thread, cpu); 1627 + p->iothread = thread; 1628 + wake_up_process(thread); 1629 + return 0; 1630 1630 } 1631 1631 1632 - static void qedi_percpu_thread_destroy(unsigned int cpu) 1632 + static int qedi_cpu_offline(unsigned int cpu) 1633 1633 { 1634 - struct qedi_percpu_s *p; 1635 - struct task_struct *thread; 1634 + struct qedi_percpu_s *p = this_cpu_ptr(&qedi_percpu); 1636 1635 struct qedi_work *work, *tmp; 1636 + struct task_struct *thread; 1637 1637 1638 - p = &per_cpu(qedi_percpu, cpu); 1639 1638 spin_lock_bh(&p->p_work_lock); 1640 1639 thread = p->iothread; 1641 1640 p->iothread = NULL; ··· 1649 1650 spin_unlock_bh(&p->p_work_lock); 1650 1651 if (thread) 1651 1652 kthread_stop(thread); 1653 + return 0; 1652 1654 } 1653 - 1654 - static int qedi_cpu_callback(struct notifier_block *nfb, 1655 - unsigned long action, void *hcpu) 1656 - { 1657 - unsigned int cpu = (unsigned long)hcpu; 1658 - 1659 - switch (action) { 1660 - case CPU_ONLINE: 1661 - case CPU_ONLINE_FROZEN: 1662 - QEDI_ERR(NULL, "CPU %d online.\n", cpu); 1663 - qedi_percpu_thread_create(cpu); 1664 - break; 1665 - case CPU_DEAD: 1666 - case CPU_DEAD_FROZEN: 1667 - QEDI_ERR(NULL, "CPU %d offline.\n", cpu); 1668 - qedi_percpu_thread_destroy(cpu); 1669 - break; 1670 - default: 1671 - break; 1672 - } 1673 - 1674 - return NOTIFY_OK; 1675 - } 1676 - 1677 - static struct notifier_block qedi_cpu_notifier = { 1678 - .notifier_call = qedi_cpu_callback, 1679 - }; 1680 1655 1681 1656 void qedi_reset_host_mtu(struct qedi_ctx *qedi, u16 mtu) 1682 1657 { ··· 2011 2038 }; 2012 2039 MODULE_DEVICE_TABLE(pci, qedi_pci_tbl); 2013 2040 2041 + static enum cpuhp_state qedi_cpuhp_state; 2042 + 2014 2043 static struct pci_driver qedi_pci_driver = { 2015 2044 .name = QEDI_MODULE_NAME, 2016 2045 .id_table = qedi_pci_tbl, ··· 2022 2047 2023 2048 static int __init qedi_init(void) 2024 2049 { 2025 - int rc = 0; 2026 - int ret; 2027 2050 struct qedi_percpu_s *p; 2028 - unsigned int cpu = 0; 2051 + int cpu, rc = 0; 2029 2052 2030 2053 qedi_ops = qed_get_iscsi_ops(); 2031 2054 if (!qedi_ops) { 2032 2055 QEDI_ERR(NULL, "Failed to get qed iSCSI operations\n"); 2033 - rc = -EINVAL; 2034 - goto exit_qedi_init_0; 2056 + return -EINVAL; 2035 2057 } 2036 2058 2037 2059 #ifdef CONFIG_DEBUG_FS ··· 2042 2070 goto exit_qedi_init_1; 2043 2071 } 2044 2072 2045 - register_hotcpu_notifier(&qedi_cpu_notifier); 2046 - 2047 - ret = pci_register_driver(&qedi_pci_driver); 2048 - if (ret) { 2049 - QEDI_ERR(NULL, "Failed to register driver\n"); 2050 - rc = -EINVAL; 2051 - goto exit_qedi_init_2; 2052 - } 2053 - 2054 2073 for_each_possible_cpu(cpu) { 2055 2074 p = &per_cpu(qedi_percpu, cpu); 2056 2075 INIT_LIST_HEAD(&p->work_list); ··· 2049 2086 p->iothread = NULL; 2050 2087 } 2051 2088 2052 - for_each_online_cpu(cpu) 2053 - qedi_percpu_thread_create(cpu); 2089 + rc = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "scsi/qedi:online", 2090 + qedi_cpu_online, qedi_cpu_offline); 2091 + if (rc < 0) 2092 + goto exit_qedi_init_2; 2093 + qedi_cpuhp_state = rc; 2054 2094 2055 - return rc; 2095 + rc = pci_register_driver(&qedi_pci_driver); 2096 + if (rc) { 2097 + QEDI_ERR(NULL, "Failed to register driver\n"); 2098 + goto exit_qedi_hp; 2099 + } 2056 2100 2101 + return 0; 2102 + 2103 + exit_qedi_hp: 2104 + cpuhp_remove_state(qedi_cpuhp_state); 2057 2105 exit_qedi_init_2: 2058 2106 iscsi_unregister_transport(&qedi_iscsi_transport); 2059 2107 exit_qedi_init_1: ··· 2072 2098 qedi_dbg_exit(); 2073 2099 #endif 2074 2100 qed_put_iscsi_ops(); 2075 - exit_qedi_init_0: 2076 2101 return rc; 2077 2102 } 2078 2103 2079 2104 static void __exit qedi_cleanup(void) 2080 2105 { 2081 - unsigned int cpu = 0; 2082 - 2083 - for_each_online_cpu(cpu) 2084 - qedi_percpu_thread_destroy(cpu); 2085 - 2086 2106 pci_unregister_driver(&qedi_pci_driver); 2087 - unregister_hotcpu_notifier(&qedi_cpu_notifier); 2107 + cpuhp_remove_state(qedi_cpuhp_state); 2088 2108 iscsi_unregister_transport(&qedi_iscsi_transport); 2089 2109 2090 2110 #ifdef CONFIG_DEBUG_FS
+46 -41
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
··· 967 967 } 968 968 969 969 #ifdef CONFIG_HOTPLUG_CPU 970 - static int 971 - cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) 970 + static enum cpuhp_state lustre_cpu_online; 971 + 972 + static void cfs_cpu_incr_cpt_version(void) 972 973 { 973 - unsigned int cpu = (unsigned long)hcpu; 974 - bool warn; 975 - 976 - switch (action) { 977 - case CPU_DEAD: 978 - case CPU_DEAD_FROZEN: 979 - case CPU_ONLINE: 980 - case CPU_ONLINE_FROZEN: 981 - spin_lock(&cpt_data.cpt_lock); 982 - cpt_data.cpt_version++; 983 - spin_unlock(&cpt_data.cpt_lock); 984 - /* Fall through */ 985 - default: 986 - if (action != CPU_DEAD && action != CPU_DEAD_FROZEN) { 987 - CDEBUG(D_INFO, "CPU changed [cpu %u action %lx]\n", 988 - cpu, action); 989 - break; 990 - } 991 - 992 - mutex_lock(&cpt_data.cpt_mutex); 993 - /* if all HTs in a core are offline, it may break affinity */ 994 - cpumask_copy(cpt_data.cpt_cpumask, 995 - topology_sibling_cpumask(cpu)); 996 - warn = cpumask_any_and(cpt_data.cpt_cpumask, 997 - cpu_online_mask) >= nr_cpu_ids; 998 - mutex_unlock(&cpt_data.cpt_mutex); 999 - CDEBUG(warn ? D_WARNING : D_INFO, 1000 - "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u action: %lx]\n", 1001 - cpu, action); 1002 - } 1003 - 1004 - return NOTIFY_OK; 974 + spin_lock(&cpt_data.cpt_lock); 975 + cpt_data.cpt_version++; 976 + spin_unlock(&cpt_data.cpt_lock); 1005 977 } 1006 978 1007 - static struct notifier_block cfs_cpu_notifier = { 1008 - .notifier_call = cfs_cpu_notify, 1009 - .priority = 0 1010 - }; 979 + static int cfs_cpu_online(unsigned int cpu) 980 + { 981 + cfs_cpu_incr_cpt_version(); 982 + return 0; 983 + } 1011 984 985 + static int cfs_cpu_dead(unsigned int cpu) 986 + { 987 + bool warn; 988 + 989 + cfs_cpu_incr_cpt_version(); 990 + 991 + mutex_lock(&cpt_data.cpt_mutex); 992 + /* if all HTs in a core are offline, it may break affinity */ 993 + cpumask_copy(cpt_data.cpt_cpumask, topology_sibling_cpumask(cpu)); 994 + warn = cpumask_any_and(cpt_data.cpt_cpumask, 995 + cpu_online_mask) >= nr_cpu_ids; 996 + mutex_unlock(&cpt_data.cpt_mutex); 997 + CDEBUG(warn ? D_WARNING : D_INFO, 998 + "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u]\n", 999 + cpu); 1000 + return 0; 1001 + } 1012 1002 #endif 1013 1003 1014 1004 void ··· 1008 1018 cfs_cpt_table_free(cfs_cpt_table); 1009 1019 1010 1020 #ifdef CONFIG_HOTPLUG_CPU 1011 - unregister_hotcpu_notifier(&cfs_cpu_notifier); 1021 + if (lustre_cpu_online > 0) 1022 + cpuhp_remove_state_nocalls(lustre_cpu_online); 1023 + cpuhp_remove_state_nocalls(CPUHP_LUSTRE_CFS_DEAD); 1012 1024 #endif 1013 1025 if (cpt_data.cpt_cpumask) 1014 1026 LIBCFS_FREE(cpt_data.cpt_cpumask, cpumask_size()); ··· 1019 1027 int 1020 1028 cfs_cpu_init(void) 1021 1029 { 1030 + int ret = 0; 1031 + 1022 1032 LASSERT(!cfs_cpt_table); 1023 1033 1024 1034 memset(&cpt_data, 0, sizeof(cpt_data)); ··· 1035 1041 mutex_init(&cpt_data.cpt_mutex); 1036 1042 1037 1043 #ifdef CONFIG_HOTPLUG_CPU 1038 - register_hotcpu_notifier(&cfs_cpu_notifier); 1044 + ret = cpuhp_setup_state_nocalls(CPUHP_LUSTRE_CFS_DEAD, 1045 + "staging/lustre/cfe:dead", NULL, 1046 + cfs_cpu_dead); 1047 + if (ret < 0) 1048 + goto failed; 1049 + ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, 1050 + "staging/lustre/cfe:online", 1051 + cfs_cpu_online, NULL); 1052 + if (ret < 0) 1053 + goto failed; 1054 + lustre_cpu_online = ret; 1039 1055 #endif 1056 + ret = -EINVAL; 1040 1057 1041 1058 if (*cpu_pattern) { 1042 1059 cfs_cpt_table = cfs_cpt_table_create_pattern(cpu_pattern); ··· 1080 1075 1081 1076 failed: 1082 1077 cfs_cpu_fini(); 1083 - return -1; 1078 + return ret; 1084 1079 } 1085 1080 1086 1081 #endif
+1 -1
drivers/xen/events/events_fifo.c
··· 445 445 evtchn_ops = &evtchn_ops_fifo; 446 446 447 447 cpuhp_setup_state_nocalls(CPUHP_XEN_EVTCHN_PREPARE, 448 - "CPUHP_XEN_EVTCHN_PREPARE", 448 + "xen/evtchn:prepare", 449 449 xen_evtchn_cpu_prepare, xen_evtchn_cpu_dead); 450 450 out: 451 451 put_cpu();
-90
include/linux/cpu.h
··· 57 57 58 58 #define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */ 59 59 #define CPU_UP_PREPARE 0x0003 /* CPU (unsigned)v coming up */ 60 - #define CPU_UP_CANCELED 0x0004 /* CPU (unsigned)v NOT coming up */ 61 - #define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */ 62 - #define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */ 63 60 #define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */ 64 61 #define CPU_POST_DEAD 0x0009 /* CPU (unsigned)v dead, cpu_hotplug 65 62 * lock is dropped */ ··· 77 80 78 81 #ifdef CONFIG_SMP 79 82 extern bool cpuhp_tasks_frozen; 80 - /* Need to know about CPUs going up/down? */ 81 - #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE) 82 - #define cpu_notifier(fn, pri) { \ 83 - static struct notifier_block fn##_nb = \ 84 - { .notifier_call = fn, .priority = pri }; \ 85 - register_cpu_notifier(&fn##_nb); \ 86 - } 87 - 88 - #define __cpu_notifier(fn, pri) { \ 89 - static struct notifier_block fn##_nb = \ 90 - { .notifier_call = fn, .priority = pri }; \ 91 - __register_cpu_notifier(&fn##_nb); \ 92 - } 93 - 94 - extern int register_cpu_notifier(struct notifier_block *nb); 95 - extern int __register_cpu_notifier(struct notifier_block *nb); 96 - extern void unregister_cpu_notifier(struct notifier_block *nb); 97 - extern void __unregister_cpu_notifier(struct notifier_block *nb); 98 - 99 - #else /* #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE) */ 100 - #define cpu_notifier(fn, pri) do { (void)(fn); } while (0) 101 - #define __cpu_notifier(fn, pri) do { (void)(fn); } while (0) 102 - 103 - static inline int register_cpu_notifier(struct notifier_block *nb) 104 - { 105 - return 0; 106 - } 107 - 108 - static inline int __register_cpu_notifier(struct notifier_block *nb) 109 - { 110 - return 0; 111 - } 112 - 113 - static inline void unregister_cpu_notifier(struct notifier_block *nb) 114 - { 115 - } 116 - 117 - static inline void __unregister_cpu_notifier(struct notifier_block *nb) 118 - { 119 - } 120 - #endif 121 - 122 83 int cpu_up(unsigned int cpu); 123 84 void notify_cpu_starting(unsigned int cpu); 124 85 extern void cpu_maps_update_begin(void); 125 86 extern void cpu_maps_update_done(void); 126 87 127 - #define cpu_notifier_register_begin cpu_maps_update_begin 128 - #define cpu_notifier_register_done cpu_maps_update_done 129 - 130 88 #else /* CONFIG_SMP */ 131 89 #define cpuhp_tasks_frozen 0 132 - 133 - #define cpu_notifier(fn, pri) do { (void)(fn); } while (0) 134 - #define __cpu_notifier(fn, pri) do { (void)(fn); } while (0) 135 - 136 - static inline int register_cpu_notifier(struct notifier_block *nb) 137 - { 138 - return 0; 139 - } 140 - 141 - static inline int __register_cpu_notifier(struct notifier_block *nb) 142 - { 143 - return 0; 144 - } 145 - 146 - static inline void unregister_cpu_notifier(struct notifier_block *nb) 147 - { 148 - } 149 - 150 - static inline void __unregister_cpu_notifier(struct notifier_block *nb) 151 - { 152 - } 153 90 154 91 static inline void cpu_maps_update_begin(void) 155 92 { 156 93 } 157 94 158 95 static inline void cpu_maps_update_done(void) 159 - { 160 - } 161 - 162 - static inline void cpu_notifier_register_begin(void) 163 - { 164 - } 165 - 166 - static inline void cpu_notifier_register_done(void) 167 96 { 168 97 } 169 98 ··· 105 182 extern void put_online_cpus(void); 106 183 extern void cpu_hotplug_disable(void); 107 184 extern void cpu_hotplug_enable(void); 108 - #define hotcpu_notifier(fn, pri) cpu_notifier(fn, pri) 109 - #define __hotcpu_notifier(fn, pri) __cpu_notifier(fn, pri) 110 - #define register_hotcpu_notifier(nb) register_cpu_notifier(nb) 111 - #define __register_hotcpu_notifier(nb) __register_cpu_notifier(nb) 112 - #define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb) 113 - #define __unregister_hotcpu_notifier(nb) __unregister_cpu_notifier(nb) 114 185 void clear_tasks_mm_cpumask(int cpu); 115 186 int cpu_down(unsigned int cpu); 116 187 ··· 116 199 #define put_online_cpus() do { } while (0) 117 200 #define cpu_hotplug_disable() do { } while (0) 118 201 #define cpu_hotplug_enable() do { } while (0) 119 - #define hotcpu_notifier(fn, pri) do { (void)(fn); } while (0) 120 - #define __hotcpu_notifier(fn, pri) do { (void)(fn); } while (0) 121 - /* These aren't inline functions due to a GCC bug. */ 122 - #define register_hotcpu_notifier(nb) ({ (void)(nb); 0; }) 123 - #define __register_hotcpu_notifier(nb) ({ (void)(nb); 0; }) 124 - #define unregister_hotcpu_notifier(nb) ({ (void)(nb); }) 125 - #define __unregister_hotcpu_notifier(nb) ({ (void)(nb); }) 126 202 #endif /* CONFIG_HOTPLUG_CPU */ 127 203 128 204 #ifdef CONFIG_PM_SLEEP_SMP
+3 -6
include/linux/cpuhotplug.h
··· 41 41 CPUHP_NET_DEV_DEAD, 42 42 CPUHP_PCI_XGENE_DEAD, 43 43 CPUHP_IOMMU_INTEL_DEAD, 44 + CPUHP_LUSTRE_CFS_DEAD, 45 + CPUHP_SCSI_BNX2FC_DEAD, 46 + CPUHP_SCSI_BNX2I_DEAD, 44 47 CPUHP_WORKQUEUE_PREP, 45 48 CPUHP_POWER_NUMA_PREPARE, 46 49 CPUHP_HRTIMERS_PREPARE, ··· 59 56 CPUHP_POWERPC_MMU_CTX_PREPARE, 60 57 CPUHP_XEN_PREPARE, 61 58 CPUHP_XEN_EVTCHN_PREPARE, 62 - CPUHP_NOTIFY_PREPARE, 63 59 CPUHP_ARM_SHMOBILE_SCU_PREPARE, 64 60 CPUHP_SH_SH3X_PREPARE, 65 61 CPUHP_BLK_MQ_PREPARE, ··· 73 71 CPUHP_KVM_PPC_BOOK3S_PREPARE, 74 72 CPUHP_ZCOMP_PREPARE, 75 73 CPUHP_TIMERS_DEAD, 76 - CPUHP_NOTF_ERR_INJ_PREPARE, 77 74 CPUHP_MIPS_SOC_PREPARE, 78 75 CPUHP_BRINGUP_CPU, 79 76 CPUHP_AP_IDLE_DEAD, ··· 80 79 CPUHP_AP_SCHED_STARTING, 81 80 CPUHP_AP_RCUTREE_DYING, 82 81 CPUHP_AP_IRQ_GIC_STARTING, 83 - CPUHP_AP_IRQ_GICV3_STARTING, 84 82 CPUHP_AP_IRQ_HIP04_STARTING, 85 83 CPUHP_AP_IRQ_ARMADA_XP_STARTING, 86 - CPUHP_AP_IRQ_ARMADA_CASC_STARTING, 87 84 CPUHP_AP_IRQ_BCM2836_STARTING, 88 85 CPUHP_AP_ARM_MVEBU_COHERENCY, 89 86 CPUHP_AP_PERF_X86_UNCORE_STARTING, ··· 117 118 CPUHP_AP_DUMMY_TIMER_STARTING, 118 119 CPUHP_AP_ARM_XEN_STARTING, 119 120 CPUHP_AP_ARM_CORESIGHT_STARTING, 120 - CPUHP_AP_ARM_CORESIGHT4_STARTING, 121 121 CPUHP_AP_ARM64_ISNDEP_STARTING, 122 122 CPUHP_AP_SMPCFD_DYING, 123 123 CPUHP_AP_X86_TBOOT_DYING, ··· 140 142 CPUHP_AP_PERF_ARM_L2X0_ONLINE, 141 143 CPUHP_AP_WORKQUEUE_ONLINE, 142 144 CPUHP_AP_RCUTREE_ONLINE, 143 - CPUHP_AP_NOTIFY_ONLINE, 144 145 CPUHP_AP_ONLINE_DYN, 145 146 CPUHP_AP_ONLINE_DYN_END = CPUHP_AP_ONLINE_DYN + 30, 146 147 CPUHP_AP_X86_HPET_ONLINE,
+51 -184
kernel/cpu.c
··· 183 183 /* 184 184 * The following two APIs (cpu_maps_update_begin/done) must be used when 185 185 * attempting to serialize the updates to cpu_online_mask & cpu_present_mask. 186 - * The APIs cpu_notifier_register_begin/done() must be used to protect CPU 187 - * hotplug callback (un)registration performed using __register_cpu_notifier() 188 - * or __unregister_cpu_notifier(). 189 186 */ 190 187 void cpu_maps_update_begin(void) 191 188 { 192 189 mutex_lock(&cpu_add_remove_lock); 193 190 } 194 - EXPORT_SYMBOL(cpu_notifier_register_begin); 195 191 196 192 void cpu_maps_update_done(void) 197 193 { 198 194 mutex_unlock(&cpu_add_remove_lock); 199 195 } 200 - EXPORT_SYMBOL(cpu_notifier_register_done); 201 - 202 - static RAW_NOTIFIER_HEAD(cpu_chain); 203 196 204 197 /* If set, cpu_up and cpu_down will return -EBUSY and do nothing. 205 198 * Should always be manipulated under cpu_add_remove_lock ··· 342 349 EXPORT_SYMBOL_GPL(cpu_hotplug_enable); 343 350 #endif /* CONFIG_HOTPLUG_CPU */ 344 351 345 - /* Need to know about CPUs going up/down? */ 346 - int register_cpu_notifier(struct notifier_block *nb) 347 - { 348 - int ret; 349 - cpu_maps_update_begin(); 350 - ret = raw_notifier_chain_register(&cpu_chain, nb); 351 - cpu_maps_update_done(); 352 - return ret; 353 - } 354 - 355 - int __register_cpu_notifier(struct notifier_block *nb) 356 - { 357 - return raw_notifier_chain_register(&cpu_chain, nb); 358 - } 359 - 360 - static int __cpu_notify(unsigned long val, unsigned int cpu, int nr_to_call, 361 - int *nr_calls) 362 - { 363 - unsigned long mod = cpuhp_tasks_frozen ? CPU_TASKS_FROZEN : 0; 364 - void *hcpu = (void *)(long)cpu; 365 - 366 - int ret; 367 - 368 - ret = __raw_notifier_call_chain(&cpu_chain, val | mod, hcpu, nr_to_call, 369 - nr_calls); 370 - 371 - return notifier_to_errno(ret); 372 - } 373 - 374 - static int cpu_notify(unsigned long val, unsigned int cpu) 375 - { 376 - return __cpu_notify(val, cpu, -1, NULL); 377 - } 378 - 379 - static void cpu_notify_nofail(unsigned long val, unsigned int cpu) 380 - { 381 - BUG_ON(cpu_notify(val, cpu)); 382 - } 383 - 384 352 /* Notifier wrappers for transitioning to state machine */ 385 - static int notify_prepare(unsigned int cpu) 386 - { 387 - int nr_calls = 0; 388 - int ret; 389 - 390 - ret = __cpu_notify(CPU_UP_PREPARE, cpu, -1, &nr_calls); 391 - if (ret) { 392 - nr_calls--; 393 - printk(KERN_WARNING "%s: attempt to bring up CPU %u failed\n", 394 - __func__, cpu); 395 - __cpu_notify(CPU_UP_CANCELED, cpu, nr_calls, NULL); 396 - } 397 - return ret; 398 - } 399 - 400 - static int notify_online(unsigned int cpu) 401 - { 402 - cpu_notify(CPU_ONLINE, cpu); 403 - return 0; 404 - } 405 353 406 354 static int bringup_wait_for_ap(unsigned int cpu) 407 355 { ··· 367 433 /* Arch-specific enabling code. */ 368 434 ret = __cpu_up(cpu, idle); 369 435 irq_unlock_sparse(); 370 - if (ret) { 371 - cpu_notify(CPU_UP_CANCELED, cpu); 436 + if (ret) 372 437 return ret; 373 - } 374 438 ret = bringup_wait_for_ap(cpu); 375 439 BUG_ON(!cpu_online(cpu)); 376 440 return ret; ··· 497 565 BUG_ON(st->state < CPUHP_AP_ONLINE_IDLE); 498 566 499 567 undo_cpu_down(cpu, st); 500 - /* 501 - * This is a momentary workaround to keep the notifier users 502 - * happy. Will go away once we got rid of the notifiers. 503 - */ 504 - cpu_notify_nofail(CPU_DOWN_FAILED, cpu); 505 568 st->rollback = false; 506 569 } else { 507 570 /* Cannot happen .... */ ··· 586 659 kthread_unpark(this_cpu_read(cpuhp_state.thread)); 587 660 } 588 661 589 - EXPORT_SYMBOL(register_cpu_notifier); 590 - EXPORT_SYMBOL(__register_cpu_notifier); 591 - void unregister_cpu_notifier(struct notifier_block *nb) 592 - { 593 - cpu_maps_update_begin(); 594 - raw_notifier_chain_unregister(&cpu_chain, nb); 595 - cpu_maps_update_done(); 596 - } 597 - EXPORT_SYMBOL(unregister_cpu_notifier); 598 - 599 - void __unregister_cpu_notifier(struct notifier_block *nb) 600 - { 601 - raw_notifier_chain_unregister(&cpu_chain, nb); 602 - } 603 - EXPORT_SYMBOL(__unregister_cpu_notifier); 604 - 605 662 #ifdef CONFIG_HOTPLUG_CPU 606 663 /** 607 664 * clear_tasks_mm_cpumask - Safely clear tasks' mm_cpumask for a CPU ··· 650 739 p->comm, task_pid_nr(p), dead_cpu, p->state, p->flags); 651 740 } 652 741 read_unlock(&tasklist_lock); 653 - } 654 - 655 - static int notify_down_prepare(unsigned int cpu) 656 - { 657 - int err, nr_calls = 0; 658 - 659 - err = __cpu_notify(CPU_DOWN_PREPARE, cpu, -1, &nr_calls); 660 - if (err) { 661 - nr_calls--; 662 - __cpu_notify(CPU_DOWN_FAILED, cpu, nr_calls, NULL); 663 - pr_warn("%s: attempt to take down CPU %u failed\n", 664 - __func__, cpu); 665 - } 666 - return err; 667 742 } 668 743 669 744 /* Take this CPU down. */ ··· 730 833 return 0; 731 834 } 732 835 733 - static int notify_dead(unsigned int cpu) 734 - { 735 - cpu_notify_nofail(CPU_DEAD, cpu); 736 - check_for_tasks(cpu); 737 - return 0; 738 - } 739 - 740 836 static void cpuhp_complete_idle_dead(void *arg) 741 837 { 742 838 struct cpuhp_cpu_state *st = arg; ··· 753 863 } 754 864 755 865 #else 756 - #define notify_down_prepare NULL 757 866 #define takedown_cpu NULL 758 - #define notify_dead NULL 759 867 #endif 760 868 761 869 #ifdef CONFIG_HOTPLUG_CPU ··· 812 924 hasdied = prev_state != st->state && st->state == CPUHP_OFFLINE; 813 925 out: 814 926 cpu_hotplug_done(); 815 - /* This post dead nonsense must die */ 816 - if (!ret && hasdied) 817 - cpu_notify_nofail(CPU_POST_DEAD, cpu); 818 927 return ret; 819 928 } 820 929 ··· 1177 1292 .teardown.single = rcutree_dead_cpu, 1178 1293 }, 1179 1294 /* 1180 - * Preparatory and dead notifiers. Will be replaced once the notifiers 1181 - * are converted to states. 1182 - */ 1183 - [CPUHP_NOTIFY_PREPARE] = { 1184 - .name = "notify:prepare", 1185 - .startup.single = notify_prepare, 1186 - .teardown.single = notify_dead, 1187 - .skip_onerr = true, 1188 - .cant_stop = true, 1189 - }, 1190 - /* 1191 1295 * On the tear-down path, timers_dead_cpu() must be invoked 1192 1296 * before blk_mq_queue_reinit_notify() from notify_dead(), 1193 1297 * otherwise a RCU stall occurs. ··· 1265 1391 .startup.single = rcutree_online_cpu, 1266 1392 .teardown.single = rcutree_offline_cpu, 1267 1393 }, 1268 - 1269 - /* 1270 - * Online/down_prepare notifiers. Will be removed once the notifiers 1271 - * are converted to states. 1272 - */ 1273 - [CPUHP_AP_NOTIFY_ONLINE] = { 1274 - .name = "notify:online", 1275 - .startup.single = notify_online, 1276 - .teardown.single = notify_down_prepare, 1277 - .skip_onerr = true, 1278 - }, 1279 1394 #endif 1280 1395 /* 1281 1396 * The dynamically registered state space is here ··· 1295 1432 return 0; 1296 1433 } 1297 1434 1298 - static void cpuhp_store_callbacks(enum cpuhp_state state, 1299 - const char *name, 1300 - int (*startup)(unsigned int cpu), 1301 - int (*teardown)(unsigned int cpu), 1302 - bool multi_instance) 1435 + /* 1436 + * Returns a free for dynamic slot assignment of the Online state. The states 1437 + * are protected by the cpuhp_slot_states mutex and an empty slot is identified 1438 + * by having no name assigned. 1439 + */ 1440 + static int cpuhp_reserve_state(enum cpuhp_state state) 1441 + { 1442 + enum cpuhp_state i; 1443 + 1444 + for (i = CPUHP_AP_ONLINE_DYN; i <= CPUHP_AP_ONLINE_DYN_END; i++) { 1445 + if (!cpuhp_ap_states[i].name) 1446 + return i; 1447 + } 1448 + WARN(1, "No more dynamic states available for CPU hotplug\n"); 1449 + return -ENOSPC; 1450 + } 1451 + 1452 + static int cpuhp_store_callbacks(enum cpuhp_state state, const char *name, 1453 + int (*startup)(unsigned int cpu), 1454 + int (*teardown)(unsigned int cpu), 1455 + bool multi_instance) 1303 1456 { 1304 1457 /* (Un)Install the callbacks for further cpu hotplug operations */ 1305 1458 struct cpuhp_step *sp; 1459 + int ret = 0; 1306 1460 1307 1461 mutex_lock(&cpuhp_state_mutex); 1462 + 1463 + if (state == CPUHP_AP_ONLINE_DYN) { 1464 + ret = cpuhp_reserve_state(state); 1465 + if (ret < 0) 1466 + goto out; 1467 + state = ret; 1468 + } 1308 1469 sp = cpuhp_get_step(state); 1470 + if (name && sp->name) { 1471 + ret = -EBUSY; 1472 + goto out; 1473 + } 1309 1474 sp->startup.single = startup; 1310 1475 sp->teardown.single = teardown; 1311 1476 sp->name = name; 1312 1477 sp->multi_instance = multi_instance; 1313 1478 INIT_HLIST_HEAD(&sp->list); 1479 + out: 1314 1480 mutex_unlock(&cpuhp_state_mutex); 1481 + return ret; 1315 1482 } 1316 1483 1317 1484 static void *cpuhp_get_teardown_cb(enum cpuhp_state state) ··· 1402 1509 } 1403 1510 } 1404 1511 1405 - /* 1406 - * Returns a free for dynamic slot assignment of the Online state. The states 1407 - * are protected by the cpuhp_slot_states mutex and an empty slot is identified 1408 - * by having no name assigned. 1409 - */ 1410 - static int cpuhp_reserve_state(enum cpuhp_state state) 1411 - { 1412 - enum cpuhp_state i; 1413 - 1414 - mutex_lock(&cpuhp_state_mutex); 1415 - for (i = CPUHP_AP_ONLINE_DYN; i <= CPUHP_AP_ONLINE_DYN_END; i++) { 1416 - if (cpuhp_ap_states[i].name) 1417 - continue; 1418 - 1419 - cpuhp_ap_states[i].name = "Reserved"; 1420 - mutex_unlock(&cpuhp_state_mutex); 1421 - return i; 1422 - } 1423 - mutex_unlock(&cpuhp_state_mutex); 1424 - WARN(1, "No more dynamic states available for CPU hotplug\n"); 1425 - return -ENOSPC; 1426 - } 1427 - 1428 1512 int __cpuhp_state_add_instance(enum cpuhp_state state, struct hlist_node *node, 1429 1513 bool invoke) 1430 1514 { ··· 1450 1580 1451 1581 /** 1452 1582 * __cpuhp_setup_state - Setup the callbacks for an hotplug machine state 1453 - * @state: The state to setup 1454 - * @invoke: If true, the startup function is invoked for cpus where 1455 - * cpu state >= @state 1456 - * @startup: startup callback function 1457 - * @teardown: teardown callback function 1583 + * @state: The state to setup 1584 + * @invoke: If true, the startup function is invoked for cpus where 1585 + * cpu state >= @state 1586 + * @startup: startup callback function 1587 + * @teardown: teardown callback function 1588 + * @multi_instance: State is set up for multiple instances which get 1589 + * added afterwards. 1458 1590 * 1459 1591 * Returns: 1460 1592 * On success: ··· 1471 1599 bool multi_instance) 1472 1600 { 1473 1601 int cpu, ret = 0; 1474 - int dyn_state = 0; 1475 1602 1476 1603 if (cpuhp_cb_check(state) || !name) 1477 1604 return -EINVAL; 1478 1605 1479 1606 get_online_cpus(); 1480 1607 1481 - /* currently assignments for the ONLINE state are possible */ 1482 - if (state == CPUHP_AP_ONLINE_DYN) { 1483 - dyn_state = 1; 1484 - ret = cpuhp_reserve_state(state); 1485 - if (ret < 0) 1486 - goto out; 1487 - state = ret; 1488 - } 1608 + ret = cpuhp_store_callbacks(state, name, startup, teardown, 1609 + multi_instance); 1489 1610 1490 - cpuhp_store_callbacks(state, name, startup, teardown, multi_instance); 1491 - 1492 - if (!invoke || !startup) 1611 + if (ret || !invoke || !startup) 1493 1612 goto out; 1494 1613 1495 1614 /* ··· 1504 1641 } 1505 1642 out: 1506 1643 put_online_cpus(); 1507 - if (!ret && dyn_state) 1644 + /* 1645 + * If the requested state is CPUHP_AP_ONLINE_DYN, return the 1646 + * dynamically allocated state in case of success. 1647 + */ 1648 + if (!ret && state == CPUHP_AP_ONLINE_DYN) 1508 1649 return state; 1509 1650 return ret; 1510 1651 }
-24
lib/Kconfig.debug
··· 1538 1538 1539 1539 Say N if unsure. 1540 1540 1541 - config CPU_NOTIFIER_ERROR_INJECT 1542 - tristate "CPU notifier error injection module" 1543 - depends on HOTPLUG_CPU && NOTIFIER_ERROR_INJECTION 1544 - help 1545 - This option provides a kernel module that can be used to test 1546 - the error handling of the cpu notifiers by injecting artificial 1547 - errors to CPU notifier chain callbacks. It is controlled through 1548 - debugfs interface under /sys/kernel/debug/notifier-error-inject/cpu 1549 - 1550 - If the notifier call chain should be failed with some events 1551 - notified, write the error code to "actions/<notifier event>/error". 1552 - 1553 - Example: Inject CPU offline error (-1 == -EPERM) 1554 - 1555 - # cd /sys/kernel/debug/notifier-error-inject/cpu 1556 - # echo -1 > actions/CPU_DOWN_PREPARE/error 1557 - # echo 0 > /sys/devices/system/cpu/cpu1/online 1558 - bash: echo: write error: Operation not permitted 1559 - 1560 - To compile this code as a module, choose M here: the module will 1561 - be called cpu-notifier-error-inject. 1562 - 1563 - If unsure, say N. 1564 - 1565 1541 config PM_NOTIFIER_ERROR_INJECT 1566 1542 tristate "PM notifier error injection module" 1567 1543 depends on PM && NOTIFIER_ERROR_INJECTION
-1
lib/Makefile
··· 128 128 obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o iommu-common.o 129 129 obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o 130 130 obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o 131 - obj-$(CONFIG_CPU_NOTIFIER_ERROR_INJECT) += cpu-notifier-error-inject.o 132 131 obj-$(CONFIG_PM_NOTIFIER_ERROR_INJECT) += pm-notifier-error-inject.o 133 132 obj-$(CONFIG_NETDEV_NOTIFIER_ERROR_INJECT) += netdev-notifier-error-inject.o 134 133 obj-$(CONFIG_MEMORY_NOTIFIER_ERROR_INJECT) += memory-notifier-error-inject.o
-84
lib/cpu-notifier-error-inject.c
··· 1 - #include <linux/kernel.h> 2 - #include <linux/module.h> 3 - #include <linux/cpu.h> 4 - 5 - #include "notifier-error-inject.h" 6 - 7 - static int priority; 8 - module_param(priority, int, 0); 9 - MODULE_PARM_DESC(priority, "specify cpu notifier priority"); 10 - 11 - #define UP_PREPARE 0 12 - #define UP_PREPARE_FROZEN 0 13 - #define DOWN_PREPARE 0 14 - #define DOWN_PREPARE_FROZEN 0 15 - 16 - static struct notifier_err_inject cpu_notifier_err_inject = { 17 - .actions = { 18 - { NOTIFIER_ERR_INJECT_ACTION(UP_PREPARE) }, 19 - { NOTIFIER_ERR_INJECT_ACTION(UP_PREPARE_FROZEN) }, 20 - { NOTIFIER_ERR_INJECT_ACTION(DOWN_PREPARE) }, 21 - { NOTIFIER_ERR_INJECT_ACTION(DOWN_PREPARE_FROZEN) }, 22 - {} 23 - } 24 - }; 25 - 26 - static int notf_err_handle(struct notifier_err_inject_action *action) 27 - { 28 - int ret; 29 - 30 - ret = action->error; 31 - if (ret) 32 - pr_info("Injecting error (%d) to %s\n", ret, action->name); 33 - return ret; 34 - } 35 - 36 - static int notf_err_inj_up_prepare(unsigned int cpu) 37 - { 38 - if (!cpuhp_tasks_frozen) 39 - return notf_err_handle(&cpu_notifier_err_inject.actions[0]); 40 - else 41 - return notf_err_handle(&cpu_notifier_err_inject.actions[1]); 42 - } 43 - 44 - static int notf_err_inj_dead(unsigned int cpu) 45 - { 46 - if (!cpuhp_tasks_frozen) 47 - return notf_err_handle(&cpu_notifier_err_inject.actions[2]); 48 - else 49 - return notf_err_handle(&cpu_notifier_err_inject.actions[3]); 50 - } 51 - 52 - static struct dentry *dir; 53 - 54 - static int err_inject_init(void) 55 - { 56 - int err; 57 - 58 - dir = notifier_err_inject_init("cpu", notifier_err_inject_dir, 59 - &cpu_notifier_err_inject, priority); 60 - if (IS_ERR(dir)) 61 - return PTR_ERR(dir); 62 - 63 - err = cpuhp_setup_state_nocalls(CPUHP_NOTF_ERR_INJ_PREPARE, 64 - "cpu-err-notif:prepare", 65 - notf_err_inj_up_prepare, 66 - notf_err_inj_dead); 67 - if (err) 68 - debugfs_remove_recursive(dir); 69 - 70 - return err; 71 - } 72 - 73 - static void err_inject_exit(void) 74 - { 75 - cpuhp_remove_state_nocalls(CPUHP_NOTF_ERR_INJ_PREPARE); 76 - debugfs_remove_recursive(dir); 77 - } 78 - 79 - module_init(err_inject_init); 80 - module_exit(err_inject_exit); 81 - 82 - MODULE_DESCRIPTION("CPU notifier error injection module"); 83 - MODULE_LICENSE("GPL"); 84 - MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>");
+1 -1
virt/kvm/arm/arch_timer.c
··· 456 456 kvm_info("virtual timer IRQ%d\n", host_vtimer_irq); 457 457 458 458 cpuhp_setup_state(CPUHP_AP_KVM_ARM_TIMER_STARTING, 459 - "AP_KVM_ARM_TIMER_STARTING", kvm_timer_starting_cpu, 459 + "kvm/arm/timer:starting", kvm_timer_starting_cpu, 460 460 kvm_timer_dying_cpu); 461 461 return err; 462 462 }
+1 -1
virt/kvm/arm/vgic/vgic-init.c
··· 428 428 } 429 429 430 430 ret = cpuhp_setup_state(CPUHP_AP_KVM_ARM_VGIC_INIT_STARTING, 431 - "AP_KVM_ARM_VGIC_INIT_STARTING", 431 + "kvm/arm/vgic:starting", 432 432 vgic_init_cpu_starting, vgic_init_cpu_dying); 433 433 if (ret) { 434 434 kvm_err("Cannot register vgic CPU notifier\n");
+1 -1
virt/kvm/kvm_main.c
··· 3944 3944 goto out_free_1; 3945 3945 } 3946 3946 3947 - r = cpuhp_setup_state_nocalls(CPUHP_AP_KVM_STARTING, "AP_KVM_STARTING", 3947 + r = cpuhp_setup_state_nocalls(CPUHP_AP_KVM_STARTING, "kvm/cpu:starting", 3948 3948 kvm_starting_cpu, kvm_dying_cpu); 3949 3949 if (r) 3950 3950 goto out_free_2;