Dec 07

How to build a linux kernel (Ubuntu)

Create a .config file for your new kernel using the config file of your existing kernel.
# cp /boot/<config-kernel_version_#> <kernel_dir>/.config

If the .config file is modified using an editor like vim, etc, do
# make oldconfig

The kernel configuration can also be modified by
# make menuconfig

Make changes and then save and exit.

To build and install the kernel, do the following:

  • # make all -j #proc_cores (to build the kernel in parallel)
    For me (#cores+1) is the fastest.
  • # make module_install
  • # make install

There should now be three new files in /boot
# ls /boot

  1. config-<new_kernel_name>
  2. System.map-<new_kernel_name>
  3. vmlinux-<new_kernel_name>

On Ubuntu distributions v10.10 and above, the initrd.img file has to created manually. For doing so:

  • # sudo update-initramfs -c -k <new_kernel_name>
  • # sudo update-grub

Dec 07

Running OpenCL applications remotely on AMD GPUs

AMD’s OpenCL implementation relies on CAL to manage the AMD GPU for general-purpose computations. AMD CAL uses existing API hooks into the display driver to access the GPU. For doing so, CAL needs to have direct access to the display driver.

When the applications are run locally on the graphics console, CAL has direct access to the display driver, but not so when the applications are remotely.

The solution to the problem is to provide necessary permissions to CAL to access the to the display driver.

On linux, this can be done as following:

1. Log into your system as root.

2. If you are running Red Hat Enterprise Linux or Ubuntu 11.04:

a. Add the following lines at the end of /etc/gdm/Init/Default, before the exit 0, to modify the security settings, allowing remote sessions to access the X server and ensuring that remote sessions have access to the necessary device files when communicating with the GPU:

xhost +
chmod uog+rw /dev/ati/card*

b. If you normally use bash, add the following line to the end of /etc/bashrc file to ensure remote sessions know which X server to access.
case $DISPLAY in ’’) export DISPLAY=:0;; *) ;; esac
NOTE: ’ ’ are two single quotes, not a single double-quote.

3. If you are running openSUSE:

a. Add the following lines at the end of /etc/X11/xdm/Xsetup after the . /etc/sysconfig/displaymanager to modify the security settings, allowing remote sessions to access the X server and to ensure remote sessions have access to the necessary device files when communicating with the GPU.
xhost +
chmod uog+rw /dev/ati/card*

b. If you normally use bash, add the following line to the end of /etc/bash.bashrc to ensure remote sessions know which X server to access.
case $DISPLAY in ’’) export DISPLAY=:0;; *) ;; esac
NOTE: ’ ’ are two single quotes, not a single double-quote.

4. If you normally use tcsh, add the following line to the end of
/etc/csh.cshrc to ensure remote sessions know which X server to access.

if ( ! $?DISPLAY ) then
setenv DISPLAY :0
endif

5. Run /usr/sbin/gdm-restart (RHEL), service gdm restart (Ubuntu), or kill the xorg process (openSUSE) to force gdm/kdm/xdm to restart and pick up the new settings.

You should now be able to run OpenCL applications remotely.

Dec 07

Log kernel messages on a remote machine in Linux (Ubuntu).

Netconsole can be used to transmit the kernel messages on the sender to the receiver. Netconsole is a kernel module that logs kernel printk messages over UDP allowing debugging of problems where disk logging fails.

Prerequisites -

  • IP address of the receiver
  • MAC address of the receiver
  • A port on the receiver
  • IP address of the sender
  • A port on the sender
  • Name of the network interface of the sender

Assumption -

Both sender and receiver are on the same gateway.

To get receiver’s MAC address, either do ifconfig -a on the receiver or do the following:

pet@sender:~$ ping -c 1 192.168.1.103 > /dev/null
pet@sender:~$ arp -n 192.168.1.103
 Address                  HWtype  HWaddress           Flags Mask            Iface
 192.168.1.103            ether   08:00:46:d4:1d:82   C                     eth0

Netconsole can either be built-in in the kernel or can be added as a module. Follow the steps below to initialize netconsole at boot time.

Case 1: Netconsole is built-in in the kernel.

  • Add the following kernel boot-time parameter in etc/default/grub:
    netconsole = <local_port>@<sender_ip_addr>/<sender_interface>,<remote_port>@<receiver_ip_addr>/<receiver_mac_addr>
  • Reboot the machine.

Case 2: Netconsole has been built as a module.

  • Append “netconsole” in /etc/modules
  • Append the following in /etc/modprobe.d/netconsole.conf
    options netconsole netconsole = <local_port>@<sender_ip_addr>/<sender_interface>,<remote_port>@<receiver_ip_addr>/<receiver_mac_addr>
  • Reboot the machine.

On the sender side, do the following to set the level at which logging of messages is done to the console.

pet@sender:~$ dmesg -n 8

If the above is not set, netconsole will not transmit anything to the receiver.

On the receiver side to listen to the kernel messages, netcat or nc can be used. Depending on the Ubuntu version, one the following will work:

pet@receiver:~$ nc.traditional -ul -q -1 -p <remote_port>
or
pet@receiver:~$ nc -ul -q -1 <remote_port>

One can also use syslog-ng on the receiver side to listen to the messages.

For more info, check the netconsole page on Ubuntu wiki:

https://wiki.ubuntu.com/Kernel/Netconsole

» Newer posts