Tuesday, August 25, 2015

perf on fedora 21


sudo yum install perf



[steve@steve-GA-880GMA-UD2H perf]$ pgrep iperf
2807

[steve@steve-GA-880GMA-UD2H perf]$ perf record -p 2807 -g
^C[ perf record: Woken up 26 times to write data ]
[nf_nat_ipv4] with build id 08e53c9cb720761011036c0f3f3d7db2feb62bc3 not found, continuing without symbols
[nf_conntrack] with build id 6b2d193426fa4e8a93181f77d0622c1425d23af9 not found, continuing without symbols
[iptable_mangle] with build id 3f487227e3da17d0386b8a8b6976ade8311bc0fd not found, continuing without symbols
[nf_conntrack_ipv4] with build id d872b229572d3106b3b415d24a83679191cfd58c not found, continuing without symbols
[iptable_nat] with build id 4a354a31abf978aacb65d3e7c53e13f421c6bdb9 not found, continuing without symbols
[nf_defrag_ipv4] with build id ed79015881b828ed986f78ee7fa06bb62ecf52f3 not found, continuing without symbols
[nf_nat] with build id 9135bac40d6819086edde4816d82c495bbc5640f not found, continuing without symbols
[radeon] with build id 7417d27e130d2e4eecb5d45cc08fb74b4eb003a5 not found, continuing without symbols
[drm] with build id b840649b8536d349cd1525af9dac7892f4b4f5d7 not found, continuing without symbols
[ perf record: Captured and wrote 6.551 MB perf.data (37928 samples) ]


[steve@steve-GA-880GMA-UD2H perf]$ perf report --stdio -g


# Children      Self  Command  Shared Object        Symbol                                         
# ........  ........  .......  ...................  ...............................................
#
    98.75%     0.00%  iperf    libpthread-2.20.so   [.] 0xffff80c11eca95fd                         
              |
              ---0xf5fd
                 |          
                 |--77.16%-- malloc
                 |          0x1d5
                 |          
                 |--15.29%-- Server::Run
                 |          
                 |--6.44%-- 0
                  --1.11%-- [...]

    98.56%     0.08%  iperf    [kernel.kallsyms]    [k] system_call_fastpath                       
              |
              ---system_call_fastpath
                 |          
                 |--99.89%-- 0xf5fd
                 |          |          
                 |          |--78.04%-- malloc
                 |          |          0x1d5



can't get report/annotate to show file/line
maybe related to ?

OK...
I could get it to work by building iperf with
CXXFLAGS='-g3 -gdwarf-2' CFLAGS='-g3 -gdwarf-2'

then some work to understand how threads are represented


operf / oprofile on fedora 21



Using iperf as code to profile
sudo yum install iperf
sudo debuginfo-install iperf

Install oprofile
sudo yum install oprofile

Profile particular pid

[steve@steve-GA-880GMA-UD2H operf]$ pgrep iperf
2807
[steve@steve-GA-880GMA-UD2H operf]$ operf --pid 2807
operf: Press Ctl-c or 'kill -SIGINT 3924' to stop profiling
operf: Profiler started
^C
Profiling done.


[steve@steve-GA-880GMA-UD2H operf]$ opreport -l -dg  |less
CPU: AMD64 family10, speed 3200 MHz (estimated)
Counted CPU_CLK_UNHALTED events (Cycles outside of halt state) with a unit mask of 0x00 (No unit mask) count 100000
vma      samples  %        linenr info                 image name               symbol name
00408700 261      30.9242  Reporter.c:710              iperf                    reporter_handle_packet
...
  004089af 121      46.3602  Reporter.c:814

[steve@steve-GA-880GMA-UD2H operf]$ opannotate --source |less
 * Total samples for file : "/usr/src/debug/iperf-2.0.8/src/Reporter.c"
 * 
 *    402 47.6303
...
    809             } else if (reporthdr->report.mThreadMode == kMode_Server && (packet->packetLen > 0)) {
    810                 int bin;
    811                 // mean min max tests
    812                 stats->tcp.read.cntRead++;
    813                 stats->tcp.read.totcntRead++;
    814                 bin = (int)floor((packet->packetLen -1)/stats->tcp.read.binsize);
    815                 stats->tcp.read.bins[bin]++;
    816                 stats->tcp.read.totbins[bin]++;
    817             } else if (reporthdr->report.mThreadMode == kMode_Client) {


Profile system wide

[steve@steve-GA-880GMA-UD2H operf]$ sudo operf -s
operf: Press Ctl-c or 'kill -SIGINT 4003' to stop profiling
operf: Profiler started
^C* * * * WARNING: Profiling rate was throttled back by the kernel * * * *
The number of samples actually recorded is less than expected, but is
probably still statistically valid.  Decreasing the sampling rate is the
best option if you want to avoid throttling.

Profiling done.


[steve@steve-GA-880GMA-UD2H operf]$ opreport  |less

CPU: AMD64 family10, speed 3200 MHz (estimated)
Counted CPU_CLK_UNHALTED events (Cycles outside of halt state) with a unit mask of 0x00 (No unit mask) count 100000
CPU_CLK_UNHALT...|
  samples|      %|
------------------
   298879 83.0667 iperf
        CPU_CLK_UNHALT...|
          samples|      %|
        ------------------
           286580 95.8850 kallsyms
             6738  2.2544 nf_conntrack
             1279  0.4279 nf_nat_ipv4
              742  0.2483 libpthread-2.20.so
              740  0.2476 nf_conntrack_ipv4
              667  0.2232 iptable_mangle
              634  0.2121 iperf
              533  0.1783 [vdso] (tgid:2807 range:0x7fffd53fc000-0x7fffd53fdfff)

[steve@steve-GA-880GMA-UD2H operf]$ opreport -l -d -g /usr/bin/iperf -f |less
...
004092e0 293       0.0980  /usr/src/debug/iperf-2.0.8/src/Server.cpp:104 /usr/bin/iperf           Server::Run()
  004093d2 2         0.6826  /usr/src/debug/iperf-2.0.8/src/Server.cpp:182
  004093d9 5         1.7065  /usr/src/debug/iperf-2.0.8/src/Server.cpp:179
  004093ec 121      41.2969  /usr/src/debug/iperf-2.0.8/src/Server.cpp:182
  004093f5 2         0.6826  /usr/src/debug/iperf-2.0.8/src/Server.cpp:201
  00409416 12        4.0956  /usr/src/debug/iperf-2.0.8/src/Server.cpp:243
  0040941c 7         2.3891  /usr/src/debug/iperf-2.0.8/src/Server.cpp:244
  00409427 2         0.6826  /usr/src/debug/iperf-2.0.8/src/Server.cpp:248
  00409443 19        6.4846  /usr/src/debug/iperf-2.0.8/src/Server.cpp:178
  00409446 11        3.7543  /usr/src/debug/iperf-2.0.8/src/Server.cpp:178
  00409510 3         1.0239  /usr/src/debug/iperf-2.0.8/src/Server.cpp:259
  00409512 12        4.0956  /usr/src/debug/iperf-2.0.8/src/Server.cpp:259
  00409521 4         1.3652  /usr/src/debug/iperf-2.0.8/src/Server.cpp:260
  0040952d 1         0.3413  /usr/src/debug/iperf-2.0.8/src/Server.cpp:260
  00409538 4         1.3652  /usr/src/debug/iperf-2.0.8/src/Server.cpp:260
  0040953b 14        4.7782  /usr/src/debug/iperf-2.0.8/src/Server.cpp:201
  00409541 19        6.4846  /usr/src/debug/iperf-2.0.8/src/Server.cpp:201
  0040954a 4         1.3652  /usr/src/debug/iperf-2.0.8/src/Server.cpp:201
  004095bb 27        9.2150  /usr/src/debug/iperf-2.0.8/src/Server.cpp:242
  004095c4 24        8.1911  /usr/src/debug/iperf-2.0.8/src/Server.cpp:242

vi /usr/src/debug/iperf-2.0.8/src/Server.cpp
    177         gettimeofday( &watchdog, NULL );
    178         do {
    179             reportstruct->emptyreport=0;
    180 #if HAVE_DECL_SO_TIMESTAMP
    181             // perform read
    182             currLen = recvmsg( mSettings->mSock, &message, 0 );
    183             if (currLen <= 0) {
    184                 // Socket read timeout or read error
    185                 reportstruct->emptyreport=1;
    186                 gettimeofday( &(reportstruct->packetTime), NULL );


[steve@steve-GA-880GMA-UD2H operf]$ opannotate --source |less
...
/* 
 * Total samples for file : "/usr/src/debug/iperf-2.0.8/src/Server.cpp"
 * 
 *    293  0.0814
 */
...
    30  0.0083 :        do {
     5  0.0014 :            reportstruct->emptyreport=0;
               :#if HAVE_DECL_SO_TIMESTAMP
               :            // perform read 
   123  0.0342 :            currLen = recvmsg( mSettings->mSock, &message, 0 );
               :            if (currLen <= 0) {
               :                // Socket read timeout or read error
               :                reportstruct->emptyreport=1;
               :                gettimeofday( &(reportstruct->packetTime), NULL );




Sunday, January 5, 2014

Android development - Fedora 20 and Nexus 7

On Nexus 7

Follow this post to enable USB debugging on the Nexus 7

If you do not see "Developer Options", go into "About device" in Settings and tap on the "Build number" entry seven times, which will unlock "Developer Options".

Then, to get the ADB to recognize the device -

[steve@localhost ~]$ sudo Development/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb devices
List of devices attached
????????????    no permissions


Following this post -

[steve@localhost ~]$ lsusb |grep Nexus
Bus 002 Device 014: ID 18d1:4e42 Google Inc. Nexus 7 (debug)


Edit as below -

[steve@localhost ~]$ cat /etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"

[steve@localhost ~]$ sudo chmod a+r /etc/udev/rules.d/51-android.rules
 
Restart udev and adb server -
 
[steve@localhost ~]$ sudo systemctl restart systemd-udevd.service
[steve@localhost ~]$ sudo Development/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb kill-server
 
[steve@localhost ~]$ sudo Development/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached 
015d3f18d1281012 unauthorized

Authorize the PC on the device, and re-check -

[steve@localhost ~]$ sudo Development/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb devices
List of devices attached 
015d3f18d1281012 device

Monday, December 30, 2013

Compiling qemu on ubuntu 12.04

I hit a seemingly common issue running configure

ERROR: glib-2.12 required to compile QEMU

I tried the usual suspects -

~/qemu-1.7.0$ sudo apt-get install libglib2.0-dev
Reading package lists... Done
Building dependency tree    
Reading state information... Done
libglib2.0-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 72 not upgraded.

to no avail...
After poking through the configure script, I suspected a pkg-config issue.
The export below resolved my issue -

export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig

Monday, September 23, 2013

Headless install of Fedora 19

I need to do a headless install of fedora at work, and want to test the process at home first.
Approach is, use kvm/qemu on my ubuntu machine, and install fedora as a guest

virt-install \

 --name=guest1-fedora19-64 \
 --disk /var/lib/libvirt/images/guest1-fedora19-64.img,size=10 \
 --graphics none \
 --vcpus=1 --ram=2048 \
 --location=/home/steve/Downloads/Fedora-19-x86_64-DVD.iso \
 --network bridge=virbr0 \
 --os-type=linux \
 --os-variant=fedora16 \
 --extra-args="console=ttyS0,115200"


This works well, and anaconda gives me the choice of vnc or text based install

Trying text first -

Worked very smoothly.
After install, added tigervncserver, configured for lxde, disabled firewall, and was able to connect with vncviewer.


Reconnect after restart -

root@steve-GA-880GMA-UD2H:~# virsh list --inactive Id Name State ---------------------------------- - guest1-fedora19-64 shut off root@steve-GA-880GMA-UD2H:~# virsh start guest1-fedora19-64 Domain guest1-fedora19-64 started

root@steve-GA-880GMA-UD2H:~# virsh console guest1-fedora19-64
Connected to domain guest1-fedora19-64 Escape character is ^] [ 0.535212] 00:04: ttyS Fedora release 19 (Schrödinger’s Cat) Kernel 3.9.5-301.fc19.x86_64 on an x86_64 (ttyS0) localhost login:



Then vnc via anaconda

Network was configured automatically
vnc worked fine

and vnc via qemu/kvm

apt-get install virt-viewer

virt-install \

 --name=guest2-fedora19-64 \
 --disk /var/lib/libvirt/images/guest2-fedora19-64.img,size=10 \
 --graphics vnc \
 --vcpus=1 --ram=2048 \
 --location=/home/steve/Downloads/Fedora-19-x86_64-DVD.iso \
 --network bridge=virbr0 \
 --os-type=linux \
 --os-variant=fedora16

Also went smoothly.



UEFI & GPT

The real hardware had some UEFI support, and this led to some extra issues. Enough for another post, later...

Thursday, September 5, 2013

Migrating to grub2

Well, this was also relatively painless. Following the instructions from the FedUp page -

grub2-install /dev/sda
grub2-mkconfig -o /boot/grub2/grub.cfg

Got me a working grub2 system - however, my poor man's install option was lost.
This I corrected as below, adding it's entry in the file below

[steve@aspireone753 ~]$ sudo cat /etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

menuentry Fedora-17-x86_64-Live-Desktop {
  set root=(hd0,msdos8)
  linux /isolinux/vmlinuz0 root=UUID=B381-1423 rootfstype=auto rw liveimg quiet  rhgb
  initrd /isolinux/initrd0.img
}

and then re-running 
sudo grub2-mkconfig -o /boot/grub2/grub.cfg

There were some syntax changes from how it was in grub.conf ->

title Fedora-17-x86_64-Live-Desktop.is
  root (hd0,7)
  kernel /isolinux/vmlinuz0 root=UUID=B381-1423 rootfstype=auto rw liveimg quiet  rhgb
  initrd /isolinux/initrd0.img

Note especially the change in partition numbering.

Friday, August 30, 2013

Upgrade Fedora 17 to 19 using FedUp

Whilst a fairly time consuming process, it went very smoothly. The only minor issue I encountered was Chrome not working, but this and a simple solution was documented on the FedUp page.

Dare I tackle a grub update?

Also worth noting... my issue with

rfkill: WLAN soft blocked

occurring randomly some minutes after boot, although not solved... I seem to have found a remedy.
After installing the rfkill util, I'm able to re-enable via the command

rfkill unblock WLAN