OFFLINE OFFLINE | ^ v | BRINGUP_CPU->AP_OFFLINE BRINGUP_CPU <- AP_IDLE_DEAD (idle thread/play_dead) | AP_OFFLINE v (IRQ-off) ,---------------^ AP_ONLNE | (stop_machine) | TEARDOWN_CPU <- AP_ONLINE_IDLE | ^ v | AP_ACTIVE AP_ACTIVE

cpu_down

                cpu_down()
                do_cpu_down
            cpu_down_maps_locked(cpu, offline)
                _cpu_down ##set target offline ,cpuhp_hp_states cb will use
                 onlinecpus=1 or !present cpu--> return ##only one cpu or not setup cpu will return
                cpus_write_lock---percpu_down_write                                                             smpboot_register_percpu_thread
                    |                                                                                                       |
                cpuhp_tasks_frozen = tasks_frozen = 0                                   ------------------------------------
                    |                                                                   |
                st->state > CPUHP_TEARDOWN_CPU                                          |
                    |                                                                   |
                cpuhp_kick_ap_work  ## target CPUHP_TEARDOWN_CPU                        |
                    |------------                                                       |
                    |            |                                                      |
                    |        __cpuhp_kick_ap                                            |
                    |            |                                                      |
                    |       wake_up_process ----------------------------------------->st->thread
                    |            |                                                       |
                    |            |                                                    cpuhp_thread_fun
                    |            |                                                       |
                    |       wait_for_ap_thread  DONE                                cpuhp_invoke_callback
                    |                                                                    |
                 cpuhp_down_callbacks  ##target offline                               cb(cpu)
                    |                                                                    |
                cpuhp_invoke_callback  ##CPUHP_TEARDOWN_CPU -> CPUHP_OFFLINE   cpuhp_hp_states.teardown----------> CPUHP_ONLINE---->CPUHP_TEARDOWN_CPU
        ------------|                 \ ----------------------------                      |
        |                                                           \                       -------------- \   
        |                ##CPUHP_TEARDOWN_CPU -> CPUHP_OFFLINE       |                      |         sched_cpu_deactivat
cpus_write_unlock   ------------------------------------------------ takedown_cpu           |         rcutree_offline_cpue
        |           |           (takedown_cpu function)-------------/                       |         workqueue_offline_cpu
    cleanup         |           |                                                           |         lockup_detector_offline_cpu
        |           |    kthread_park  ##ark the smpboot threads                            |         perf_event_exit_cpu
    arch smt update |           |                                                           |         smpboot_park_threads
        |           |   stop_machine_cpuslocked(take_cpu_down)                              |           DONE                                          
    DONE            |           |                   |                                       --------------- /   
                    |           |                   |                                                                       
                    |           |               __cpu_disable---------------------------|----------\
            timers_dead_cpu     |                   |                                   |      platform_cpu_disable------#check(support hotplug and tos is run on this cpu)
                |               |           cpuhp_invoke_callback -------------\        |      set_cpu_online(cpu, false);              
            rcutree_dead_cpu    |                   |                           |       |               |
                |               |          tick_handover_do_timer               |       |      irq_migrate_all_off_this_cpu
            slab_dead_cpu       |                   |                           |       |               |
                |               |           stop_machine_park                   |       |      flush_cache_louis
            relay_prepare_cpu   |                   |                           |       |      local_flush_tlb_all
                |               |                   DONE                        |       |----------/ DONE
            smpcfd_dead_cpu     |                                               |
                |               |                                               ------------|--\####CPUHP_TEARDOWN_CPU -> CPUHP_AP_OFFLINE
            hrtimers_dead_cpu   |                                                           |       smpcfd_dying_cpu
                |               |                                                           |         rcutree_dying_cpu
            perf_event_exit_cpu |                                                           |           sched_cpu_dying
                |               |                                                           |--------------/DONE
                DONE            |                       
                            wait_for_ap_thread
                            hotplug_cpu__broadcast_tick_pull
                            __cpu_die------wait_for_completion_timeout  <----------------------------------------- idle thread
                            tick_cleanup_dead_cpu
                            rcutree_migrate_callbacks
echo mem > /sys/power/state
Suspend                     Resume
    |                           |
    call notifiers              Turn On Power
    |                           |
echo 0 > /sys/devices/system/cpu/cpuX/online
具体的code flow如下:
int device_add(struct device *dev)->device_create_file
而dev_attr_onlline 就是按照下面的方式定义的
static ssize_t online_
2.6内核上一个新的特性就是per-CPU变量。顾名思义,就是每个处理器上有此变量的一个副本。
per-CPU的最大优点就是,对它的访问几乎不需要锁,因为每个CPU都在自己的副本上工作。
tasklet、timer_list等机制都使用了per-CPU技术。
当创建一个per-cpu变量时,系统中的每一个处理器都会拥有该变量的独
				
Chinese translated version of Documentation/percpu-rw-semaphore.txt If you have any comment or update to the content, please contact the original document maintainer directly.  However, if you hav
1. 前言 在SMP(Symmetric Multi-Processing)流行起来之前的很长一段时间,Linux kernel的电源管理工作主要集中在外部设备上,和CPU core相关的,顶多就是CPU idle。但随着SMP的普及,一个系统中可用的CPU core越来越多,这些core的频率越来越高,处理能力越来越强,功耗也越来越大。因此,CPU core有关的电源管理,在系统设计中
本文系本站原创,欢迎转载! 转载请注明出处:http://ericxiao.cublog.cn/ ------------------------------------------ 一: 前言 本文主要是对trace的框架做详尽的分析, 在后续的分析中,再来分析接入到框架中的几个重要的trac
1. 前言 由“Linux CPU core的电源管理(1)_概述”的描述可知,kernel cpu control位于“.\kernel\cpu.c”中,是一个承上启下的模块,负责屏蔽arch-dependent的实现细节,向上层软件提供控制CPU core的统一API(主要包括cpu_up/cpu_down等接口的实现)。本文将基于这些API,从上到下,分析CPU core从启动到关
1. 前言 Linux内核提供了三种Suspend: Freeze、Standby和STR(Suspend to RAM),在用户空间向”/sys/power/state”文件分别写入”freeze”、”standby”和”mem”,即可触发它们。 内核中,Suspend及Resume过程涉及到PM Core、Device PM、各个设备的驱动、Platform dependent PM
谢谢分享。 请教下CPU_down时,被关闭的CPU上的running queue上的任务迁移发生在哪里(或者说非hotplug CPU需要任务迁移吗)? hotplug CPU在如下回调中可以做rq上task的migration。但是非hotplugCPU的任务migration发生在哪里?CPU die的具体操作发生在当前CPU的idle线程中,如果rq中还有别的task,idle线程也没有机会执行啊。谢谢解答。 [CPUHP_AP_SCHED_STARTING] = { .name = "sched:starting", .startup.single = sched_cpu_starting, .teardown.single = sched_cpu_dying, [Linux][K]IRQ代码阅读记录 盼盼编程: 写的不错,感谢分享 [ARM]AArch64异常 代码改变世界ctw: good! 我上面举得例子不对,EL3要是为32位,那么EL0/EL1/EL2就都必需位32位了。所以一般EL3都是用64的 以下是摘自官方文档(和您说的一致): When the processor moves from a higher to a lower Exception level, the Execution state can stay the same, or it can switch from AArch64 to AArch32. When moving from a lower to a higher Exception level, the Execution state can stay the same or switch from AArch32 to AArch64 [ARM]AArch64异常 Big2chris: 主要是对于EL0/EL1来说,如EL0(android)EL1(kernel), 64位的kernel可以运行32/64位的android, 32位的kernel只能跑32位的android