Saturday, January 28, 2017

Install waveforms software for Analog Discovery 2 on Fedora 24

Install adept2 and then install the waveforms rpm. Use --nodeps option if you receive failed dependency error on libc when the waveforms rpm is installed.

# rpm -ivh digilent.adept.runtime-2.16.5.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:digilent.adept.runtime-2.16.5-1  ################################# [100%]


#rpm -ivh digilent.waveforms_3.4.7.x86_64.rpm 

error: Failed dependencies:
libc6 >= 2.14 is needed by digilent.waveforms-3.4.7-1.x86_64

# rpm -ivh digilent.waveforms_3.4.7.x86_64.rpm  --nodeps
Preparing...                          ################################# [100%]
Updating / installing...
   1:digilent.waveforms-3.4.7-1       ################################# [100%]


SD card benchmarking on raspberry pi

I have been reading about various SBCs (Single Board computers) to find a suitable one to build a NAS. While doing that, I remembered I own a Raspberry Pi 1 Model B SBC. Therefore I decided to try a torrent client on the raspberry pi to find out the capabilities of my old raspberry pi.

So, I used the latest raspbian lite image (2017-01-11-raspbian-jessie-lite.img) which is a nice headless distro suitable for my experiment on a Class 10 SD card ( Kingston 32GB SDHC SDC10G2/32GB).

Then I installed the transmission client daemon as the torrent client and added a private torrent which had a good healthy swarm. I left the torrent client keep running for a while and noticed that the download speed goes down to 0 time to time. I thought this was due to the behavior of the peers. however after observing the client for a while I understood it happened time to time with a pattern.

Then I used iostat command (comes with the sysstat package) to monitor the I/O behavior and found out that the I/O Wait goes about 100% when the download speed goes to 0. So there is a relationship between the write performance and the periodic download speed drops.

Therefore I decided to benchmark the write performance on the raspberry pi. The intention was just to study the performance of the write performance of the OS (VFS + File system ) and the raspberry pi hardware combination, not the SD card performance.

The tests were done using iozone tool with different test scenarios. Each scenario was tested for a 1000MB file with 25MB, 50 MB and 100MB record sizes.


File System
Disk Scheduling Algorithm
Ext4 with journal
noop
Ext4 without journal
noop
Ext4 with journal
deadline
Ext4 without journal
deadline
Ext4 with journal
cfq
Ext4 without journal
cfq


Then I plotted the read,write,random read and random write results using gnuplot.

According to the results,

  • write graphs shows that the raspberry pi can handle about 10000 KB write rate. There was no significant variance in the rate with the record size.
  • random write graph shows that the raspberry pi can handle 9000 KB write rate. It also shows that the higher rates can be achieved setting the higher record sizes.
  • read and random read graphs show that the raspberry pi can handle about 18000 KB read/random read rate. There was no significant variance in the rate with the record size. 

Therefore even though the SD card is class 10, that will not give you the actual SD card performance due to bottlenecks in Raspberry pi.


Write
Write 

Random Write
Random Write
Read
Read
Random Read
Random Read
This is how I prepared the SD card for the tests,

Prepare the SD card for raspberry pi

First write the raspbian image on to the SD card using dd command,

dd if=2017-01-11-raspbian-jessie-lite.img of=/dev/sdx

Then we need to create two partitions with and without ext4 journal for this experiment. However when raspberry pi boots at first time, it expands the file system automatically to consume all the free disk space in the SD card. In order to avoid that we should disable that feature.

For that, mount the SD card and edit cmdline.txt file located in the boot partition and remove the highlighted portion from the boot parameters.

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh


Create 2 partitions for tests

Insert the SD card in to the raspberry pi and boot it. Now we are able to create the two partitions we want on the SD card.


root@raspberrypi:~# fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 29 GiB, 31104958464 bytes, 60751872 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x244b8248

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1        8192  137215  129024   63M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      137216 2715647 2578432  1.2G 83 Linux


Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): e
Partition number (3,4, default 3): 
First sector (2048-60751871, default 2048): 2715648
Last sector, +sectors or +size{K,M,G,T,P} (2715648-60751871, default 60751871): 

Created a new partition 3 of type 'Extended' and of size 27.7 GiB.

Command (m for help): p
Disk /dev/mmcblk0: 29 GiB, 31104958464 bytes, 60751872 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x244b8248

Device         Boot   Start      End  Sectors  Size Id Type
/dev/mmcblk0p1         8192   137215   129024   63M  c W95 FAT32 (LBA)
/dev/mmcblk0p2       137216  2715647  2578432  1.2G 83 Linux
/dev/mmcblk0p3      2715648 60751871 58036224 27.7G  5 Extended


Command (m for help): n
Partition type
   p   primary (2 primary, 1 extended, 1 free)
   l   logical (numbered from 5)
Select (default p): l

Adding logical partition 5
First sector (2717696-60751871, default 2717696): 
Last sector, +sectors or +size{K,M,G,T,P} (2717696-60751871, default 60751871): +14G

Created a new partition 5 of type 'Linux' and of size 14 GiB.

Command (m for help): p
Disk /dev/mmcblk0: 29 GiB, 31104958464 bytes, 60751872 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x244b8248

Device         Boot   Start      End  Sectors  Size Id Type
/dev/mmcblk0p1         8192   137215   129024   63M  c W95 FAT32 (LBA)
/dev/mmcblk0p2       137216  2715647  2578432  1.2G 83 Linux
/dev/mmcblk0p3      2715648 60751871 58036224 27.7G  5 Extended
/dev/mmcblk0p5      2717696 32077823 29360128   14G 83 Linux


Command (m for help): n
Partition type
   p   primary (2 primary, 1 extended, 1 free)
   l   logical (numbered from 5)
Select (default p): l

Adding logical partition 6
First sector (32079872-60751871, default 32079872): 
Last sector, +sectors or +size{K,M,G,T,P} (32079872-60751871, default 60751871): 

Created a new partition 6 of type 'Linux' and of size 13.7 GiB.

Command (m for help): p
Disk /dev/mmcblk0: 29 GiB, 31104958464 bytes, 60751872 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x244b8248

Device         Boot    Start      End  Sectors  Size Id Type
/dev/mmcblk0p1          8192   137215   129024   63M  c W95 FAT32 (LBA)
/dev/mmcblk0p2        137216  2715647  2578432  1.2G 83 Linux
/dev/mmcblk0p3       2715648 60751871 58036224 27.7G  5 Extended
/dev/mmcblk0p5       2717696 32077823 29360128   14G 83 Linux
/dev/mmcblk0p6      32079872 60751871 28672000 13.7G 83 Linux


Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).


root@raspberrypi:~# partprobe /dev/mmcblk0

root@raspberrypi:~# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0     179:0    0   29G  0 disk 
├─mmcblk0p1 179:1    0   63M  0 part /boot
├─mmcblk0p2 179:2    0  1.2G  0 part /
├─mmcblk0p3 179:3    0  512B  0 part 
├─mmcblk0p5 179:5    0   14G  0 part 

└─mmcblk0p6 179:6    0 13.7G  0 part 


Create file systems on the partitions

Create a ext4 file system without a journal,

root@raspberrypi:~# mkfs.ext4 -O ^has_journal /dev/mmcblk0p5
mke2fs 1.42.12 (29-Aug-2014)
Discarding device blocks: done                            
Creating filesystem with 3670016 4k blocks and 917504 inodes
Filesystem UUID: 70fbac8c-4b68-4f53-aacb-12c2f84022ba
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

Create another ext4 file system with default options,

root@raspberrypi:~# mkfs.ext4  /dev/mmcblk0p6
mke2fs 1.42.12 (29-Aug-2014)
Discarding device blocks: done                            
Creating filesystem with 3584000 4k blocks and 897600 inodes
Filesystem UUID: 3d5c4292-3aa6-49c8-a0e9-4fa7f0d484e3
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 


Then mount the partitions,

mkdir /no_journal /with_journal

root@raspberrypi:~# cat /etc/fstab 
proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
/dev/mmcblk0p5  /no_journal     ext4    defaults,noatime  0       0
/dev/mmcblk0p6  /with_journal   ext4    defaults,noatime  0       0

root@raspberrypi:~# mount -a



iozone utilitiy

Download iozone source code and compile it to build the tool.

wget http://www.iozone.org/src/current/iozone3_465.tar


Note: I changed  MAXBUFFERSIZE constant defined in the iozone.c file in order to have larger record sizes. by default it supports only for 16MB record sizes.

References,

Friday, January 13, 2017

Things I did after installing Fedora 24

Removed evolution application since I don't use it.


dnf remove evolution

Configure RPMFusion repo


wget https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-24.noarch.rpm
rpm -ivh rpmfusion-free-release-24.noarch.rpm 

Upgrade the system


dnf upgrade

Install Intel Linux graphic drivers


wget https://download.01.org/gfx/fedora/24/x86_64/intel-graphics-update-tool-2.0.3-24.intel20163.x86_64.rpm
rpm -ivh intel-graphics-update-tool-2.0.3-24.intel20163.x86_64.rpm 
Run intel-graphics-update-tool command as root and install the Intel drivers

Install VLC and configure hardware acceleration


Read the instructions here,
http://swapoff.blogspot.com/2017/01/how-to-enable-hardware-acceleration-in.html


Install Google Chrome


rpm -ivh google-chrome-stable_current_x86_64.rpm 
warning: google-chrome-stable_current_x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 7fac5991: NOKEYerror: Failed dependencies: lsb >= 4.0 is needed by google-chrome-stable-55.0.2883.87-1.x86_64

Install redhat-lsb as well if you receive above error when you try to install Google Chrome.
dnf provides lsb
dnf install redhat-lsb

Install Gnome Tweak Tool and configure it to show files on Desktop


dnf install gnome-tweak-tool

Disable dnf-makecache service


systemctl status dnf-makecache.service
systemctl status dnf-makecache.timer
More information is avaiable here,
http://swapoff.blogspot.com/2015/09/disable-automatic-package-metadata.html

Wednesday, January 11, 2017

How to enable hardware acceleration in VLC running on Fedora 24

I used to use VLC hardware acceleration (http://swapoff.blogspot.com/2014/12/install-libva-intel-driver-to-get-hw.html) because it's a cool thing to have when you play HD videos. Recently I noticed that my CPU is heavily utilized when I played HD videos even though I was under the impression that the hardware acceleration was working. The methods I tried to find out whether the hardware acceleration was working or not gave positive results, but the CPU utilization was telling a different story.

Therefore I tried to understand what was actually happening.

After doing some google searches I landed on a VLC forum thread which describes this was due to the behavior in the FFmpeg library. (https://forum.videolan.org/viewtopic.php?t=134770) According to the information shared in that thread, the library does not support multithreading with hardware acceleration. But VLC set 0 which is auto for the number of threads for FFmpeg.

Therefore changing this value to 1 should work. We can change the value by selecting,  
Tools -> Preferences -> Input/Codecs -> Show Settings All -> Input codecs -> Video codecs -> FFmpeg and set the value of the parameter "Threads" to 1

After setting this value to 1 and restarting the VLC, I tried to play several 720p videos. It actually worked. The CPU utilization was well under 10%.

However when I tried to play a 1080i Blue-Ray video, a nasty thing happened. It triggered a bug in the kernel and crashed the system.

details of the crash from journalctl,

Jan 10 02:31:17 localhost.localdomain kernel: BUG: unable to handle kernel NULL pointer dereference at           (null)
Jan 10 02:31:17 localhost.localdomain kernel: IP: [<ffffffffc019d58d>] gen6_ppgtt_insert_entries+0x14d/0x1d0 [i915]
Jan 10 02:31:17 localhost.localdomain kernel: PGD 0
Jan 10 02:31:17 localhost.localdomain kernel: Oops: 0000 [#1] SMP
Jan 10 02:31:17 localhost.localdomain kernel: Modules linked in: uas usb_storage fuse xt_CHECKSUM ipt_MASQUERADE nf_nat_masquerade_ipv4 tun ip6t_REJECT nf_reject_ipv6 xt_con
Jan 10 02:31:17 localhost.localdomain kernel:  intel_rapl_perf snd_hda_core snd_hwdep snd_seq snd_seq_device snd_pcm joydev i2c_i801 mei_me i2c_smbus snd_timer snd mei shpch
Jan 10 02:31:17 localhost.localdomain kernel: CPU: 3 PID: 2740 Comm: vlc Not tainted 4.8.15-200.fc24.x86_64 #1
Jan 10 02:31:17 localhost.localdomain kernel: Hardware name: ASUS All Series/H97M-E, BIOS 2302 02/09/2015
Jan 10 02:31:17 localhost.localdomain kernel: task: ffff91804f7f1e80 task.stack: ffff91801e340000
Jan 10 02:31:17 localhost.localdomain kernel: RIP: 0010:[<ffffffffc019d58d>]  [<ffffffffc019d58d>] gen6_ppgtt_insert_entries+0x14d/0x1d0 [i915]
Jan 10 02:31:17 localhost.localdomain kernel: RSP: 0018:ffff91801e3439d8  EFLAGS: 00010246
Jan 10 02:31:17 localhost.localdomain kernel: RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff91808be44000
Jan 10 02:31:17 localhost.localdomain kernel: RDX: ffff91801de7aae0 RSI: ffff918088b01000 RDI: 000000038cc4d000
Jan 10 02:31:17 localhost.localdomain kernel: RBP: ffff91801e343a28 R08: 0000000000000000 R09: ffff91808be44000
Jan 10 02:31:17 localhost.localdomain kernel: R10: 0000000000000000 R11: ffff918088a20000 R12: ffff918088b01ffc
Jan 10 02:31:17 localhost.localdomain kernel: R13: 0000000000000000 R14: ffff91801de7aae0 R15: 0000000000000000
Jan 10 02:31:17 localhost.localdomain kernel: FS:  00007f8b0882a700(0000) GS:ffff91809fb80000(0000) knlGS:0000000000000000
Jan 10 02:31:17 localhost.localdomain kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Jan 10 02:31:17 localhost.localdomain kernel: CR2: 00007fe765248000 CR3: 00000003b4c1a000 CR4: 00000000001406e0
Jan 10 02:31:17 localhost.localdomain kernel: Stack:
Jan 10 02:31:17 localhost.localdomain kernel:  ffff91804f7f1e80 0000000000000200 ffff91808be44000 0000100000000001
Jan 10 02:31:17 localhost.localdomain kernel:  000000038cc4d000 0000000000000000 ffff91801dd0ac00 0000000000000002
Jan 10 02:31:17 localhost.localdomain kernel:  0000000000000001 ffff9180487dba80 ffff91801e343a60 ffffffffc019ee60
Jan 10 02:31:17 localhost.localdomain kernel: Call Trace:
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc019ee60>] aliasing_gtt_bind_vma+0x90/0xe0 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc01a3e8e>] i915_vma_bind+0xce/0x180 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc01aa4fb>] i915_gem_object_do_pin+0x86b/0xa60 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc01aa71d>] i915_gem_object_pin+0x2d/0x30 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc0198acf>] i915_gem_execbuffer_reserve_vma.isra.20+0x9f/0x180 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc0198f3b>] i915_gem_execbuffer_reserve.isra.21+0x38b/0x3b0 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc019a1d8>] i915_gem_do_execbuffer.isra.24+0x6b8/0x1200 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc019b944>] i915_gem_execbuffer2+0x104/0x260 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc00cbfa0>] drm_ioctl+0x200/0x4f0 [drm]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc019b840>] ? i915_gem_execbuffer+0x330/0x330 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffb0264cc3>] do_vfs_ioctl+0xa3/0x5f0
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffb0265289>] SyS_ioctl+0x79/0x90
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffb0803b72>] entry_SYSCALL_64_fastpath+0x1a/0xa4
Jan 10 02:31:17 localhost.localdomain kernel: Code: 5f 5d c3 c7 45 cc 00 00 00 00 31 db 48 c7 45 d0 00 00 00 00 45 31 f6 e9 2a ff ff ff 8b 45 b8 48 8b 4d c0 48 8b 84 c1 c8 0
Jan 10 02:31:17 localhost.localdomain kernel: RIP  [<ffffffffc019d58d>] gen6_ppgtt_insert_entries+0x14d/0x1d0 [i915]


Then I have found a bug report (https://bugs.freedesktop.org/show_bug.cgi?id=98760) which was reported for this particular issue. Fortunately it had a workaround mentioned to fix the issue. The workaround is to downgrade the
libvdpau-va-gl installation.

First, find out the available versions of libvdpau-va-gl,
dnf --showduplicates list libvdpau-va-gl

Then remove the existing libvdpau-va-gl installation,
dnf remove libvdpau-va-gl

Then install the previous version of libvdpau-va-gl,
dnf install libvdpau-va-gl-0.3.6-1.fc24.x86_64

Finally I was able to get hardware acceleration in VLC worked for both 720p and 1080i HD videos.