【问题标题】:What is the significance of PIDS_PER_CPU_DEFAULT?PIDS_PER_CPU_DEFAULT 的意义是什么?
【发布时间】:2014-03-30 10:14:38
【问题描述】:

PIDS_PER_CPU_DEFAULT 和定义 linux/threads.h 中定义的 PIDS_PER_CPU_MIN 有什么意义? 我知道 PID 的最大值可以增加到大约 400 万,默认值为 32768,但我无法将最大 pid 值关联到 PIDS_PER_CPU_DEFAULT。

【问题讨论】:

    标签: process linux-kernel kernel limit cpu


    【解决方案1】:

    cmets 给出了很好的解释:

    include/linux/threads.h

    /*
     * Define a minimum number of pids per cpu.  Heuristically based
     * on original pid max of 32k for 32 cpus.  Also, increase the
     * minimum settable value for pid_max on the running system based
     * on similar defaults.  See kernel/pid.c:pidmap_init() for details.
     */
    #define PIDS_PER_CPU_DEFAULT    1024
    #define PIDS_PER_CPU_MIN        8
    

    kernel/pid.c

    void __init pidmap_init(void)
    {
        /* Veryify no one has done anything silly */
        BUILD_BUG_ON(PID_MAX_LIMIT >= PIDNS_HASH_ADDING);
    
        /* bump default and minimum pid_max based on number of cpus */
        pid_max = min(pid_max_max, max_t(int, pid_max,
                                PIDS_PER_CPU_DEFAULT * num_possible_cpus()));
        pid_max_min = max_t(int, pid_max_min,
                                PIDS_PER_CPU_MIN * num_possible_cpus());
        pr_info("pid_max: default: %u minimum: %u\n", pid_max, pid_max_min);
        .
        .
    

    在初始化时,他们正在调整"default and minimum pid_max based on number of cpus"

    您希望在系统中运行的最大 pid 数取决于可用 CPU 的数量。 (我假设两个 CPU 理论上可以运行两倍于一个 CPU 的并发进程,而效率是相同的。)由于 CPU 的数量可能会随着引导而改变,pid_max 在内核初始化时进行调整。

    【讨论】:

    • @乔纳森。这是我所理解的摘要。系统中最大可能的 PID 约为 400 万,但默认值为 32768。但根据系统中 CPU 的数量,此值 (32768) 会重新配置。例如对于单 CPU 系统,PID 的默认值为 32768,每个 CPU 允许的默认 PID 为 1024,每个 CPU 允许的 MIN PID 为 8。
    猜你喜欢
    • 2013-03-31
    • 1970-01-01
    • 2011-08-19
    • 2010-09-08
    • 2011-07-28
    • 2011-06-13
    • 1970-01-01
    • 1970-01-01
    • 2018-04-11
    相关资源
    最近更新 更多