set-control-group-knob 1 user commands nosh
set-control-group-knob set a knob in the current control group
`set-control-group-knob` --infinity-is-max --multiplier-suffixes --device-name-key --percent-of filename --nested-key key knob value

## Description

`set-control-group-knob` is a simple utility that sets the control group knob group in the current control group to value. It locates the current control group using the same algorithm as move-to-control-group 1, and will similiarly fall back to being a no-op on platforms where `/proc/self/cgroup` does not exist.

For details on what knobs are available and what values they can be set to, consult the Linux API documentation.

The Linux I/O control groups mechanism has several knobs that operate in terms of a device "key" that denotes which device the knob setting is affecting. The key actually comprises major and minor device numbers, not device file names. However, because of Plug and Play these major and minor device numbers are not necessarily stable from run to run of the system, or the same across systems. The --device-name-key command line option is used to allow one to operate with device file names. If that command line option is given, then the first thing that `set-control-group-knob` does is strip the first white-space delimited word from value, treat it as the name of a block or character device file (failing if that is not the case), and prefix the remainder of value that was left with the major and minor device numbers of the device. Other options then act upon the remainder of value as if the device key were not there. So, for example, one can use a value of "/dev/null default" in the command line arguments in a script and that will be re-written using the major and minor device numbers of the actual current `/dev/null` device when the `set-control-group-knob` command is run.

If the --infinity-is-max command line option is given, then if value is `infinity` it is replaced with `max`. The Linux control groups mechanism actually recognizes "max", not "infinity"; but unfortunately some toolsets have encouraged the use of "infinity" when talking to control groups. This provides compatibility with such usage.

If the --nested-key command line option is given, then value when finally written is prefixed by key as a nested key. Of course one can simply provide key directly in value. This provides a convenience mechanism for using nested keys in scripts without the script having to merge the nested key into the value itself. It also enables the options that expect value to take the form of a number followed by a suffix, which do not allow for nested keys in value.

If the --multiplier-suffixes command line option is given and if value is parseable as a number followed by an SI or an IEEE/IEC abbreviation, then it is replaced by the value that results when multiplying the number by the associated scale factor. The SI abbreviations are `k`, `M`, `G`, or `T` denoting the relevant power of 10; the IEEE/IEC abbreviations are `Ki`, `Mi`, `Gi`, and `Ti` denoting the relevant power of 2.

If the --percent-of command line option is given and value is parseable as a number followed by a percent symbol, then file is read and parsed as a decimal number followed by a newline. If opening the file and parsing the number fails, `set-control-group-knob` exits with a failure code. Otherwise, value is replaced by the value of that number, in decimal without exponential notation and rounded to an integer value, multiplied by the given percentage. At minimum, 64-bit integer arithmetic is used to calculate the percentage.

## See also

- create-control-group 1

- move-to-control-group 1

- delegate-control-group-to 1

## Author

Jonathan de Boyne Pollard