docs/zh_CN: core-api: Update the partial translation to 5.19-rc3
Subsystems (2)
v2 cover docs/zh_CN: core-api: Update the partial translation to 5.19-rc3
In this series of patches, I updated the translated file contents in the core-api directory to 5.19-rc3.
The next step, I plan to translate the untranslated documents in the core-api directory. For details, please see TODOLIST in the core-api/index.rst file.
Changes since V1:
- Update the code base to 5.19-rc3
- According to the suggestions of Xiangcheng and Yanteng, the translations of corresponding documents are updated to make them more readable.
The modified documents are as follows:
cpu_hotplug.rst
irq/irq-domain.rst
printk-format.rst
If you like, please review the mailing list for details.
In addition, for the translation of the Rust part in "printk-format.rst", I will reorganize it into a patch to the Rust tree.
Binbin Zhou (9):
docs/zh_CN: core-api: Update the translation of cachetlb.rst to
5.19-rc3
docs/zh_CN: core-api: Update the translation of cpu_hotplug.rst to
5.19-rc3
docs/zh_CN: core-api: Update the translation of irq/irq-domain.rst to
5.19-rc3
docs/zh_CN: core-api: Update the translation of kernel-api.rst to
5.19-rc3
docs/zh_CN: core-api: Update the translation of mm-api.rst to 5.19-rc3
docs/zh_CN: core-api: Update the translation of printk-basics.rst to
5.19-rc3
docs/zh_CN: core-api: Update the translation of printk-format.rst to
5.19-rc3
docs/zh_CN: core-api: Update the translation of workqueue.rst to
5.19-rc3 docs/zh_CN: core-api: Update the translation of xarray.rst to 5.19-rc3
.../translations/zh_CN/core-api/cachetlb.rst | 6 + .../zh_CN/core-api/cpu_hotplug.rst | 435 +++++++++++++++--- .../zh_CN/core-api/irq/irq-domain.rst | 22 +- .../zh_CN/core-api/kernel-api.rst | 3 + .../translations/zh_CN/core-api/mm-api.rst | 23 +- .../zh_CN/core-api/printk-basics.rst | 3 +- .../zh_CN/core-api/printk-formats.rst | 3 +- .../translations/zh_CN/core-api/workqueue.rst | 21 +- .../translations/zh_CN/core-api/xarray.rst | 4 +- 9 files changed, 449 insertions(+), 71 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/9 docs/zh_CN: core-api: Update the translation of cachetlb.rst to 5.19-rc3
Synchronous translation from upstream commit 08b0b0059bf1 ("mm: Add flush_dcache_folio()")
--- Documentation/translations/zh_CN/core-api/cachetlb.rst | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/translations/zh_CN/core-api/cachetlb.rst +6 -0
@@ -5,6 +5,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> :校译:
@@ -278,6 +279,11 @@ HyperSparc cpu就是这样一个具有这种属性的cpu。 CPU上,因为它将cpu存储到页面上,使其变脏。同样,请看 sparc64关于如何处理这个问题的例子。 + ``void flush_dcache_folio(struct folio *folio)`` + + 该函数的调用情形与flush_dcache_page()相同。它允许架构针对刷新整个 + folio页面进行优化,而不是一次刷新一页。 + ``void copy_to_user_page(struct vm_area_struct *vma, struct page *page, unsigned long user_vaddr, void *dst, void *src, int len)`` ``void copy_from_user_page(struct vm_area_struct *vma, struct page *page,
Signature · 1 line
2.20.1
Re: [PATCH 1/9] docs/zh_CN: core-api: Update the translation of cachetlb.rst to 5.19-rc3
Quoted 4 lines · Binbin Zhou
Synchronous translation from upstream commit
08b0b0059bf1("mm: Addflush_dcache_folio()")Signed-off-by Binbin Zhou <[email protected]>
Quoted 8 lines
--- Documentation/translations/zh_CN/core-api/cachetlb.rst | 6 ++++++ 1 file changed, 6 insertions(+)Documentation/translations/zh_CN/core-api/cachetlb.rst +0
-0
YanTeng Si
Reviewed-byRe: [PATCH 1/9] docs/zh_CN: core-api: Update the translation of cachetlb.rst to 5.19-rc3
Quoted 6 lines · Wu XiangCheng
Quoted 4 lines · Binbin Zhou
Synchronous translation from upstream commit
08b0b0059bf1("mm: Addflush_dcache_folio()")Signed-off-by Binbin Zhou <[email protected]>Reviewed-by Wu XiangCheng <[email protected]>
Quoted 9 lines
Quoted 9 lines
--- Documentation/translations/zh_CN/core-api/cachetlb.rst | 6 ++++++ 1 file changed, 6 insertions(+)Documentation/translations/zh_CN/core-api/cachetlb.rst +0
-0
PATCH v2 2/9 docs/zh_CN: core-api: Update the translation of cpu_hotplug.rst to 5.19-rc3
In reply to Binbin ZhouSynchronous translation from upstream commit c9871c800f65 ("Documentation: core-api/cpuhotplug: Rewrite the API section")
--- .../zh_CN/core-api/cpu_hotplug.rst | 435 +++++++++++++++--- 1 file changed, 377 insertions(+), 58 deletions(-)
Documentation/translations/zh_CN/core-api/cpu_hotplug.rst +377 -58
@@ -4,6 +4,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> :校译:
@@ -15,12 +16,13 @@ 内核中的CPU热拔插 ================= -:时间: 2016年12月 +:时间: 2021年9月 :作者: Sebastian Andrzej Siewior <[email protected]>, - Rusty Russell <[email protected]>, - Srivatsa Vaddagiri <[email protected]>, - Ashok Raj <[email protected]>, - Joel Schopp <[email protected]> + Rusty Russell <[email protected]>, + Srivatsa Vaddagiri <[email protected]>, + Ashok Raj <[email protected]>, + Joel Schopp <[email protected]>, + Thomas Gleixner <[email protected]> 简介 ====
@@ -139,7 +141,7 @@ CPU的热拔插协作 下线情况 -------- -一旦CPU被逻辑关闭,注册的热插拔状态的清除回调将被调用,从 ``CPUHP_ONLINE`` 开始,在 +一旦CPU被逻辑关闭,注册的热插拔状态的清除回调将被调用,从 ``CPUHP_ONLINE`` 开始,到 ``CPUHP_OFFLINE`` 状态结束。这包括: * 如果任务因暂停操作而被冻结,那么 *cpuhp_tasks_frozen* 将被设置为true。
@@ -154,82 +156,399 @@ CPU的热拔插协作 * 一旦所有的服务被迁移,内核会调用一个特定的例程 ``__cpu_disable()`` 来进行特定的清 理。 -使用热插拔API -------------- +CPU热插拔API +============ + +CPU热拔插状态机 +--------------- + +CPU热插拔使用一个从CPUHP_OFFLINE到CPUHP_ONLINE的线性状态空间的普通状态机。每个状态都 +有一个startup和teardown的回调。 + +当一个CPU上线时,将按顺序调用startup回调,直到达到CPUHP_ONLINE状态。当设置状态的回调 +或将实例添加到多实例状态时,也可以调用它们。 + +当一个CPU下线时,将按相反的顺序依次调用teardown回调,直到达到CPUHP_OFFLINE状态。当删 +除状态的回调或从多实例状态中删除实例时,也可以调用它们。 + +如果某个使用场景只需要一个方向的热插拔操作回调(CPU上线或CPU下线),则在设置状态时, +可以将另一个不需要的回调设置为NULL。 + +状态空间被划分成三个阶段: + +* PREPARE阶段 + + PREPARE阶段涵盖了从CPUHP_OFFLINE到CPUHP_BRINGUP_CPU之间的状态空间。 + + 在该阶段中,startup回调在CPU上线操作启动CPU之前被调用,teardown回调在CPU下线操作使 + CPU功能失效之后被调用。 + + 这些回调是在控制CPU上调用的,因为它们显然不能在热插拔的CPU上运行,此时热插拔的CPU要 + 么还没有启动,要么已经功能失效。 + + startup回调用于设置CPU成功上线所需要的资源。teardown回调用于释放资源或在热插拔的CPU + 功能失效后,将待处理的工作转移到在线的CPU上。 + + 允许startup回调失败。如果回调失败,CPU上线操作被中止,CPU将再次被降到之前的状态(通 + 常是CPUHP_OFFLINE)。 + + 本阶段中的teardown回调不允许失败。 + +* STARTING阶段 + + STARTING阶段涵盖了CPUHP_BRINGUP_CPU + 1到CPUHP_AP_ONLINE之间的状态空间。 + + 该阶段中的startup回调是在早期CPU设置代码中的CPU上线操作期间,禁用中断的情况下在热拔 + 插的CPU上被调用。teardown回调是在CPU完全关闭前不久的CPU下线操作期间,禁用中断的情况 + 下在热拔插的CPU上被调用。 + + 该阶段中的回调不允许失败。 + + 回调用于低级别的硬件初始化/关机和核心子系统。 + +* ONLINE阶段 + + ONLINE阶段涵盖了CPUHP_AP_ONLINE + 1到CPUHP_ONLINE之间的状态空间。 + + 该阶段中的startup回调是在CPU上线时在热插拔的CPU上调用的。teardown回调是在CPU下线操 + 作时在热插拔CPU上调用的。 + + 回调是在每个CPU热插拔线程的上下文中调用的,该线程绑定在热插拔的CPU上。回调是在启用 + 中断和抢占的情况下调用的。 + + 允许回调失败。如果回调失败,CPU热插拔操作被中止,CPU将恢复到之前的状态。 + +CPU 上线/下线操作 +----------------- + +一个成功的上线操作如下:: + + [CPUHP_OFFLINE] + [CPUHP_OFFLINE + 1]->startup() -> 成功 + [CPUHP_OFFLINE + 2]->startup() -> 成功 + [CPUHP_OFFLINE + 3] -> 略过,因为startup == NULL + ... + [CPUHP_BRINGUP_CPU]->startup() -> 成功 + === PREPARE阶段结束 + [CPUHP_BRINGUP_CPU + 1]->startup() -> 成功 + ... + [CPUHP_AP_ONLINE]->startup() -> 成功 + === STARTUP阶段结束 + [CPUHP_AP_ONLINE + 1]->startup() -> 成功 + ... + [CPUHP_ONLINE - 1]->startup() -> 成功 + [CPUHP_ONLINE] + +一个成功的下线操作如下:: + + [CPUHP_ONLINE] + [CPUHP_ONLINE - 1]->teardown() -> 成功 + ... + [CPUHP_AP_ONLINE + 1]->teardown() -> 成功 + === STARTUP阶段开始 + [CPUHP_AP_ONLINE]->teardown() -> 成功 + ... + [CPUHP_BRINGUP_ONLINE - 1]->teardown() + ... + === PREPARE阶段开始 + [CPUHP_BRINGUP_CPU]->teardown() + [CPUHP_OFFLINE + 3]->teardown() + [CPUHP_OFFLINE + 2] -> 略过,因为teardown == NULL + [CPUHP_OFFLINE + 1]->teardown() + [CPUHP_OFFLINE] + +一个失败的上线操作如下:: + + [CPUHP_OFFLINE] + [CPUHP_OFFLINE + 1]->startup() -> 成功 + [CPUHP_OFFLINE + 2]->startup() -> 成功 + [CPUHP_OFFLINE + 3] -> 略过,因为startup == NULL + ... + [CPUHP_BRINGUP_CPU]->startup() -> 成功 + === PREPARE阶段结束 + [CPUHP_BRINGUP_CPU + 1]->startup() -> 成功 + ... + [CPUHP_AP_ONLINE]->startup() -> 成功 + === STARTUP阶段结束 + [CPUHP_AP_ONLINE + 1]->startup() -> 成功 + --- + [CPUHP_AP_ONLINE + N]->startup() -> 失败 + [CPUHP_AP_ONLINE + (N - 1)]->teardown() + ... + [CPUHP_AP_ONLINE + 1]->teardown() + === STARTUP阶段开始 + [CPUHP_AP_ONLINE]->teardown() + ... + [CPUHP_BRINGUP_ONLINE - 1]->teardown() + ... + === PREPARE阶段开始 + [CPUHP_BRINGUP_CPU]->teardown() + [CPUHP_OFFLINE + 3]->teardown() + [CPUHP_OFFLINE + 2] -> 略过,因为teardown == NULL + [CPUHP_OFFLINE + 1]->teardown() + [CPUHP_OFFLINE] + +一个失败的下线操作如下:: + + [CPUHP_ONLINE] + [CPUHP_ONLINE - 1]->teardown() -> 成功 + ... + [CPUHP_ONLINE - N]->teardown() -> 失败 + [CPUHP_ONLINE - (N - 1)]->startup() + ... + [CPUHP_ONLINE - 1]->startup() + [CPUHP_ONLINE] + +递归失败不能被合理地处理。 +请看下面的例子,由于下线操作失败而导致的递归失败:: + + [CPUHP_ONLINE] + [CPUHP_ONLINE - 1]->teardown() -> 成功 + ... + [CPUHP_ONLINE - N]->teardown() -> 失败 + [CPUHP_ONLINE - (N - 1)]->startup() -> 成功 + [CPUHP_ONLINE - (N - 2)]->startup() -> 失败 + +CPU热插拔状态机在此停止,且不再尝试回滚,因为这可能会导致死循环:: + + [CPUHP_ONLINE - (N - 1)]->teardown() -> 成功 + [CPUHP_ONLINE - N]->teardown() -> 失败 + [CPUHP_ONLINE - (N - 1)]->startup() -> 成功 + [CPUHP_ONLINE - (N - 2)]->startup() -> 失败 + [CPUHP_ONLINE - (N - 1)]->teardown() -> 成功 + [CPUHP_ONLINE - N]->teardown() -> 失败 + +周而复始,不断重复。在这种情况下,CPU留在该状态中:: + + [CPUHP_ONLINE - (N - 1)] + +这至少可以让系统取得进展,让用户有机会进行调试,甚至解决这个问题。 + +分配一个状态 +------------ + +有两种方式分配一个CPU热插拔状态: + +* 静态分配 + + 当子系统或驱动程序有相对于其他CPU热插拔状态的排序要求时,必须使用静态分配。例如, + 在CPU上线操作期间,PERF核心startup回调必须在PERF驱动startup回调之前被调用。在CPU + 下线操作中,驱动teardown回调必须在核心teardown回调之前调用。静态分配的状态由 + cpuhp_state枚举中的常量描述,可以在include/linux/cpuhotplug.h中找到。 + + 在适当的位置将状态插入枚举中,这样就满足了排序要求。状态常量必须被用于状态的设置 + 和移除。 + + 当状态回调不是在运行时设置的,并且是kernel/cpu.c中CPU热插拔状态数组初始化的一部分 + 时,也需要静态分配。 + +* 动态分配 + + 当对状态回调没有排序要求时,动态分配是首选方法。状态编号由setup函数分配,并在成功 + 后返回给调用者。 + + 只有PREPARE和ONLINE阶段提供了一个动态分配范围。STARTING阶段则没有,因为该部分的大多 + 数回调都有明确的排序要求。 + +CPU热插拔状态的设置 +------------------- + +核心代码提供了以下函数用来设置状态: + +* cpuhp_setup_state(state, name, startup, teardown) +* cpuhp_setup_state_nocalls(state, name, startup, teardown) +* cpuhp_setup_state_cpuslocked(state, name, startup, teardown) +* cpuhp_setup_state_nocalls_cpuslocked(state, name, startup, teardown) + +对于一个驱动程序或子系统有多个实例,并且每个实例都需要调用相同的CPU hotplug状态回 +调的情况,CPU hotplug核心提供多实例支持。与驱动程序特定的实例列表相比,其优势在于 +与实例相关的函数完全针对CPU hotplug操作进行序列化,并在添加和删除时提供状态回调的 +自动调用。要设置这样一个多实例状态,可以使用以下函数: + +* cpuhp_setup_state_multi(state, name, startup, teardown) + +@state参数要么是静态分配的状态,要么是动态分配状态(PUHP_PREPARE_DYN,CPUHP_ONLINE_DYN) +的常量之一, 具体取决于应该分配动态状态的状态阶段(PREPARE,ONLINE)。 + +@name参数用于sysfs输出和检测。命名惯例是"subsys:mode"或"subsys/driver:mode", +例如 "perf:mode"或"perf/x86:mode"。常见的mode名称有: + +======== ============================================ +prepare 对应PREPARE阶段中的状态 + +dead 对应PREPARE阶段中不提供startup回调的状态 + +starting 对应STARTING阶段中的状态 + +dying 对应STARTING阶段中不提供startup回调的状态 + +online 对应ONLINE阶段中的状态 + +offline 对应ONLINE阶段中不提供startup回调的状态 +======== ============================================ + +由于@name参数只用于sysfs和检测,如果其他mode描述符比常见的描述符更好地描述状态的性质, +也可以使用。 + +@name参数的示例:"perf/online", "perf/x86:prepare", "RCU/tree:dying", "sched/waitempty" + +@startup参数是一个指向回调的函数指针,在CPU上线操作时被调用。若应用不需要startup +回调,则将该指针设为NULL。 + +@teardown参数是一个指向回调的函数指针,在CPU下线操作时调用。若应用不需要teardown +回调,则将该指针设为NULL。 + +这些函数在处理已注册回调的方式上有所不同: + + * cpuhp_setup_state_nocalls(), cpuhp_setup_state_nocalls_cpuslocked()和 + cpuhp_setup_state_multi()只注册回调。 + + * cpuhp_setup_state()和cpuhp_setup_state_cpuslocked()注册回调,并对当前状态大于新 + 安装状态的所有在线CPU调用@startup回调(如果不是NULL)。根据状态阶段,回调要么在 + 当前的CPU上调用(PREPARE阶段),要么在CPU的热插拔线程中调用每个在线CPU(ONLINE阶段)。 + + 如果CPU N的回调失败,那么CPU 0...N-1的teardown回调被调用以回滚操作。状态设置失败, + 状态的回调没有被注册,在动态分配的情况下,分配的状态被释放。 + +状态设置和回调调用是针对CPU热拔插操作进行序列化的。如果设置函数必须从CPU热插拔的读 +锁定区域调用,那么必须使用_cpuslocked()变体。这些函数不能在CPU热拔插回调中使用。 + +函数返回值: + ======== ========================================================== + 0 静态分配的状态设置成功 + + >0 动态分配的状态设置成功 + + 返回的数值是被分配的状态编号。如果状态回调后来必须被移除, + 例如模块移除,那么这个数值必须由调用者保存,并作为状态移 + 除函数的@state参数。对于多实例状态,动态分配的状态编号也 + 需要作为实例添加/删除操作的@state参数。 + + <0 操作失败 + ======== ========================================================== + +移除CPU热拔插状态 +----------------- + +为了移除一个之前设置好的状态,提供了如下函数: + +* cpuhp_remove_state(state) +* cpuhp_remove_state_nocalls(state) +* cpuhp_remove_state_nocalls_cpuslocked(state) +* cpuhp_remove_multi_state(state) + +@state参数要么是静态分配的状态,要么是由cpuhp_setup_state*()在动态范围内分配 +的状态编号。如果状态在动态范围内,则状态编号被释放,可再次进行动态分配。 + +这些函数在处理已注册回调的方式上有所不同: + + * cpuhp_remove_state_nocalls(), cpuhp_remove_state_nocalls_cpuslocked() + 和 cpuhp_remove_multi_state()只删除回调。 + + * cpuhp_remove_state()删除回调,并调用所有当前状态大于被删除状态的在线CPU的 + teardown回调(如果不是NULL)。根据状态阶段,回调要么在当前的CPU上调用 + (PREPARE阶段),要么在CPU的热插拔线程中调用每个在线CPU(ONLINE阶段)。 + + 为了完成移除工作,teardown回调不能失败。 + +状态移除和回调调用是针对CPU热拔插操作进行序列化的。如果移除函数必须从CPU hotplug +读取锁定区域调用,那么必须使用_cpuslocked()变体。这些函数不能从CPU热插拔的回调中使用。 + +如果一个多实例的状态被移除,那么调用者必须先移除所有的实例。 + +多实例状态实例管理 +------------------ + +一旦多实例状态被建立,实例就可以被添加到状态中: -一旦一个CPU下线或上线,就有可能收到通知。这对某些需要根据可用CPU数量执行某种设置或清 -理功能的驱动程序来说可能很重要:: + * cpuhp_state_add_instance(state, node) + * cpuhp_state_add_instance_nocalls(state, node) - #include <linux/cpuhotplug.h> +@state参数是一个静态分配的状态或由cpuhp_setup_state_multi()在动态范围内分配的状 +态编号。 - ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "X/Y:online", - Y_online, Y_prepare_down); +@node参数是一个指向hlist_node的指针,它被嵌入到实例的数据结构中。这个指针被交给 +多实例状态的回调,可以被回调用来通过container_of()检索到实例。 -*X* 是子系统, *Y* 是特定的驱动程序。 *Y_online* 回调将在所有在线CPU的注册过程中被调用。 -如果在线回调期间发生错误, *Y_prepare_down* 回调将在所有之前调用过在线回调的CPU上调 -用。注册完成后,一旦有CPU上线, *Y_online* 回调将被调用,当CPU关闭时, *Y_prepare_down* -将被调用。所有之前在 *Y_online* 中分配的资源都应该在 *Y_prepare_down* 中释放。如果在 -注册过程中发生错误,返回值 *ret* 为负值。否则会返回一个正值,其中包含动态分配状态 -( *CPUHP_AP_ONLINE_DYN* )的分配热拔插。对于预定义的状态,它将返回0。 +这些函数在处理已注册回调的方式上有所不同: -该回调可以通过调用 ``cpuhp_remove_state()`` 来删除。如果是动态分配的状态 -( *CPUHP_AP_ONLINE_DYN* ),则使用返回的状态。在移除热插拔状态的过程中,将调用拆解回调。 + * cpuhp_state_add_instance_nocalls()只将实例添加到多实例状态的节点列表中。 -多个实例 -~~~~~~~~ + * cpuhp_state_add_instance()为所有当前状态大于@state的在线CPU添加实例并调用与 + @state相关的startup回调(如果不是NULL)。该回调只对将要添加的实例进行调用。 + 根据状态阶段,回调要么在当前的CPU上调用(PREPARE阶段),要么在CPU的热插拔线 + 程中调用每个在线CPU(ONLINE阶段)。 -如果一个驱动程序有多个实例,并且每个实例都需要独立执行回调,那么很可能应该使用 -``multi-state`` 。首先需要注册一个多状态的状态:: + 如果CPU N的回调失败,那么CPU 0 ... N-1的teardown回调被调用以回滚操作,该函数 + 失败,实例不会被添加到多实例状态的节点列表中。 - ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, "X/Y:online, - Y_online, Y_prepare_down); - Y_hp_online = ret; +要从状态的节点列表中删除一个实例,可以使用这些函数: -``cpuhp_setup_state_multi()`` 的行为与 ``cpuhp_setup_state()`` 类似,只是它 -为多状态准备了回调,但不调用回调。这是一个一次性的设置。 -一旦分配了一个新的实例,你需要注册这个新实例:: + * cpuhp_state_remove_instance(state, node) + * cpuhp_state_remove_instance_nocalls(state, node) - ret = cpuhp_state_add_instance(Y_hp_online, &d->node); +参数与上述cpuhp_state_add_instance*()变体相同。 -这个函数将把这个实例添加到你先前分配的 ``Y_hp_online`` 状态,并在所有在线的 -CPU上调用先前注册的回调( ``Y_online`` )。 *node* 元素是你的每个实例数据结构 -中的一个 ``struct hlist_node`` 成员。 +这些函数在处理已注册回调的方式上有所不同: -在移除该实例时:: + * cpuhp_state_remove_instance_nocalls()只从状态的节点列表中删除实例。 - cpuhp_state_remove_instance(Y_hp_online, &d->node) + * cpuhp_state_remove_instance()删除实例并调用与@state相关的回调(如果不是NULL), + 用于所有当前状态大于@state的在线CPU。 该回调只对将要被移除的实例进行调用。 + 根据状态阶段,回调要么在当前的CPU上调用(PREPARE阶段),要么在CPU的热插拔 + 线程中调用每个在线CPU(ONLINE阶段)。 -应该被调用,这将在所有在线CPU上调用拆分回调。 + 为了完成移除工作,teardown回调不能失败。 -手动设置 -~~~~~~~~ +节点列表的添加/删除操作和回调调用是针对CPU热拔插操作进行序列化。这些函数不能在 +CPU hotplug回调和CPU hotplug读取锁定区域内使用。 -通常情况下,在注册或移除状态时调用setup和teamdown回调是很方便的,因为通常在CPU上线 -(下线)和驱动的初始设置(关闭)时需要执行该操作。然而,每个注册和删除功能也有一个 -_nocalls的后缀,如果不希望调用回调,则不调用所提供的回调。在手动设置(或关闭)期间, -应该使用 ``get_online_cpus()`` 和 ``put_online_cpus()`` 函数来抑制CPU热插拔操作。 +样例 +---- +在STARTING阶段设置和取消静态分配的状态,以获取上线和下线操作的通知:: -事件的顺序 ----------- + ret = cpuhp_setup_state(CPUHP_SUBSYS_STARTING, "subsys:starting", subsys_cpu_starting, subsys_cpu_dying); + if (ret < 0) + return ret; + .... + cpuhp_remove_state(CPUHP_SUBSYS_STARTING); -热插拔状态被定义在 ``include/linux/cpuhotplug.h``: +在ONLINE阶段设置和取消动态分配的状态,以获取下线操作的通知:: -* ``CPUHP_OFFLINE`` ... ``CPUHP_AP_OFFLINE`` 状态是在CPU启动前调用的。 + state = cpuhp_setup_state(CPUHP_ONLINE_DYN, "subsys:offline", NULL, subsys_cpu_offline); + if (state < 0) + return state; + .... + cpuhp_remove_state(state); -* ``CPUHP_AP_OFFLINE`` ... ``CPUHP_AP_ONLINE`` 状态是在CPU被启动后被调用的。 - 中断是关闭的,调度程序还没有在这个CPU上活动。从 ``CPUHP_AP_OFFLINE`` 开始, - 回调被调用到目标CPU上。 +在ONLINE阶段设置和取消动态分配的状态,以获取有关上线操作的通知,而无需调用回调:: -* ``CPUHP_AP_ONLINE_DYN`` 和 ``CPUHP_AP_ONLINE_DYN_END`` 之间的状态被保留 - 给动态分配。 + state = cpuhp_setup_state_nocalls(CPUHP_ONLINE_DYN, "subsys:online", subsys_cpu_online, NULL); + if (state < 0) + return state; + .... + cpuhp_remove_state_nocalls(state); -* 这些状态在CPU关闭时以相反的顺序调用,从 ``CPUHP_ONLINE`` 开始,在 ``CPUHP_OFFLINE`` - 停止。这里的回调是在将被关闭的CPU上调用的,直到 ``CPUHP_AP_OFFLINE`` 。 +在ONLINE阶段设置、使用和取消动态分配的多实例状态,以获得上线和下线操作的通知:: -通过 ``CPUHP_AP_ONLINE_DYN`` 动态分配的状态通常已经足够了。然而,如果在启动或关闭 -期间需要更早的调用,那么应该获得一个显式状态。如果热拔插事件需要相对于另一个热拔插事 -件的特定排序,也可能需要一个显式状态。 + state = cpuhp_setup_state_multi(CPUHP_ONLINE_DYN, "subsys:online", subsys_cpu_online, subsys_cpu_offline); + if (state < 0) + return state; + .... + ret = cpuhp_state_add_instance(state, &inst1->node); + if (ret) + return ret; + .... + ret = cpuhp_state_add_instance(state, &inst2->node); + if (ret) + return ret; + .... + cpuhp_remove_instance(state, &inst1->node); + .... + cpuhp_remove_instance(state, &inst2->node); + .... + remove_multi_state(state); 测试热拔插状态 ==============
Signature · 1 line
2.20.1
Re: [PATCH 2/9] docs/zh_CN: core-api: Update the translation of cpu_hotplug.rst to 5.19-rc3
Quoted 4 lines · Binbin Zhou
Synchronous translation from upstream commit
c9871c800f65("Documentation: core-api/cpuhotplug: Rewrite the API section")Signed-off-by Binbin Zhou <[email protected]>
Quoted 8 lines
--- .../zh_CN/core-api/cpu_hotplug.rst | 435 +++++++++++++++--- 1 file changed, 377 insertions(+), 58 deletions(-)Documentation/translations/zh_CN/core-api/cpu_hotplug.rst +0
-0
Re: [PATCH 2/9] docs/zh_CN: core-api: Update the translation of cpu_hotplug.rst to 5.19-rc3
In reply to Binbin ZhouQuoted 4 lines · Binbin Zhou
Synchronous translation from upstream commit
c9871c800f65("Documentation: core-api/cpuhotplug: Rewrite the API section")Signed-off-by Binbin Zhou <[email protected]>
Thanks,
Yanteng
Quoted 496 lines
--- .../zh_CN/core-api/cpu_hotplug.rst | 435 +++++++++++++++--- 1 file changed, 377 insertions(+), 58 deletions(-)Documentation/translations/zh_CN/core-api/cpu_hotplug.rst +377
-58@@ -4,6 +4,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> :校译:@@ -15,12 +16,13 @@ 内核中的CPU热拔插 ================= -:时间: 2016年12月 +:时间: 2021年9月 :作者: Sebastian Andrzej Siewior <[email protected]>, - Rusty Russell <[email protected]>, - Srivatsa Vaddagiri <[email protected]>, - Ashok Raj <[email protected]>, - Joel Schopp <[email protected]> + Rusty Russell <[email protected]>, + Srivatsa Vaddagiri <[email protected]>, + Ashok Raj <[email protected]>, + Joel Schopp <[email protected]>, + Thomas Gleixner <[email protected]> 简介 ====@@ -139,7 +141,7 @@ CPU的热拔插协作 下线情况 -------- -一旦CPU被逻辑关闭,注册的热插拔状态的清除回调将被调用,从 ``CPUHP_ONLINE`` 开始,在 +一旦CPU被逻辑关闭,注册的热插拔状态的清除回调将被调用,从 ``CPUHP_ONLINE`` 开始,到 ``CPUHP_OFFLINE`` 状态结束。这包括: * 如果任务因暂停操作而被冻结,那么 *cpuhp_tasks_frozen* 将被设置为true。@@ -154,82 +156,399 @@ CPU的热拔插协作 * 一旦所有的服务被迁移,内核会调用一个特定的例程 ``__cpu_disable()`` 来进行特定的清 理。 -使用热插拔API -------------- +CPU热插拔API +============ + +CPU热拔插状态机 +--------------- + +CPU热插拔使用一个从CPUHP_OFFLINE到CPUHP_ONLINE的线性状态空间的普通状态机。每个状态都 +有一个startup和teardown的回调。 + +当一个CPU上线时,将按顺序调用startup回调,直到达到CPUHP_ONLINE状态。当设置状态的回调 +或将实例添加到多实例状态时,也可以调用它们。 + +当一个CPU下线时,将按相反的顺序依次调用teardown回调,直到达到CPUHP_OFFLINE状态。当删 +除状态的回调或从多实例状态中删除实例时,也可以调用它们。 + +如果某个使用场景只需要一个方向的热插拔操作回调(CPU上线或CPU下线),则在设置状态时, +可以将另一个不需要的回调设置为NULL。 + +状态空间被划分成三个阶段: + +* PREPARE阶段 + + PREPARE阶段涵盖了从CPUHP_OFFLINE到CPUHP_BRINGUP_CPU之间的状态空间。 + + 在该阶段中,startup回调在CPU上线操作启动CPU之前被调用,teardown回调在CPU下线操作使 + CPU功能失效之后被调用。 + + 这些回调是在控制CPU上调用的,因为它们显然不能在热插拔的CPU上运行,此时热插拔的CPU要 + 么还没有启动,要么已经功能失效。 + + startup回调用于设置CPU成功上线所需要的资源。teardown回调用于释放资源或在热插拔的CPU + 功能失效后,将待处理的工作转移到在线的CPU上。 + + 允许startup回调失败。如果回调失败,CPU上线操作被中止,CPU将再次被降到之前的状态(通 + 常是CPUHP_OFFLINE)。 + + 本阶段中的teardown回调不允许失败。 + +* STARTING阶段 + + STARTING阶段涵盖了CPUHP_BRINGUP_CPU + 1到CPUHP_AP_ONLINE之间的状态空间。 + + 该阶段中的startup回调是在早期CPU设置代码中的CPU上线操作期间,禁用中断的情况下在热拔 + 插的CPU上被调用。teardown回调是在CPU完全关闭前不久的CPU下线操作期间,禁用中断的情况 + 下在热拔插的CPU上被调用。 + + 该阶段中的回调不允许失败。 + + 回调用于低级别的硬件初始化/关机和核心子系统。 + +* ONLINE阶段 + + ONLINE阶段涵盖了CPUHP_AP_ONLINE + 1到CPUHP_ONLINE之间的状态空间。 + + 该阶段中的startup回调是在CPU上线时在热插拔的CPU上调用的。teardown回调是在CPU下线操 + 作时在热插拔CPU上调用的。 + + 回调是在每个CPU热插拔线程的上下文中调用的,该线程绑定在热插拔的CPU上。回调是在启用 + 中断和抢占的情况下调用的。 + + 允许回调失败。如果回调失败,CPU热插拔操作被中止,CPU将恢复到之前的状态。 + +CPU 上线/下线操作 +----------------- + +一个成功的上线操作如下:: + + [CPUHP_OFFLINE] + [CPUHP_OFFLINE + 1]->startup() -> 成功 + [CPUHP_OFFLINE + 2]->startup() -> 成功 + [CPUHP_OFFLINE + 3] -> 略过,因为startup == NULL + ... + [CPUHP_BRINGUP_CPU]->startup() -> 成功 + === PREPARE阶段结束 + [CPUHP_BRINGUP_CPU + 1]->startup() -> 成功 + ... + [CPUHP_AP_ONLINE]->startup() -> 成功 + === STARTUP阶段结束 + [CPUHP_AP_ONLINE + 1]->startup() -> 成功 + ... + [CPUHP_ONLINE - 1]->startup() -> 成功 + [CPUHP_ONLINE] + +一个成功的下线操作如下:: + + [CPUHP_ONLINE] + [CPUHP_ONLINE - 1]->teardown() -> 成功 + ... + [CPUHP_AP_ONLINE + 1]->teardown() -> 成功 + === STARTUP阶段开始 + [CPUHP_AP_ONLINE]->teardown() -> 成功 + ... + [CPUHP_BRINGUP_ONLINE - 1]->teardown() + ... + === PREPARE阶段开始 + [CPUHP_BRINGUP_CPU]->teardown() + [CPUHP_OFFLINE + 3]->teardown() + [CPUHP_OFFLINE + 2] -> 略过,因为teardown == NULL + [CPUHP_OFFLINE + 1]->teardown() + [CPUHP_OFFLINE] + +一个失败的上线操作如下:: + + [CPUHP_OFFLINE] + [CPUHP_OFFLINE + 1]->startup() -> 成功 + [CPUHP_OFFLINE + 2]->startup() -> 成功 + [CPUHP_OFFLINE + 3] -> 略过,因为startup == NULL + ... + [CPUHP_BRINGUP_CPU]->startup() -> 成功 + === PREPARE阶段结束 + [CPUHP_BRINGUP_CPU + 1]->startup() -> 成功 + ... + [CPUHP_AP_ONLINE]->startup() -> 成功 + === STARTUP阶段结束 + [CPUHP_AP_ONLINE + 1]->startup() -> 成功 + --- + [CPUHP_AP_ONLINE + N]->startup() -> 失败 + [CPUHP_AP_ONLINE + (N - 1)]->teardown() + ... + [CPUHP_AP_ONLINE + 1]->teardown() + === STARTUP阶段开始 + [CPUHP_AP_ONLINE]->teardown() + ... + [CPUHP_BRINGUP_ONLINE - 1]->teardown() + ... + === PREPARE阶段开始 + [CPUHP_BRINGUP_CPU]->teardown() + [CPUHP_OFFLINE + 3]->teardown() + [CPUHP_OFFLINE + 2] -> 略过,因为teardown == NULL + [CPUHP_OFFLINE + 1]->teardown() + [CPUHP_OFFLINE] + +一个失败的下线操作如下:: + + [CPUHP_ONLINE] + [CPUHP_ONLINE - 1]->teardown() -> 成功 + ... + [CPUHP_ONLINE - N]->teardown() -> 失败 + [CPUHP_ONLINE - (N - 1)]->startup() + ... + [CPUHP_ONLINE - 1]->startup() + [CPUHP_ONLINE] + +递归失败不能被合理地处理。 +请看下面的例子,由于下线操作失败而导致的递归失败:: + + [CPUHP_ONLINE] + [CPUHP_ONLINE - 1]->teardown() -> 成功 + ... + [CPUHP_ONLINE - N]->teardown() -> 失败 + [CPUHP_ONLINE - (N - 1)]->startup() -> 成功 + [CPUHP_ONLINE - (N - 2)]->startup() -> 失败 + +CPU热插拔状态机在此停止,且不再尝试回滚,因为这可能会导致死循环:: + + [CPUHP_ONLINE - (N - 1)]->teardown() -> 成功 + [CPUHP_ONLINE - N]->teardown() -> 失败 + [CPUHP_ONLINE - (N - 1)]->startup() -> 成功 + [CPUHP_ONLINE - (N - 2)]->startup() -> 失败 + [CPUHP_ONLINE - (N - 1)]->teardown() -> 成功 + [CPUHP_ONLINE - N]->teardown() -> 失败 + +周而复始,不断重复。在这种情况下,CPU留在该状态中:: + + [CPUHP_ONLINE - (N - 1)] + +这至少可以让系统取得进展,让用户有机会进行调试,甚至解决这个问题。 + +分配一个状态 +------------ + +有两种方式分配一个CPU热插拔状态: + +* 静态分配 + + 当子系统或驱动程序有相对于其他CPU热插拔状态的排序要求时,必须使用静态分配。例如, + 在CPU上线操作期间,PERF核心startup回调必须在PERF驱动startup回调之前被调用。在CPU + 下线操作中,驱动teardown回调必须在核心teardown回调之前调用。静态分配的状态由 + cpuhp_state枚举中的常量描述,可以在include/linux/cpuhotplug.h中找到。 + + 在适当的位置将状态插入枚举中,这样就满足了排序要求。状态常量必须被用于状态的设置 + 和移除。 + + 当状态回调不是在运行时设置的,并且是kernel/cpu.c中CPU热插拔状态数组初始化的一部分 + 时,也需要静态分配。 + +* 动态分配 + + 当对状态回调没有排序要求时,动态分配是首选方法。状态编号由setup函数分配,并在成功 + 后返回给调用者。 + + 只有PREPARE和ONLINE阶段提供了一个动态分配范围。STARTING阶段则没有,因为该部分的大多 + 数回调都有明确的排序要求。 + +CPU热插拔状态的设置 +------------------- + +核心代码提供了以下函数用来设置状态: + +* cpuhp_setup_state(state, name, startup, teardown) +* cpuhp_setup_state_nocalls(state, name, startup, teardown) +* cpuhp_setup_state_cpuslocked(state, name, startup, teardown) +* cpuhp_setup_state_nocalls_cpuslocked(state, name, startup, teardown) + +对于一个驱动程序或子系统有多个实例,并且每个实例都需要调用相同的CPU hotplug状态回 +调的情况,CPU hotplug核心提供多实例支持。与驱动程序特定的实例列表相比,其优势在于 +与实例相关的函数完全针对CPU hotplug操作进行序列化,并在添加和删除时提供状态回调的 +自动调用。要设置这样一个多实例状态,可以使用以下函数: + +* cpuhp_setup_state_multi(state, name, startup, teardown) + +@state参数要么是静态分配的状态,要么是动态分配状态(PUHP_PREPARE_DYN,CPUHP_ONLINE_DYN) +的常量之一, 具体取决于应该分配动态状态的状态阶段(PREPARE,ONLINE)。 + +@name参数用于sysfs输出和检测。命名惯例是"subsys:mode"或"subsys/driver:mode", +例如 "perf:mode"或"perf/x86:mode"。常见的mode名称有: + +======== ============================================ +prepare 对应PREPARE阶段中的状态 + +dead 对应PREPARE阶段中不提供startup回调的状态 + +starting 对应STARTING阶段中的状态 + +dying 对应STARTING阶段中不提供startup回调的状态 + +online 对应ONLINE阶段中的状态 + +offline 对应ONLINE阶段中不提供startup回调的状态 +======== ============================================ + +由于@name参数只用于sysfs和检测,如果其他mode描述符比常见的描述符更好地描述状态的性质, +也可以使用。 + +@name参数的示例:"perf/online", "perf/x86:prepare", "RCU/tree:dying", "sched/waitempty" + +@startup参数是一个指向回调的函数指针,在CPU上线操作时被调用。若应用不需要startup +回调,则将该指针设为NULL。 + +@teardown参数是一个指向回调的函数指针,在CPU下线操作时调用。若应用不需要teardown +回调,则将该指针设为NULL。 + +这些函数在处理已注册回调的方式上有所不同: + + * cpuhp_setup_state_nocalls(), cpuhp_setup_state_nocalls_cpuslocked()和 + cpuhp_setup_state_multi()只注册回调。 + + * cpuhp_setup_state()和cpuhp_setup_state_cpuslocked()注册回调,并对当前状态大于新 + 安装状态的所有在线CPU调用@startup回调(如果不是NULL)。根据状态阶段,回调要么在 + 当前的CPU上调用(PREPARE阶段),要么在CPU的热插拔线程中调用每个在线CPU(ONLINE阶段)。 + + 如果CPU N的回调失败,那么CPU 0...N-1的teardown回调被调用以回滚操作。状态设置失败, + 状态的回调没有被注册,在动态分配的情况下,分配的状态被释放。 + +状态设置和回调调用是针对CPU热拔插操作进行序列化的。如果设置函数必须从CPU热插拔的读 +锁定区域调用,那么必须使用_cpuslocked()变体。这些函数不能在CPU热拔插回调中使用。 + +函数返回值: + ======== ========================================================== + 0 静态分配的状态设置成功 + + >0 动态分配的状态设置成功 + + 返回的数值是被分配的状态编号。如果状态回调后来必须被移除, + 例如模块移除,那么这个数值必须由调用者保存,并作为状态移 + 除函数的@state参数。对于多实例状态,动态分配的状态编号也 + 需要作为实例添加/删除操作的@state参数。 + + <0 操作失败 + ======== ========================================================== + +移除CPU热拔插状态 +----------------- + +为了移除一个之前设置好的状态,提供了如下函数: + +* cpuhp_remove_state(state) +* cpuhp_remove_state_nocalls(state) +* cpuhp_remove_state_nocalls_cpuslocked(state) +* cpuhp_remove_multi_state(state) + +@state参数要么是静态分配的状态,要么是由cpuhp_setup_state*()在动态范围内分配 +的状态编号。如果状态在动态范围内,则状态编号被释放,可再次进行动态分配。 + +这些函数在处理已注册回调的方式上有所不同: + + * cpuhp_remove_state_nocalls(), cpuhp_remove_state_nocalls_cpuslocked() + 和 cpuhp_remove_multi_state()只删除回调。 + + * cpuhp_remove_state()删除回调,并调用所有当前状态大于被删除状态的在线CPU的 + teardown回调(如果不是NULL)。根据状态阶段,回调要么在当前的CPU上调用 + (PREPARE阶段),要么在CPU的热插拔线程中调用每个在线CPU(ONLINE阶段)。 + + 为了完成移除工作,teardown回调不能失败。 + +状态移除和回调调用是针对CPU热拔插操作进行序列化的。如果移除函数必须从CPU hotplug +读取锁定区域调用,那么必须使用_cpuslocked()变体。这些函数不能从CPU热插拔的回调中使用。 + +如果一个多实例的状态被移除,那么调用者必须先移除所有的实例。 + +多实例状态实例管理 +------------------ + +一旦多实例状态被建立,实例就可以被添加到状态中: -一旦一个CPU下线或上线,就有可能收到通知。这对某些需要根据可用CPU数量执行某种设置或清 -理功能的驱动程序来说可能很重要:: + * cpuhp_state_add_instance(state, node) + * cpuhp_state_add_instance_nocalls(state, node) - #include <linux/cpuhotplug.h> +@state参数是一个静态分配的状态或由cpuhp_setup_state_multi()在动态范围内分配的状 +态编号。 - ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "X/Y:online", - Y_online, Y_prepare_down); +@node参数是一个指向hlist_node的指针,它被嵌入到实例的数据结构中。这个指针被交给 +多实例状态的回调,可以被回调用来通过container_of()检索到实例。 -*X* 是子系统, *Y* 是特定的驱动程序。 *Y_online* 回调将在所有在线CPU的注册过程中被调用。 -如果在线回调期间发生错误, *Y_prepare_down* 回调将在所有之前调用过在线回调的CPU上调 -用。注册完成后,一旦有CPU上线, *Y_online* 回调将被调用,当CPU关闭时, *Y_prepare_down* -将被调用。所有之前在 *Y_online* 中分配的资源都应该在 *Y_prepare_down* 中释放。如果在 -注册过程中发生错误,返回值 *ret* 为负值。否则会返回一个正值,其中包含动态分配状态 -( *CPUHP_AP_ONLINE_DYN* )的分配热拔插。对于预定义的状态,它将返回0。 +这些函数在处理已注册回调的方式上有所不同: -该回调可以通过调用 ``cpuhp_remove_state()`` 来删除。如果是动态分配的状态 -( *CPUHP_AP_ONLINE_DYN* ),则使用返回的状态。在移除热插拔状态的过程中,将调用拆解回调。 + * cpuhp_state_add_instance_nocalls()只将实例添加到多实例状态的节点列表中。 -多个实例 -~~~~~~~~ + * cpuhp_state_add_instance()为所有当前状态大于@state的在线CPU添加实例并调用与 + @state相关的startup回调(如果不是NULL)。该回调只对将要添加的实例进行调用。 + 根据状态阶段,回调要么在当前的CPU上调用(PREPARE阶段),要么在CPU的热插拔线 + 程中调用每个在线CPU(ONLINE阶段)。 -如果一个驱动程序有多个实例,并且每个实例都需要独立执行回调,那么很可能应该使用 -``multi-state`` 。首先需要注册一个多状态的状态:: + 如果CPU N的回调失败,那么CPU 0 ... N-1的teardown回调被调用以回滚操作,该函数 + 失败,实例不会被添加到多实例状态的节点列表中。 - ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, "X/Y:online, - Y_online, Y_prepare_down); - Y_hp_online = ret; +要从状态的节点列表中删除一个实例,可以使用这些函数: -``cpuhp_setup_state_multi()`` 的行为与 ``cpuhp_setup_state()`` 类似,只是它 -为多状态准备了回调,但不调用回调。这是一个一次性的设置。 -一旦分配了一个新的实例,你需要注册这个新实例:: + * cpuhp_state_remove_instance(state, node) + * cpuhp_state_remove_instance_nocalls(state, node) - ret = cpuhp_state_add_instance(Y_hp_online, &d->node); +参数与上述cpuhp_state_add_instance*()变体相同。 -这个函数将把这个实例添加到你先前分配的 ``Y_hp_online`` 状态,并在所有在线的 -CPU上调用先前注册的回调( ``Y_online`` )。 *node* 元素是你的每个实例数据结构 -中的一个 ``struct hlist_node`` 成员。 +这些函数在处理已注册回调的方式上有所不同: -在移除该实例时:: + * cpuhp_state_remove_instance_nocalls()只从状态的节点列表中删除实例。 - cpuhp_state_remove_instance(Y_hp_online, &d->node) + * cpuhp_state_remove_instance()删除实例并调用与@state相关的回调(如果不是NULL), + 用于所有当前状态大于@state的在线CPU。 该回调只对将要被移除的实例进行调用。 + 根据状态阶段,回调要么在当前的CPU上调用(PREPARE阶段),要么在CPU的热插拔 + 线程中调用每个在线CPU(ONLINE阶段)。 -应该被调用,这将在所有在线CPU上调用拆分回调。 + 为了完成移除工作,teardown回调不能失败。 -手动设置 -~~~~~~~~ +节点列表的添加/删除操作和回调调用是针对CPU热拔插操作进行序列化。这些函数不能在 +CPU hotplug回调和CPU hotplug读取锁定区域内使用。 -通常情况下,在注册或移除状态时调用setup和teamdown回调是很方便的,因为通常在CPU上线 -(下线)和驱动的初始设置(关闭)时需要执行该操作。然而,每个注册和删除功能也有一个 -_nocalls的后缀,如果不希望调用回调,则不调用所提供的回调。在手动设置(或关闭)期间, -应该使用 ``get_online_cpus()`` 和 ``put_online_cpus()`` 函数来抑制CPU热插拔操作。 +样例 +---- +在STARTING阶段设置和取消静态分配的状态,以获取上线和下线操作的通知:: -事件的顺序 ----------- + ret = cpuhp_setup_state(CPUHP_SUBSYS_STARTING, "subsys:starting", subsys_cpu_starting, subsys_cpu_dying); + if (ret < 0) + return ret; + .... + cpuhp_remove_state(CPUHP_SUBSYS_STARTING); -热插拔状态被定义在 ``include/linux/cpuhotplug.h``: +在ONLINE阶段设置和取消动态分配的状态,以获取下线操作的通知:: -* ``CPUHP_OFFLINE`` ... ``CPUHP_AP_OFFLINE`` 状态是在CPU启动前调用的。 + state = cpuhp_setup_state(CPUHP_ONLINE_DYN, "subsys:offline", NULL, subsys_cpu_offline); + if (state < 0) + return state; + .... + cpuhp_remove_state(state); -* ``CPUHP_AP_OFFLINE`` ... ``CPUHP_AP_ONLINE`` 状态是在CPU被启动后被调用的。 - 中断是关闭的,调度程序还没有在这个CPU上活动。从 ``CPUHP_AP_OFFLINE`` 开始, - 回调被调用到目标CPU上。 +在ONLINE阶段设置和取消动态分配的状态,以获取有关上线操作的通知,而无需调用回调:: -* ``CPUHP_AP_ONLINE_DYN`` 和 ``CPUHP_AP_ONLINE_DYN_END`` 之间的状态被保留 - 给动态分配。 + state = cpuhp_setup_state_nocalls(CPUHP_ONLINE_DYN, "subsys:online", subsys_cpu_online, NULL); + if (state < 0) + return state; + .... + cpuhp_remove_state_nocalls(state); -* 这些状态在CPU关闭时以相反的顺序调用,从 ``CPUHP_ONLINE`` 开始,在 ``CPUHP_OFFLINE`` - 停止。这里的回调是在将被关闭的CPU上调用的,直到 ``CPUHP_AP_OFFLINE`` 。 +在ONLINE阶段设置、使用和取消动态分配的多实例状态,以获得上线和下线操作的通知:: -通过 ``CPUHP_AP_ONLINE_DYN`` 动态分配的状态通常已经足够了。然而,如果在启动或关闭 -期间需要更早的调用,那么应该获得一个显式状态。如果热拔插事件需要相对于另一个热拔插事 -件的特定排序,也可能需要一个显式状态。 + state = cpuhp_setup_state_multi(CPUHP_ONLINE_DYN, "subsys:online", subsys_cpu_online, subsys_cpu_offline); + if (state < 0) + return state; + .... + ret = cpuhp_state_add_instance(state, &inst1->node); + if (ret) + return ret; + .... + ret = cpuhp_state_add_instance(state, &inst2->node); + if (ret) + return ret; + .... + cpuhp_remove_instance(state, &inst1->node); + .... + cpuhp_remove_instance(state, &inst2->node); + .... + remove_multi_state(state); 测试热拔插状态 ==============
PATCH v2 3/9 docs/zh_CN: core-api: Update the translation of irq/irq-domain.rst to 5.19-rc3
In reply to Binbin ZhouSynchronous translation from the following commits(Latest in front):
[1]: commit 0953fb263714("irq: remove handle_domain_{irq,nmi}()")
[2]: commit 0ddc5e55e6f1("Documentation: Fix irq-domain.rst build warning")
[3]: commit 991007ba6cca("Documentation: Update
irq_domain.rst with new lookup APIs")
[4]: commit 405e94e9aed2("irqdomain: Kill irq_domain_add_legacy_isa")
--- .../zh_CN/core-api/irq/irq-domain.rst | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
Documentation/translations/zh_CN/core-api/irq/irq-domain.rst +18 -4
@@ -5,6 +5,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> .. _cn_irq-domain.rst:
@@ -52,8 +53,18 @@ irq_domain和一个hwirq号作为参数。 如果hwirq的映射还不存在, 一个新的Linux irq_desc,将其与hwirq关联起来,并调用.map()回调,这样驱动 程序就可以执行任何必要的硬件设置。 -当接收到一个中断时,应该使用irq_find_mapping()函数从hwirq号中找到 -Linux IRQ号。 +一旦建立了映射,可以通过多种方法检索或使用它: + +- irq_resolve_mapping()返回一个指向给定域和hwirq号的irq_desc结构指针, + 如果没有映射则返回NULL。 + +- irq_find_mapping()返回给定域和hwirq的Linux IRQ号,如果没有映射则返回0。 + +- irq_linear_revmap()现与irq_find_mapping()相同,已被废弃。 + +- generic_handle_domain_irq()处理一个由域和hwirq号描述的中断。 + +请注意,irq域的查找必须发生在与RCU读临界区兼容的上下文中。 在调用irq_find_mapping()之前,至少要调用一次irq_create_mapping()函数, 以免描述符不能被分配。
@@ -119,7 +130,8 @@ irq_domain_add_tree()和irq_domain_create_tree()在功能上是等价的,除 Linux IRQ号编入硬件本身,这样就不需要映射了。 调用irq_create_direct_mapping() 会分配一个Linux IRQ号,并调用.map()回调,这样驱动就可以将Linux IRQ号编入硬件中。 -大多数驱动程序不能使用这个映射。 +大多数驱动程序无法使用此映射,现在它由CONFIG_IRQ_DOMAIN_NOMAP选项控制。 +请不要引入此API的新用户。 传统映射类型 ------------
@@ -128,7 +140,6 @@ Linux IRQ号编入硬件本身,这样就不需要映射了。 调用irq_create irq_domain_add_simple() irq_domain_add_legacy() - irq_domain_add_legacy_isa() irq_domain_create_simple() irq_domain_create_legacy()
@@ -137,6 +148,9 @@ Linux IRQ号编入硬件本身,这样就不需要映射了。 调用irq_create 一组用于IRQ号的定义(#define),这些定义被传递给struct设备注册。 在这种情况下, 不能动态分配Linux IRQ号,应该使用传统映射。 +顾名思义,\*_legacy()系列函数已被废弃,只是为了方便对古老平台的支持而存在。 +不应该增加新的用户。当\*_simple()系列函数的使用导致遗留行为时,他们也是如此。 + 传统映射假设已经为控制器分配了一个连续的IRQ号范围,并且可以通过向hwirq号添加一 个固定的偏移来计算IRQ号,反之亦然。 缺点是需要中断控制器管理IRQ分配,并且需要为每 个hwirq分配一个irq_desc,即使它没有被使用。
Signature · 1 line
2.20.1
Re: [PATCH 3/9] docs/zh_CN: core-api: Update the translation of irq/irq-domain.rst to 5.19-rc3
Quoted 4 lines · Binbin Zhou
Synchronous translation from the following commits(Latest in front):
[1]: commit 0953fb263714("irq: remove handle_domain_{irq,nmi}()")
Quoted 8 lines
[2]: commit 0ddc5e55e6f1("Documentation: Fix
irq-domain.rstbuild warning")[3]: commit 991007ba6cca("Documentation: Update
irq_domain.rstwith new lookup APIs")[4]: commit 405e94e9aed2("irqdomain: Kill
irq_domain_add_legacy_isa")Signed-off-by Binbin Zhou <[email protected]>
Quoted 8 lines
--- .../zh_CN/core-api/irq/irq-domain.rst | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)Documentation/translations/zh_CN/core-api/irq/irq-domain.rst +0
-0
Re: [PATCH 3/9] docs/zh_CN: core-api: Update the translation of irq/irq-domain.rst to 5.19-rc3
In reply to Binbin ZhouQuoted 4 lines · Binbin Zhou
Synchronous translation from the following commits(Latest in front):
[1]: commit 0953fb263714("irq: remove handle_domain_{irq,nmi}()")
Quoted 8 lines
[2]: commit 0ddc5e55e6f1("Documentation: Fix
irq-domain.rstbuild warning")[3]: commit 991007ba6cca("Documentation: Update
irq_domain.rstwith new lookup APIs")[4]: commit 405e94e9aed2("irqdomain: Kill
irq_domain_add_legacy_isa")Signed-off-by Binbin Zhou <[email protected]>
Thanks,
Yantneg
Quoted 65 lines
--- .../zh_CN/core-api/irq/irq-domain.rst | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)Documentation/translations/zh_CN/core-api/irq/irq-domain.rst +18
-4@@ -5,6 +5,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> .. _cn_irq-domain.rst:@@ -52,8 +53,18 @@ irq_domain和一个hwirq号作为参数。 如果hwirq的映射还不存在, 一个新的Linux irq_desc,将其与hwirq关联起来,并调用.map()回调,这样驱动 程序就可以执行任何必要的硬件设置。 -当接收到一个中断时,应该使用irq_find_mapping()函数从hwirq号中找到 -Linux IRQ号。 +一旦建立了映射,可以通过多种方法检索或使用它: + +- irq_resolve_mapping()返回一个指向给定域和hwirq号的irq_desc结构指针, + 如果没有映射则返回NULL。 + +- irq_find_mapping()返回给定域和hwirq的Linux IRQ号,如果没有映射则返回0。 + +- irq_linear_revmap()现与irq_find_mapping()相同,已被废弃。 + +- generic_handle_domain_irq()处理一个由域和hwirq号描述的中断。 + +请注意,irq域的查找必须发生在与RCU读临界区兼容的上下文中。 在调用irq_find_mapping()之前,至少要调用一次irq_create_mapping()函数, 以免描述符不能被分配。@@ -119,7 +130,8 @@ irq_domain_add_tree()和irq_domain_create_tree()在功能上是等价的,除 Linux IRQ号编入硬件本身,这样就不需要映射了。 调用irq_create_direct_mapping() 会分配一个Linux IRQ号,并调用.map()回调,这样驱动就可以将Linux IRQ号编入硬件中。 -大多数驱动程序不能使用这个映射。 +大多数驱动程序无法使用此映射,现在它由CONFIG_IRQ_DOMAIN_NOMAP选项控制。 +请不要引入此API的新用户。 传统映射类型 ------------@@ -128,7 +140,6 @@ Linux IRQ号编入硬件本身,这样就不需要映射了。 调用irq_create irq_domain_add_simple() irq_domain_add_legacy() - irq_domain_add_legacy_isa() irq_domain_create_simple() irq_domain_create_legacy()@@ -137,6 +148,9 @@ Linux IRQ号编入硬件本身,这样就不需要映射了。 调用irq_create 一组用于IRQ号的定义(#define),这些定义被传递给struct设备注册。 在这种情况下, 不能动态分配Linux IRQ号,应该使用传统映射。 +顾名思义,\*_legacy()系列函数已被废弃,只是为了方便对古老平台的支持而存在。 +不应该增加新的用户。当\*_simple()系列函数的使用导致遗留行为时,他们也是如此。 + 传统映射假设已经为控制器分配了一个连续的IRQ号范围,并且可以通过向hwirq号添加一 个固定的偏移来计算IRQ号,反之亦然。 缺点是需要中断控制器管理IRQ分配,并且需要为每 个hwirq分配一个irq_desc,即使它没有被使用。
PATCH v2 4/9 docs/zh_CN: core-api: Update the translation of kernel-api.rst to 5.19-rc3
In reply to Binbin ZhouSynchronous translation from upstream commit 640d1930bef4 ("block: Add bio_for_each_folio_all()")
--- Documentation/translations/zh_CN/core-api/kernel-api.rst | 3 +++ 1 file changed, 3 insertions(+)
Documentation/translations/zh_CN/core-api/kernel-api.rst +3 -0
@@ -5,6 +5,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> .. _cn_kernel-api.rst:
@@ -282,6 +283,8 @@ kernel/acct.c 该API在以下内核代码中: +include/linux/bio.h + block/blk-core.c block/blk-core.c
Signature · 1 line
2.20.1
Re: [PATCH 4/9] docs/zh_CN: core-api: Update the translation of kernel-api.rst to 5.19-rc3
Quoted 4 lines · Binbin Zhou
Synchronous translation from upstream commit
640d1930bef4("block: Addbio_for_each_folio_all()")Signed-off-by Binbin Zhou <[email protected]>
Quoted 25 lines
--- Documentation/translations/zh_CN/core-api/kernel-api.rst | 3 +++ 1 file changed, 3 insertions(+)Documentation/translations/zh_CN/core-api/kernel-api.rst +3
-0@@ -5,6 +5,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> .. _cn_kernel-api.rst:@@ -282,6 +283,8 @@ kernel/acct.c 该API在以下内核代码中: +include/linux/bio.h + block/blk-core.c block/blk-core.c
Re: [PATCH 4/9] docs/zh_CN: core-api: Update the translation of kernel-api.rst to 5.19-rc3
In reply to Binbin ZhouQuoted 4 lines · Binbin Zhou
Synchronous translation from upstream commit
640d1930bef4("block: Addbio_for_each_folio_all()")Signed-off-by Binbin Zhou <[email protected]>
Quoted 8 lines
--- Documentation/translations/zh_CN/core-api/kernel-api.rst | 3 +++ 1 file changed, 3 insertions(+)Documentation/translations/zh_CN/core-api/kernel-api.rst +0
-0
PATCH v2 5/9 docs/zh_CN: core-api: Update the translation of mm-api.rst to 5.19-rc3
In reply to Binbin ZhouSynchronous translation from the following commits(Latest in front):
[1]: commit 84dacdbd5352("mm: document and polish read-ahead code")
[2]: commit 2f52578f9c64("mm/util: Add folio_mapping() and
folio_file_mapping()")
[3]: commit 889a3747b3b7("mm/lru: Add folio LRU functions")
[4]: commit c24016ac3a62("mm: Add folio reference count functions")
--- .../translations/zh_CN/core-api/mm-api.rst | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/translations/zh_CN/core-api/mm-api.rst +22 -1
@@ -5,6 +5,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> :校译:
@@ -66,12 +67,24 @@ mm/vmalloc.c 该API在以下内核代码中: -mm/readahead.c +文件映射 +-------- mm/filemap.c +预读 +---- + +mm/readahead.c + +回写 +---- + mm/page-writeback.c +截断 +---- + mm/truncate.c include/linux/pagemap.h
@@ -105,6 +118,14 @@ mm/mempolicy.c include/linux/mm_types.h +include/linux/mm_inline.h + +include/linux/page-flags.h + include/linux/mm.h +include/linux/page_ref.h + include/linux/mmzone.h + +mm/util.c
Signature · 1 line
2.20.1
Re: [PATCH 5/9] docs/zh_CN: core-api: Update the translation of mm-api.rst to 5.19-rc3
Quoted 5 lines · Binbin Zhou
Synchronous translation from the following commits(Latest in front):
[1]: commit 84dacdbd5352("mm: document and polish read-ahead code")
[2]: commit 2f52578f9c64("mm/util: Add
folio_mapping()and
Quoted 8 lines
folio_file_mapping()")[3]: commit 889a3747b3b7("mm/lru: Add folio LRU functions")
[4]: commit
c24016ac3a62("mm: Add folio reference count functions")Signed-off-by Binbin Zhou <[email protected]>---
Quoted 7 lines
.../translations/zh_CN/core-api/mm-api.rst | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)Documentation/translations/zh_CN/core-api/mm-api.rst +0
-0
Re: [PATCH 5/9] docs/zh_CN: core-api: Update the translation of mm-api.rst to 5.19-rc3
In reply to Binbin ZhouQuoted 4 lines · Binbin Zhou
Synchronous translation from the following commits(Latest in front):
[1]: commit 84dacdbd5352("mm: document and polish read-ahead code")
Quoted 8 lines
[2]: commit 2f52578f9c64("mm/util: Add
folio_mapping()andfolio_file_mapping()")[3]: commit 889a3747b3b7("mm/lru: Add folio LRU functions")
[4]: commit
c24016ac3a62("mm: Add folio reference count functions")Signed-off-by Binbin Zhou <[email protected]>
Quoted 57 lines
--- .../translations/zh_CN/core-api/mm-api.rst | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)Documentation/translations/zh_CN/core-api/mm-api.rst +22
-1@@ -5,6 +5,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> :校译:@@ -66,12 +67,24 @@ mm/vmalloc.c 该API在以下内核代码中: -mm/readahead.c +文件映射 +-------- mm/filemap.c +预读 +---- + +mm/readahead.c + +回写 +---- + mm/page-writeback.c +截断 +---- + mm/truncate.c include/linux/pagemap.h@@ -105,6 +118,14 @@ mm/mempolicy.c include/linux/mm_types.h +include/linux/mm_inline.h + +include/linux/page-flags.h + include/linux/mm.h +include/linux/page_ref.h + include/linux/mmzone.h + +mm/util.c
PATCH v2 6/9 docs/zh_CN: core-api: Update the translation of printk-basics.rst to 5.19-rc3
In reply to Binbin ZhouSynchronous translation from upstream commit 7d9e2661f268 ("printk: Move the printk() kerneldoc comment to its new home")
--- Documentation/translations/zh_CN/core-api/printk-basics.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Documentation/translations/zh_CN/core-api/printk-basics.rst +1 -2
@@ -6,6 +6,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> .. _cn_printk-basics.rst:
@@ -107,6 +108,4 @@ pr_debug()和pr_devel(),除非定义了 ``DEBUG`` (或者在pr_debug()的情 该API在以下内核代码中: -kernel/printk/printk.c - include/linux/printk.h
Signature · 1 line
2.20.1
Re: [PATCH 6/9] docs/zh_CN: core-api: Update the translation of printk-basics.rst to 5.19-rc3
Quoted 4 lines · Binbin Zhou
Synchronous translation from upstream commit
7d9e2661f268("printk: Move theprintk()kerneldoc comment to its new home")Signed-off-by Binbin Zhou <[email protected]>
Quoted 8 lines
--- Documentation/translations/zh_CN/core-api/printk-basics.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Documentation/translations/zh_CN/core-api/printk-basics.rst +0
-0
Re: [PATCH 6/9] docs/zh_CN: core-api: Update the translation of printk-basics.rst to 5.19-rc3
In reply to Binbin ZhouQuoted 4 lines · Binbin Zhou
Synchronous translation from upstream commit
7d9e2661f268("printk: Move theprintk()kerneldoc comment to its new home")Signed-off-by Binbin Zhou <[email protected]>
Quoted 23 lines
--- Documentation/translations/zh_CN/core-api/printk-basics.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Documentation/translations/zh_CN/core-api/printk-basics.rst +1
-2@@ -6,6 +6,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> .. _cn_printk-basics.rst:@@ -107,6 +108,4 @@ pr_debug()和pr_devel(),除非定义了 ``DEBUG`` (或者在pr_debug()的情 该API在以下内核代码中: -kernel/printk/printk.c - include/linux/printk.h
PATCH v2 7/9 docs/zh_CN: core-api: Update the translation of printk-format.rst to 5.19-rc3
In reply to Binbin ZhouSynchronous translation from upstream commit 6a7ca80f4033 ("vsprintf: Update %pGp documentation about that it prints hex value")
--- Documentation/translations/zh_CN/core-api/printk-formats.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/translations/zh_CN/core-api/printk-formats.rst +2 -1
@@ -5,6 +5,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> .. _cn_printk-formats.rst:
@@ -548,7 +549,7 @@ nodemask_pr_args()来方便打印cpumask和nodemask。 :: - %pGp referenced|uptodate|lru|active|private|node=0|zone=2|lastcpupid=0x1fffff + %pGp 0x17ffffc0002036(referenced|uptodate|lru|active|private|node=0|zone=2|lastcpupid=0x1fffff) %pGg GFP_USER|GFP_DMA32|GFP_NOWARN %pGv read|exec|mayread|maywrite|mayexec|denywrite
Signature · 1 line
2.20.1
Re: [PATCH 7/9] docs/zh_CN: core-api: Update the translation of printk-format.rst to 5.19-rc3
Quoted 4 lines · Binbin Zhou
Synchronous translation from upstream commit
6a7ca80f4033("vsprintf: Update %pGp documentation about that it prints hex value")Signed-off-by Binbin Zhou <[email protected]>
Quoted 8 lines
--- Documentation/translations/zh_CN/core-api/printk-formats.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Documentation/translations/zh_CN/core-api/printk-formats.rst +0
-0
Re: [PATCH 7/9] docs/zh_CN: core-api: Update the translation of printk-format.rst to 5.19-rc3
In reply to Binbin ZhouQuoted 4 lines · Binbin Zhou
Synchronous translation from upstream commit
6a7ca80f4033("vsprintf: Update %pGp documentation about that it prints hex value")Signed-off-by Binbin Zhou <[email protected]>
Quoted 25 lines
--- Documentation/translations/zh_CN/core-api/printk-formats.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Documentation/translations/zh_CN/core-api/printk-formats.rst +2
-1@@ -5,6 +5,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> .. _cn_printk-formats.rst:@@ -548,7 +549,7 @@ nodemask_pr_args()来方便打印cpumask和nodemask。 :: - %pGp referenced|uptodate|lru|active|private|node=0|zone=2|lastcpupid=0x1fffff + %pGp 0x17ffffc0002036(referenced|uptodate|lru|active|private|node=0|zone=2|lastcpupid=0x1fffff) %pGg GFP_USER|GFP_DMA32|GFP_NOWARN %pGv read|exec|mayread|maywrite|mayexec|denywrite
PATCH v2 8/9 docs/zh_CN: core-api: Update the translation of workqueue.rst to 5.19-rc3
In reply to Binbin ZhouSynchronous translation from upstream commit f9eaaa82b474 ("workqueue: doc: Call out the non-reentrance conditions")
--- .../translations/zh_CN/core-api/workqueue.rst | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
Documentation/translations/zh_CN/core-api/workqueue.rst +17 -4
@@ -6,6 +6,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> .. _cn_workqueue.rst:
@@ -178,10 +179,6 @@ workqueue将自动创建与属性相匹配的后备工作者池。调节并发 这个标志对于未绑定的wq来说是没有意义的。 -请注意,标志 ``WQ_NON_REENTRANT`` 不再存在,因为现在所有的工作 -队列都是不可逆的——任何工作项都保证在任何时间内最多被整个系统的一 -个工作者执行。 - ``max_active`` --------------
@@ -328,6 +325,22 @@ And with cmwq with ``@max_active`` >= 3, :: 工作项函数在堆栈追踪中应该是微不足道的。 +不可重入条件 +============ + +工作队列保证,如果在工作项排队后满足以下条件,则工作项不能重入: + + + 1. 工作函数没有被改变。 + 2. 没有人将该工作项排到另一个工作队列中。 + 3. 该工作项尚未被重新启动。 + +换言之,如果上述条件成立,则保证在任何给定时间最多由一个系统范围内的工作程序执行 +该工作项。 + +请注意,在self函数中将工作项重新排队(到同一队列)不会破坏这些条件,因此可以安全 +地执行此操作。否则在破坏工作函数内部的条件时需要小心。 + 内核内联文档参考 ================
Signature · 1 line
2.20.1
Re: [PATCH 8/9] docs/zh_CN: core-api: Update the translation of workqueue.rst to 5.19-rc3
Quoted 4 lines · Binbin Zhou
Synchronous translation from upstream commit
f9eaaa82b474("workqueue: doc: Call out the non-reentrance conditions")Signed-off-by Binbin Zhou <[email protected]>
Quoted 50 lines
--- .../translations/zh_CN/core-api/workqueue.rst | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)Documentation/translations/zh_CN/core-api/workqueue.rst +17
-4@@ -6,6 +6,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> .. _cn_workqueue.rst:@@ -178,10 +179,6 @@ workqueue将自动创建与属性相匹配的后备工作者池。调节并发 这个标志对于未绑定的wq来说是没有意义的。 -请注意,标志 ``WQ_NON_REENTRANT`` 不再存在,因为现在所有的工作 -队列都是不可逆的——任何工作项都保证在任何时间内最多被整个系统的一 -个工作者执行。 - ``max_active`` --------------@@ -328,6 +325,22 @@ And with cmwq with ``@max_active`` >= 3, :: 工作项函数在堆栈追踪中应该是微不足道的。 +不可重入条件 +============ + +工作队列保证,如果在工作项排队后满足以下条件,则工作项不能重入: + + + 1. 工作函数没有被改变。 + 2. 没有人将该工作项排到另一个工作队列中。 + 3. 该工作项尚未被重新启动。 + +换言之,如果上述条件成立,则保证在任何给定时间最多由一个系统范围内的工作程序执行 +该工作项。 + +请注意,在self函数中将工作项重新排队(到同一队列)不会破坏这些条件,因此可以安全 +地执行此操作。否则在破坏工作函数内部的条件时需要小心。 + 内核内联文档参考 ================
Re: [PATCH 8/9] docs/zh_CN: core-api: Update the translation of workqueue.rst to 5.19-rc3
In reply to Binbin ZhouQuoted 4 lines · Binbin Zhou
Synchronous translation from upstream commit
f9eaaa82b474("workqueue: doc: Call out the non-reentrance conditions")Signed-off-by Binbin Zhou <[email protected]>
Quoted 8 lines
--- .../translations/zh_CN/core-api/workqueue.rst | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)Documentation/translations/zh_CN/core-api/workqueue.rst +0
-0
PATCH v2 9/9 docs/zh_CN: core-api: Update the translation of xarray.rst to 5.19-rc3
In reply to Binbin ZhouSynchronous translation from upstream commit ac23d1a96460 ("XArray: Document the locking requirement for the xa_state")
--- Documentation/translations/zh_CN/core-api/xarray.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/translations/zh_CN/core-api/xarray.rst +3 -1
@@ -6,6 +6,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> :校译:
@@ -254,7 +255,8 @@ __xa_set_mark() 和 __xa_clear_mark() 函数也适用于你查找一个条目并 高级API是基于xa_state的。这是一个不透明的数据结构,你使用XA_STATE()宏在堆栈中声明。这个宏初始化了 xa_state,准备开始在XArray上移动。它被用作一个游标来保持在XArray中的位置,并让你把各种操作组合在一 -起,而不必每次都从头开始。 +起,而不必每次都从头开始。xa_state的内容受rcu_read_lock()或xas_lock()的保护。如果需要删除保护状态 +和树的这些锁中的任何一个,你必须调用xas_pause()以便将来的调用不会依赖于状态中未受保护的部分。 xa_state也被用来存储错误(store errors)。你可以调用xas_error()来检索错误。所有的操作在进行之前都 会检查xa_state是否处于错误状态,所以你没有必要在每次调用之后检查错误;你可以连续进行多次调用,只在
Signature · 1 line
2.20.1
Re: [PATCH 9/9] docs/zh_CN: core-api: Update the translation of xarray.rst to 5.19-rc3
Quoted 4 lines · Binbin Zhou
Synchronous translation from upstream commit
ac23d1a96460("XArray: Document the locking requirement for thexa_state")Signed-off-by Binbin Zhou <[email protected]>
Quoted 26 lines
--- Documentation/translations/zh_CN/core-api/xarray.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Documentation/translations/zh_CN/core-api/xarray.rst +3
-1@@ -6,6 +6,7 @@ :翻译: 司延腾 Yanteng Si <[email protected]> + 周彬彬 Binbin Zhou <[email protected]> :校译:@@ -254,7 +255,8 @@ __xa_set_mark() 和 __xa_clear_mark() 函数也适用于你查找一个条目并 高级API是基于xa_state的。这是一个不透明的数据结构,你使用XA_STATE()宏在堆栈中声明。这个宏初始化了 xa_state,准备开始在XArray上移动。它被用作一个游标来保持在XArray中的位置,并让你把各种操作组合在一 -起,而不必每次都从头开始。 +起,而不必每次都从头开始。xa_state的内容受rcu_read_lock()或xas_lock()的保护。如果需要删除保护状态 +和树的这些锁中的任何一个,你必须调用xas_pause()以便将来的调用不会依赖于状态中未受保护的部分。 xa_state也被用来存储错误(store errors)。你可以调用xas_error()来检索错误。所有的操作在进行之前都 会检查xa_state是否处于错误状态,所以你没有必要在每次调用之后检查错误;你可以连续进行多次调用,只在
Re: [PATCH 9/9] docs/zh_CN: core-api: Update the translation of xarray.rst to 5.19-rc3
In reply to Binbin ZhouQuoted 4 lines · Binbin Zhou
Synchronous translation from upstream commit
ac23d1a96460("XArray: Document the locking requirement for thexa_state")Signed-off-by Binbin Zhou <[email protected]>
Thanks!
Wu
Quoted 8 lines
--- Documentation/translations/zh_CN/core-api/xarray.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Documentation/translations/zh_CN/core-api/xarray.rst +0
-0
Jonathan Corbet
maintainerQuoted 40 lines · Binbin Zhou
In this series of patches, I updated the translated file contents in the core-api directory to 5.19-rc3.
The next step, I plan to translate the untranslated documents in the core-api directory. For details, please see TODOLIST in the
core-api/index.rstfile.Changes since V1:
- Update the code base to 5.19-rc3- According to the suggestions of Xiangcheng and Yanteng, the translations of corresponding documents are updated to make them more readable.
The modified documents are as follows:
cpu_hotplug.rst
irq/irq-domain.rst
printk-format.rstIf you like, please review the mailing list for details.
In addition, for the translation of the Rust part in "
printk-format.rst", I will reorganize it into a patch to the Rust tree.Binbin Zhou (9):
docs/zh_CN: core-api: Update the translation ofcachetlb.rstto5.19-rc3 docs/zh_CN: core-api: Update the translation of cpu_hotplug.rst to 5.19-rc3 docs/zh_CN: core-api: Update the translation of irq/irq-domain.rst to 5.19-rc3 docs/zh_CN: core-api: Update the translation of kernel-api.rst to 5.19-rc3 docs/zh_CN: core-api: Update the translation of mm-api.rst to 5.19-rc3 docs/zh_CN: core-api: Update the translation of printk-basics.rst to 5.19-rc3 docs/zh_CN: core-api: Update the translation of printk-format.rst to 5.19-rc3 docs/zh_CN: core-api: Update the translation of workqueue.rst to 5.19-rc3docs/zh_CN: core-api: Update the translation of
xarray.rstto 5.19-rc3
Quoted 10 lines
.../translations/zh_CN/core-api/cachetlb.rst | 6 + .../zh_CN/core-api/cpu_hotplug.rst | 435 +++++++++++++++--- .../zh_CN/core-api/irq/irq-domain.rst | 22 +- .../zh_CN/core-api/kernel-api.rst | 3 + .../translations/zh_CN/core-api/mm-api.rst | 23 +- .../zh_CN/core-api/printk-basics.rst | 3 +- .../zh_CN/core-api/printk-formats.rst | 3 +- .../translations/zh_CN/core-api/workqueue.rst | 21 +- .../translations/zh_CN/core-api/xarray.rst | 4 +- 9 files changed, 449 insertions(+), 71 deletions(-)
Series applied, thanks.
jon