Power & battery status from cmdline

jupiterYou must have come across tons of indicator apps, applets and widgets which show the power and battery status on Linux. However, keeping these utilities running also mean you are polling these values constantly (almost always from /sys/class/power_supply) and wasting CPU cycles. How to check the power supply and battery status from the cmdline? Continue reading Power & battery status from cmdline

intel_frequency: manipulate Intel GPU frequency

tux_compBenjamin Widawsky has pushed a new tool to change the frequency of Intel GPUs from userland. This is not a new functionality as this could be done using sysfs but this tool brings it to end users. The tool should be useful for debugging performance issues or benchmarking. It does not allow any GPU overclocking or any functionality not allowed via sysfs. Also note that the tool underwent minimal testing at the time of writing.

Usage

The name of the tool is intel_frequency. It should be run as the root user or sudoer. Options:

  • Get current, min, max and efficient frequencies
    $ sudo intel_frequency --get=cur,min,max,eff
    OR
    $ sudo intel_frequency -g
    cur: 200 MHz
    min: 200 MHz
    RP1: 200 MHz
    max: 1200 MHz
  • Another way to get a particular frequency
    $ sudo intel_frequency -geff
    RP1: 200 MHz
  • Lock frequency to an absolute value
    $ sudo intel_frequency --set min=300
  • Set a custom max (or min) frequency
    $ sudo intel_frequency --custom max=900
  • Lock frequency to the most efficient frequency
    $ sudo intel_frequency -e
    $ sudo intel_frequency -g
    cur: 200 MHz
    min: 200 MHz
    RP1: 200 MHz
    max: 200 MH
  • Lock frequencies to the max frequency
    $ sudo intel_frequency --max
    $ sudo intel_frequency -g
    cur: 1200 MHz
    min: 1200 MHz
    RP1: 200 MHz
    max: 1200 MHz
  • Lock frequencies to the min frequency (DEBUG only)
    $ sudo intel_frequency --min
    $ sudo intel_frequency -g
    cur: 200 MHz
    min: 200 MHz
    RP1: 200 MHz
    max: 200 MHz

The patch is available here in the Intel Graphics mailing list, waiting to be added to the Intel GPU tools package (at the time of writing).

cpulimit & taskset: control process CPU affinity & usage

cool_penguin_smallPlaying with processes on Linux is always fun. cpulimit and taskset are two cool and useful utilities to control the behaviour of your processes at a CPU-core level.

cpulimit

Lets you control or limit the CPU usage of a process. This will make a processor intensive process take longer to finish but will allow other processes to utilize the CPU. cpulimit works on both single or multi-core environments. Run the following command to install cpulimit on Ubuntu:

$ sudo apt-get install cpulimit

The easiest way to use cpulimit is to add cpulimit -l perecentage_of_cpu before your usual command. For example:

$ cpulimit -l 20 ghb

will run HandBrake (ghb) and force it to use around 20% of your processing capacity. cpulimit has options to attach to an already running process:

-p PID : attach to the process with PID process ID
$ cpulimit -l 20 -p 1234
 
-e prog_name : attach to the  executable with name prog_name
$ cpulimit -l 20 -e ghb

The -b option runs cpulimit in the background.

taskset

taskset is a wrapper to the sched_setaffinity system call. Use it to control which processor core(s) a process can run on.

To start HandBrake on cores 0, 2 and 3:

$ taskset -c 0,2,3 ghb

To make a process with PID 1234 run on cores 0 and 2 (the output will show the current and changed affinity):

$ taskset -c -p 0,2 1234 //note: 0,2 comes after -p followed by PID
pid 1234's current affinity list: 0-3
pid 1234's new affinity list: 0,2

As you can see, before changing the affinity, the process could have run on any core from 0 to 3 (I have a quad core device). That’s the general affinity of any process started without taskset.

To know the current affinity of any process:

$ taskset -c -p PID

You can also use ps:

$ ps -o pid,psr,comm -p PID

i-Nex: hardware information on Linux

i-Nex is a fresh hardware information reporting tool on Linux. The author was inspired by the Windows tool CPU-Z and the the GUI of i-Nex bears a strong resemblance to it. i-Nex is a very powerful tool and provides as much information as CPU-Z, if not more. Capabilities:

  • Basic information of your hardware like like CPU speed, model and L family cache sizes
  • Advanced details like the number of transistors on the die, the multiplier size, the exact voltage and TDW it uses
  • Covers GPU information, audio, drivers and more
  • Software information like distribution, desktop environment etc.
  • Xorg details and kernel information

Drawbacks:

  • i-Nex depends on gambas3 which in turn has tons of dependencies. I am not sure if anyone would want to intall so may packages just to try out a hardware reporting utility.

Install i-Nex on Ubuntu:

$ sudo add-apt-repository ppa:i-nex-development-team/stable
$ sudo add-apt-repository ppa:gambas-team/gambas3
$ sudo apt-get update
$ sudo apt-get install i-nex
Cmdline alternatives to i-Nex on Ubuntu
$ sudo dmidecode -t 4
$ lscpu
$ cat /proc/cpuinfo

Homepage: i-Nex

inxi: fetch system information

inxi is a script that fetches the details of your system, specifically hardware for you. It is quite handy when you need to touch-base with your hardware.The options page extensively details on the numerous things that inxi can do. For simplifying the usage, the authors are working on a GUI as well, though the progress is admittedly slow.

Installation instructions on Ubuntu:

$ sudo apt-get install inxi

To get a list of full options, run:

$ man inxi

Besides showing system information, inxi can show you the weather too! Run:

$ inxi -xxxw

Webpage: inxi

i7z: Intel i3, i5, i7 reporting tool on Linux

chipIf you want a detailed information of your Intel i3, i5 or i7 CPU on Linux, try this tool out – i7z. Pretty simple to compile with minimal dependencies. It gives you a lot of detailed information to know your CPU better, e.g. do you know if your Turbo Boost or Hyper-Threading is enabled? Use this tool to check.

Website: i7z