Tuesday, July 21, 2015

Tmuxing with Tmuxinator


So, Here is what’s happened, I was doing some testing with driver for #top_secrete project. So each time to test my driver, I have to go through following steps,

- ssh to target platform (tab0), run vim to edit code
- ssh to target platform (tab1), cd to source dir
- source environment
- build/install
- ssh to target (tab2), cd to log dir and start ldmesg script to continuously monitor dmesg logs
- ssh to target (tab3), cd to test dir and start test (server)
- ssh to target (tab3), cd to test dir and start test (client).

aahh, lots of steps and if driver crashes during testing (and that's what happens most of the times), I have to repeat this whole process again. Above described (steps) stuff is mostly unproductive. So how to avoid it??

So here comes tmux,

Tmux (terminal multiplexer) allows you to switch between multiple programs in single terminal. Its similar to screen.

Getting started resources for tmux :

So if I login in to target system over SSH in one terminal and start tmux, I can create multiple tabs inside single terminal using tmux to run multiple programs. This solves partial problem i.e. multiple SSH logins, but sill I have to do lots of stuff manually after creating multiple tabs using tmux. I needed further automation in the process...

After doing some googling I came across tool called tmuxinator.
It does exactly what's needed. Tmuxinator is awesome tool that allows you to configure tmux session i.e. how many TTYs (tabs) to start with, executing some commands on start, splitting window, base/root directory for each tabs can be configured separately, cool right!

Getting started resources for tmuxinator:

So tmuxinator automates most of the steps above, it launches tmux, creates multiple tabs, source env, changes dir to specific directory and additionally we can maintain multiple project settings/profiles much easily and what it needs is simple configuration file.

(will update more soon!)

Tuesday, May 19, 2015

How to increase vmalloc size [vmalloc: allocation failure]


So this is what happened, I was working on the graphics driver and testing some GLBenchmark applications to see if everything is smooth and healthy. But one of the test was always failing for unknown reason (at that time). I have put more than couple of hours to debug that. I was ignoring some errors in dmesg (kernel log) that I was getting,

May 18 14:53:38 pc-vbox kernel: [412318.373157] vmap allocation for size 37752832 failed: use vmalloc=<size> to increase size.
May 18 14:53:38 pc-vbox kernel: [412318.373161] vmalloc: allocation failure: 37748736 bytes
May 18 14:53:38 pc-vbox kernel: [412318.373163] GLBenchmark27_X: page allocation failure: order:0, mode:0xd2

Latter I found that application was quite a heavy and vmalloc is failing due to insufficient space. On x86_32 systems default vmalloc size is 128MB and can be override by vmalloc kernel boot option. vmalloc() allocates block of memory with continuous virtual addresses or pages  (no guarantee that pages are actually contiguous in physical RAM) . You can find current vmalloc size of your system as bellow,

$cat /proc/meminfo | grep -i vmalloc

VmallocTotal: 122880 kB
VmallocUsed: 28216 kB
VmallocChunk: 94156 kB

How to increase vmalloc space?
We have to modify the kernel boot options in grub in order to do that.
open /etc/default/grub and make following change,
This will increase total vmalloc space to 512MB, next you need to update the grub as follows,

$sudo update-grub

After this corresponding  change will be reflected in /boot/grub/grub.cfg file as bellow,

Then just reboot the system and that solved my problem. Its not the thumb rule to set vmalloc to 512M but just set to what solves your problem!

After reboot you can see vmalloc size increased,

$cat /proc/meminfo | grep -i vmalloc
VmallocTotal:     524288 kB
VmallocUsed:       64768 kB
VmallocChunk:     366544 kB