1 / 10

PLUG May 2013

PLUG May 2013. Porting Linux Applications to Power Architecture Part 1 - Introduction. What is porting?. X86 has become the defacto standard architecture Most code (including Linux code) is developed for the x86 platform The proper way to write apps is to make them architecture agnostic

skule
Download Presentation

PLUG May 2013

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PLUG May 2013 Porting Linux Applications to Power Architecture Part 1 - Introduction

  2. What is porting? • X86 has become the defacto standard architecture • Most code (including Linux code) is developed for the x86 platform • The proper way to write apps is to make them architecture agnostic • This is easy for Apps but rarely practiced • There is a necessity to migrate the code it to other platforms. Essentially recompile it to run on the new platform architecture

  3. Factors involved in Porting – x86 to Power • HW • Big endian vs Little endian • CISC vs RISC • Instruction width • Chip level design • 32b vs 64b • Implementation • Data type size (int and long difference in 32 vs 64) • EABI • Libraries • Good code is written in a Architecture transparent manner

  4. Porting Kernel/drivers vsUserspace Apps • Porting ranges from a very simple recompile to the worst case • Simplest is independent code using standard include libraries • Little more complicated when special dependencies are present • Harder when hardware is involved (e.g. kernel, drivers) . Includes endian conversion, structure repacking, messages (between hardware and CPU) • Hardest when assembly code present

  5. Tools • GCC • GlibC, binutils • Other tools • Other Scripting languages : Shell, Perl, python, • Freescaletoolchain : powerpc-linux-gnu-gcc • Part of Yocto SDK, or get through repo build-essential • IBM Tool Chain : https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/W51a7ffcf4dfd_4b40_9d82_446ebc23c550/page/IBM%20Advance%20Toolchain%20for%20PowerLinux%20Documentation • Clang/LLVM • Git, Hg, SVN

  6. Cross vs Native compile • Build can be native i.e. build on the same platform as you are executing • Or cross-compile where you build on a platform that is different than the platform you execute on • Using the tools listed in the previous page. sgy@sgy-ThinkPad-R500:~$ gcchello.c -o hello.x86 sgy@sgy-ThinkPad-R500:~$ file hello.x86 hello.x86: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xffad75b6bb6432582e7a7cc211e225639a14cf85, not stripped sgy@sgy-ThinkPad-R500:~$ powerpc-linux-gnu-gcchello.c –o hello.ppc sgy@sgy-ThinkPad-R500:~$ file hello.ppc hello.ppc: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0xe80c0aefeeeece9e7ec150a0a45f0ac25ad8a060, not stripped

  7. Ubuntu build • http://qa.ubuntuwire.org/ftbfs/ • buildlog • Tracing failure • Fixing

  8. Debugging Applications • grep /web search • lsof • strace • gdb • printf • Kernel debug

  9. lsof • list the information about the files (which includes libraries, pipes, sockets, devices….)that are opened by various processes • Very useful for debugging • Flags to search by user, pid, ... root@sgy-ThinkPad-R500:~$ lsof-p 1190 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME irqbalanc 1190 root cwd DIR 8,1 4096 2 / irqbalanc 1190 root rtd DIR 8,1 4096 2 / irqbalanc 1190 root txt REG 8,1 43068 2621866 /usr/sbin/irqbalance irqbalanc 1190 root mem REG 8,1 34844 526097 /lib/powerpc-linux-gnu/librt-2.16.so irqbalanc 1190 root mem REG 8,1 131217 526095 /lib/powerpc-linux-gnu/libpthread-2.16.so irqbalanc 1190 root mem REG 8,1 239092 525164 /lib/powerpc-linux-gnu/libpcre.so.3.13.1 irqbalanc 1190 root mem REG 8,1 1537380 525433 /lib/powerpc-linux-gnu/libc-2.16.so irqbalanc 1190 root mem REG 8,1 42832 2621865 /usr/lib/libnuma.so.1 irqbalanc 1190 root mem REG 8,1 706852 526082 /lib/powerpc-linux-gnu/libm-2.16.so irqbalanc 1190 root mem REG 8,1 1113248 524322 /lib/powerpc-linux-gnu/libglib-2.0.so.0.3504.0 irqbalanc 1190 root mem REG 8,1 25860 2622193 /usr/lib/libcap-ng.so.0.0.0 irqbalanc 1190 root mem REG 8,1 142596 524503 /lib/powerpc-linux-gnu/ld-2.16.so irqbalanc 1190 root 0u CHR 1,3 0t0 1029 /dev/null irqbalanc 1190 root 1u CHR 1,3 0t0 1029 /dev/null irqbalanc 1190 root 2u CHR 1,3 0t0 1029 /dev/null

  10. strace • Run a command and display its system calls, so you can see exactly what the program is doing until it exits • Can be used for debugging and performance tuning root@sgy-ThinkPad-R500:~$ stracels execve("/bin/ls", ["ls"], [/* 18 vars */]) = 0 brk(0) = 0x102b3000 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x48021000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 fstat64(3, {st_mode=S_IFREG|0644, st_size=41633, ...}) = 0 mmap(NULL, 41633, PROT_READ, MAP_PRIVATE, 3, 0) = 0x48022000 close(3) = 0 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) open("/lib/powerpc-linux-gnu/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3 read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0\0P\300\0\0\0004"..., 512) = 512 fstat64(3, {st_mode=S_IFREG|0644, st_size=137164, ...}) = 0 mmap(0xffce000, 138072, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffce000 mmap(0xffee000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x20000) = 0xffee000 close(3) = 0 open("/proc/filesystems", O_RDONLY|O_LARGEFILE) = 3 fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0 = 0 ioctl(1, TIOCGWINSZ, {ws_row=57, ws_col=132, ws_xpixel=961, ws_ypixel=860}) = 0 openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3 getdents64(3, /* 12 entries */, 32768) = 368 getdents64(3, /* 0 entries */, 32768) = 0 close(3) = 0 fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0 close(2) = 0 exit_group(0) = ?

More Related