Linux 如何隔离CPU核心 isolcpus=0-2

Linux 如何隔离CPU核心 isolcpus=0-2


rtoax
2021年5月8日

1. tuned调优方式隔核

1.1. 首先查看当前调优方式

# tuned-adm active 
Current active profile: realtime-virtual-host

1.2. tuned查看可用的调优方式

# tuned-adm profile 
Available profiles:
- balanced                    - General non-specialized tuned profile
- desktop                     - Optimize for the desktop use-case
- latency-performance         - Optimize for deterministic performance at the cost of increased po
wer consumption- network-latency             - Optimize for deterministic performance at the cost of increased po
wer consumption, focused on low latency network performance- network-throughput          - Optimize for streaming network throughput, generally only necessar
y on older CPUs or 40G+ networks- powersave                   - Optimize for low power consumption
- realtime                    - Optimize for realtime workloads
- realtime-virtual-guest      - Optimize for realtime workloads running within a KVM guest
- realtime-virtual-host       - Optimize for KVM guests running realtime workloads
- throughput-performance      - Broadly applicable tuning that provides excellent performance acro
ss a variety of common server workloads- virtual-guest               - Optimize for running inside a virtual guest
- virtual-host                - Optimize for running KVM guests
Current active profile: realtime-virtual-host

1.3. 查看系统存在调优方式的配置文件

# ls /etc/tuned/
active_profile  profile_mode             realtime-virtual-guest-variables.conf  recommend.d
bootcmdline     realtime-variables.conf  realtime-virtual-host-variables.conf   tuned-main.conf

1.4. 修改tuned 某一种调优方式的配置文件profile

# vim realtime-virtual-host-variables.conf

  1 # Examples:
  2 # isolated_cores=2,4-7
  3 # isolated_cores=2-23
  4 #
  5 isolated_cores=0

通过修改isolated_cores的数字来隔离CPU

1.5. tuned 生效一种调优方式

tuned-adm profile realtime-virtual-host

1.6. 重启生效配置

reboot

2. 修改grub配置文件

隔核调优方式也可以直接在/etc/default/grub中修改。

vim /etc/default/grub

GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap no_timer_check clocksource=tsc tsc=perfect intel_pstate=disable selinux=0 enforcing=0 nmi_watchdog=0 softlockup_panic=0 isolcpus=1-39 nohz_full=0-39 idle=poll default_hugepagesz=1G hugepagesz=1G hugepages=16 rcu_nocbs=1-39 kthread_cpus=0 irqaffinity=0 rcu_nocb_poll rhgb quiet"

修改grub配置文件后需要更新grub配置文件,运行一下命令

grub2-mkconfig -o /boot/grub2/grub.cfg

然后重启生效

reboot

3. 查看隔核情况

$ more /proc/cmdline 
BOOT_IMAGE=/vmlinuz-3.10.0-1062.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root r
d.lvm.lv=centos/swap rhgb quiet skew_tick=1 isolcpus=2-3 intel_pstate=disable nosoftlockup

其中isolcpus=2-3即为隔离的CPU。

  • 4
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值