AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 779383
Accepted
tejus
tejus
Asked: 2016-05-28 01:58:20 +0800 CST2016-05-28 01:58:20 +0800 CST 2016-05-28 01:58:20 +0800 CST

如何防止使用特定的 CPU 内核?

  • 772

是否可以防止 CPU 内核被 Linux 中的操作系统使用?maxcpus=<n>引导参数可防止在操作系统中看到指定数量的内核。我希望所有内核都是可见的,但操作系统只使用一些内核来调度进程。

编辑:这是确保关键进程可以安排在一个核心上并且保持不是绝对重要但高度 CPU 密集型进程可以相互竞争其他核心所必需的。这是在 CentOS 6 上。

central-processing-unit scheduling
  • 3 3 个回答
  • 1394 Views

3 个回答

  • Voted
  1. Best Answer
    pdp
    2016-05-28T04:20:05+08:002016-05-28T04:20:05+08:00

    使用isolcpus内核命令行上的参数将某些内核与用户空间任务隔离。引用内核启动参数文档:

    isolcpus= [KNL,SMP] 将 CPU 与通用调度程序隔离开来。格式: ,..., 或 -(必须是升序的正数范围)或混合 ,...,-

               This option can be used to specify one or more CPUs
               to isolate from the general SMP balancing and scheduling
               algorithms. You can move a process onto or off an
               "isolated" CPU via the CPU affinity syscalls or cpuset.
               <cpu number> begins at 0 and the maximum value is
               "number of CPUs in system - 1".
    
               This option is the preferred way to isolate CPUs. The
               alternative -- manually setting the CPU mask of all
               tasks in the system -- can cause problems and
               suboptimal load balancer performance.
    
    • 3
  2. deagh
    2016-05-28T03:17:23+08:002016-05-28T03:17:23+08:00

    您可以禁用处理器,例如 (core0)echo 0 > /sys/devices/system/cpu/cpu0/online并启用echo 1 > /sys/devices/system/cpu/cpu0/online

    您可以使用以下方式验证状态cat /proc/cpuinfo

    • 2
  3. ewwhite
    2016-05-28T04:19:40+08:002016-05-28T04:19:40+08:00

    通用答案...直到您提供更多信息。

    您可能希望使用为您的发行版选择的 CPU 隔离工具。此外,cgroups 可能是相关的,具体取决于您具体要完成的任务。

    任务集和cpuset的区别


    编辑:

    您正在寻找 CPU 防护罩。在 EL6 上,您可能需要阅读 cgroups 以及cgred守护进程和cgconfig包。

    例如:

    /etc/cgconfig.conf:

    mount {
            cpuset  = /cgroup/cpuset;
            cpu     = /cgroup/cpu;
            cpuacct = /cgroup/cpuacct;
            memory  = /cgroup/memory;
            devices = /cgroup/devices;
            freezer = /cgroup/freezer;
            net_cls = /cgroup/net_cls;
            blkio   = /cgroup/blkio;
    }
    
    group ppro-users {
            cpuset {
                    cpuset.mems="0-1";
                    cpuset.cpus="2-7,14-19";
            }
            cpu {
                    cpu.shares = 1000;
            }
            memory {
                    memory.limit_in_bytes = 40960m;
            }
    }
    

    上面的代码片段将“ppro-users”cgroup 中的进程限制为某些 CPU。我通过使用 cgred 包来识别和管理应该属于该 cgroup 的进程来增强它。

    /etc/cgrules.conf

    # Example:
    #<user>         <controllers>   <destination>
    #@student       cpu,memory      usergroup/student/
    #peter          cpu             test1/
    #%              memory          test2/
    admin           cpu,cpuset,memory       ppro-users/
    @ppro:dbc       cpu,cpuset,memory       ppro-users/
    
    • 2

相关问题

  • 哪些 939 插槽芯片支持 AMD-V?

  • DDR II 667 与 DDR 400

  • 两个双核与一个四核

  • 奔腾电脑的寿命

  • 有没有办法给一个带有 Windows 的 xen vm 提供多个虚拟 cpu?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve