怎么在RHEL5中提高某些进程的IO优先级?

295 篇文章 0 订阅
117 篇文章 0 订阅

How do I increase the I/O priority of some processes on Red Hat Enterprise Linux 5?

Updated 2012年九月16日10:04 - 

English 

Release Found: Red Hat Enterprise Linux 5 and later

Introduction

The I/O priority and scheduling class of a process can be modified by the ionice command. Linux supports three scheduling classes:

  • Idle: A program running with idle I/O priority will only get disk time when no other program has asked for disk io for a defined grace period.

  • Best effort: This is the default scheduling class for any process that hasn't asked for a specific I/O priority.

  • Real time: The Real Time (RT) scheduling class is given first access to the disk, regardless of what else is going on in the system.

A process by default is in the Best Effort class with a priority of 0, i.e. the highest priority in that class. The best use case for using ionice to improve performance is when you need to do two classes of tasks at once: the ones that don’t use much disk I/O but demands fast response times, and the ones that do a lot of disk I/O but don’t need it done urgently.

Solution

To increase the I/O priority of a process you can use the following command:

Raw

# ionice -c1 -n0 -p<PID>

Where:

  • "-c1" indicates Real time scheduling

  • "-n0" is for highest priority

  • "-p <PID> is the process ID

Also, you can lower the I/O priority of a process with the following:

Raw

# ionice -c2 -n4 -p<PID>

Where:

  • "-c2" indicates best-effort scheduling

  • "-n4" is for priority 4

To check the current I/O priority of a process run the following command:

Raw

# ionice <PID>

For example:

Raw

# ionice 9709
realtime: prio 7

For more details on the ionice command options, see the manual page by running "man ionice".

Applications

One use case is rescheduling an entire parent shell to idle class, so that all commands executed from that shell are idle priority. You can get this from the $$ shell variable in bash and sh.

For example:

Raw

# echo $
29033

This output means that your current bash shell is process id 29033. If you want to switch the whole shell to idle disk priority, you can run:

Raw

# ionice -c3 -p$

Now everything you do in this shell is in idle priority.

Another major application of the ionice command would be during system backups. One would like to change the I/O priority of backup software, so that it has less interference with other operations of the system.

Note: This only works on kernels 2.6.13 and later using the CFQ I/O scheduler. You can check what scheduler is running by running cat /sys/block/[sh]d[a-z]*/queue/scheduler in Red Hat Enterprise Linux 5. The word outlined in brackets is currently selected.

For example, the following output shows the the CFQ scheduler is in use:

Raw

$ cat /sys/block/[sh]d[a-z]*/queue/scheduler
noop anticipatory deadline [cfq]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值