The question says it all. I see some tutorials online for earlier editions of Ubuntu, but am having a hard time for 12.04.
Ubuntu – How to adjust IRQ priority in Ubuntu 12.04
12.04process-priority
Related Solutions
Note: This solution only works with the cfq scheduler, as explained here. You should check which one is used by issuing
cat /sys/block/sda/queue/scheduler
and change it if necessary.
If I understood correctly, you want some ionice
setting to be applied every time you start a command. You can do it this way:
echo 'ionice -c 3 /usr/bin/VirtualBox "$@"' > VirtualBox
chmod a+x VirtualBox
sudo mv VirtualBox /usr/local/bin/
First command creates a file VirtualBox
with the single-quoted text as its content. This should have the full path to the program, because if one only specify VirtualBox
it can interpret it as the file we just created and create a "loop".
Second command makes it executable, and third moves this new file in a folder which is in front of the "system" bin folder /usr/bin
, so our new file gets executed instead of the original. The "$@" part contains all the arguments the command was invoked with, so they get forwarded to the real VirtualBox command.
According to answer ("yes") to this Super User question Do children processes inherit ionice priorities from their parents? How do you check the IO priority of a running process?, it should be enough to ionice
the parent process, like this:
ionice -c 3 VirtualBox
From ionice
man page, following I/O scheduling class values are available:
- 0 for none
- 1 for realtime
- 2 for best-effort
- 3 for idle (used in example above)
A number or class name can be used.
Also, -n level
option is applicable for realtime and best-effort classes, with 0-7 as valid data (priority levels).
I think you should ask in Unix & Linux but in any case, the ones that say that NICE values for CPU in Linux vary from 0 to 99 are just for Real Time OS. The nice values are between -20 to 20, being -20 the higher priority, in normal (the one that most of users uses) *NIX kernels for CPU. Which is for most cases.
Also, the file copying wouldn't need actually that much CPU (depending the filesystems) but the I/O priority. From kernel 2.6.26 the ionice values are determined by the CPU nice values using the following formulae:
io_priority = (cpu_nice + 20) / 5
Also, all process (unless modified source code) starts with "Best effort" priority class which uses the formulae above. But, in any case, you probably don't need to set this as default.
A way to set the I/O priority to start a process is doing:
ionice -c2 -n6 SOME_COMMAND
Process that would like to set/get their own I/O scheduling class and priority should use the ioprio_set and ioprio_get functions.
Also a nice warning from Linux Poison:
Read the description for realtime carefully. Realtime IO nice processes will starve the system completely until they are done using the disk. You can easily make your system non responsive for long periods of time.
Also, IO niceness only has effect if you are using the CFQ io scheduler . If you have an elevator= (as, deadline,noop) line in your menu.lst, IO niceness will have no effect.
Sources:
Best Answer
Questions like this are very important when running pro audio applications. As you see, and as I have experienced myself many times in the past, Askubuntu.com has a tendency to tell us that we don't need an answer to these kinds of questions. For these narrowly focused questions, you'll find more friendly help on places like the LinuxMusicians forum or the OpenSourceMusicians IRC channel (# opensourcemusicians).
I run KX Studio (which is a pro audio distribution on top of Kubuntu) and I have gotten a lot of help at both #kxstudio and #ardour IRC channels.
Anyway, here's how you do it now that I have figured it out with help from the above resources.
Use these commands to discover the USB bus and IRQ of your audio device:
In my case, my USB audio interface is ehci_hcd:usb2 on IRQ 23. It may not be easy to figure it out, but if you cross reference the above listings you'll figure out which IRQ is of interest after some detective work. See below for more tips.
Next, install rtirq
See the Ubuntu Wiki:
https://wiki.edubuntu.org/UbuntuStudio/rtirq
Now edit the file /etc/default/rtirq (as sudo). And look for the line that contains
RTIRQ_NAME_LIST=
If you want IRQ 23 to have the highest priority, add it to the front of the list like so:
However, in my case, I would rather use the name of the device in case the IRQ assignment changes for some unknown reaason. So I specify it like this:
Just put the device (or IRQ) at the front of the list for highest priority. It is a space delimited list.
Save the file, then run:
There is no need to reboot. You'll see the resulting IRQ priorities listed from the command above. But if you want to see them again later, run:
And check
cat /proc/interrupts
if desired.Some extra tips, as promised:
Using
lsusb
I found that my audio interface was on USB Bus 001 Device 003.Next, using
lspci -v
I found that I have 3 USB controllers. I found one listed like this:00:1d.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1
. The flags in that listed included these:Flags: bus master, medium devsel, latency 0, IRQ 23
. So, assuming I picked the right USB controller (the one controlling Bus 01), those flags told me that I am interested in IRQ 23.Next,
/proc/interrupts
told me that IRQ 23 has the device nameehci_hcd:usb2
associated with it.I also used
tree /sys/bus/usb/drivers/usb/
andcat /proc/asound/cards
to cross reference info to pick the correct USB controller.You might also find the following Perl script useful:
realTimeConfigQuickScan.pl