Wednesday, February 26, 2014

Linux Storage Terminology

AFS:  Andrew distributed file system
ATA: Advanced Technology Attachment
ATAoE: ATA over Ethernet
BTRFS:  Butter FS
CAS: content-addressable storage
Ceph:
CIFS: Common Internet File System
CRC:  cyclic redundancy check
DAP: Data Access Protocol
DAS: Direct-attached storage
DIF: data integrity field
exofs:Extended Object File System
ext3: third extended file system
ext4: fourth extended file system
FC: Fibre Channel
FCoE: Fibre Channel over Ethernet
FCS: fixed-content storage
FUSE: Filesystem in Userspace
JFFS2: Journaling Flash File System version 2
GPFS:  General Parallel File System
HPC: high-performance computing
IDE: Integrated Drive Electronics
iSCSI: Internet SCSI
ISO: nternational Organization for Standardization
LBA: logical block addressing
LUN: Logical Unit Number
Lustre:  Linux clUSTER
LVM: Logical Volume Manage
NAS: Network-attached storage
NFS: Network File System
OSD: Object Storage Device
pNFS:  Parallel NFS
RAID: redundant array of independent disks
RDMA: remote direct memory access
RPC: remote procedure call
SAN: Storage area networks
SATA: Serial ATA
SAS: Serial attached SCSI
SCSI: Small Computer System Interface
SMB:  Server Message Block
SRP: SCSI RDMA Protocol
SSA: Serial Storage Architecture
SSD: solid-state disk
eSATA: external SATA
UBIFS: Unsorted Block Image File System
UDP: Universal Datagram Protocol
USB: Universal Serial Bus
VFS: virtual file system switch
XDR: external data representation
xHCI: Extensible Host Controller Interface
XIP: Execute-in-place
YAFFS2: Yet Another Flash File System version 2
ZFS: Zettabyte File System

Tuesday, February 25, 2014

GPIO Interrupts Routing in X86

 Interrupt routing on X86 is very complicated.
 On X86, the 1s 16 GPIO pins can be configured as interrupt.
 The routing path for GPIO interrupt is:
 GPIO-->ACPI(GPE)-->IRQ9

Linux# ls /sys/firmware/acpi/interrupts/
error        gpe02  gpe0A  gpe12  gpe1A  gpe22  gpe2A  gpe32  gpe3A
ff_gbl_lock  gpe03  gpe0B  gpe13  gpe1B  gpe23  gpe2B  gpe33  gpe3B
ff_pmtimer   gpe04  gpe0C  gpe14  gpe1C  gpe24  gpe2C  gpe34  gpe3C
ff_pwr_btn   gpe05  gpe0D  gpe15  gpe1D  gpe25  gpe2D  gpe35  gpe3D
ff_rt_clk    gpe06  gpe0E  gpe16  gpe1E  gpe26  gpe2E  gpe36  gpe3E
ff_slp_btn   gpe07  gpe0F  gpe17  gpe1F  gpe27  gpe2F  gpe37  gpe3F
gpe00        gpe08  gpe10  gpe18  gpe20  gpe28  gpe30  gpe38  gpe_all
gpe01        gpe09  gpe11  gpe19  gpe21  gpe29  gpe31  gpe39  sci

Reading Materials:

PCI Interrupts  

PCI Interrupts for x86 Machines under FreeBSD

User Space Device Driver 

 

 

Wednesday, October 2, 2013

Linux Scheduler

See link:
  1. http://www.ibm.com/developerworks/linux/library/l-scheduler/
  2. http://en.wikipedia.org/wiki/Completely_Fair_Scheduler
  3. http://www.ibm.com/developerworks/linux/library/l-completely-fair-scheduler/

3 Linux Scheduling Policies:
  •  SCHED_OTHER/SCHED_NORMAL Time-based policy with time slices
  • SCHED_FIFO Priority-based policy
  • SCHED_RR Priority-based policy with time slices

Linux scheduler queues:
  •      runqueue
  •      wait_queue or
  •      red-black tree
Linux task states :
  • TASK_RUNNING(runqueue)
  • TASK_INTERRUPTIBLE(wait_queue)
  • TASK_UNINTERRUPTIBLE(wait_queue)
  • TASK_STOPPED
  • TASK_ZOMBIE
Linux Scheduling Algorithm Evolution :
  • O(N)
  • O(1)
  • Completely Fair Scheduler (CFS)

Threads vs Process on Linux

See the following links:
http://www.samba.org/~tridge/talks/threads.pdf
http://www.mulix.org/lectures/kernel_workshop_mar_2004/things.pdf
http://en.wikipedia.org/wiki/Thread_%28computing%29

Thread has its own stack, its own register set/context. User space threads or kernel space threads?
The context of a thread is the register set, including the stack pointer.
Context switch between threads includes saving registers, restore registers only, while MMU context(Page table) & TLB stays.

Process has its own virtual address space, and has at least one thread; all threads within it share the parent process's virtual address space.
The context of a process includes state, priority, signal info, process id, and a pointer to thread.
Context switch between processes needs a switch of virtual address space, including cache and TLB flushing, MMU context switching, and thread switching.

Both thread and process 's creation in user space went to the same system call(clone) in the kernel.
Linux implements 1:1 model.
Keep in mind, TLB and MMU context is per-CPU on Linux.

Tuesday, October 1, 2013

vmlinux vs vmlinuz vs (b)zImage vs uImage

See the wiki link
  • vmlinux -- compiled from source 
  • vmlinuz -- compressed from vmlinux
  • (b)zImage -- final binary image includes: bootloader, uncompress vmlinuz, load vmlinux, ramdisk
  • uImage -- final image for U-boot
  • # readelf -h /boot/vmlinuz-2.6.18-238.el5
    ELF Header:
      Magic:   7f 45 4c 46 02 01 01 ff eb 3d 00 00 00 00 00 00
      Class:                             ELF64
      Data:                              2's complement, little endian
      Version:                           1 (current)
      OS/ABI:                            Standalone App
      ABI Version:                       235
      Type:                              DYN (Shared object file)
      Machine:                           Advanced Micro Devices X86-64
      Version:                           0x1
      Entry point address:               0x100
      Start of program headers:          80 (bytes into file)
      Start of section headers:          0 (bytes into file)
      Flags:                             0x0
      Size of this header:               64 (bytes)
      Size of program headers:           56 (bytes)
      Number of program headers:         2
      Size of section headers:           64 (bytes)
      Number of section headers:         0
      Section header string table index: 0
  • # dd if=uImage of=zImage bs=64 skip=1
    42667+1 records in
    42667+1 records out
  • # hexdump -v uImage.header
    0000000 0527 5619 4713 7f79 2f4d e379 2900 ceaa
    0000010 0000 0000 0000 0000 b9d8 534e 6ab9 e05b
    0000020 a06b ec5b 1885 0898 80f2 6f74 0705 0102
    0000030 694c 756e 2d78 2e32 2e36 3031 6d5f 6c76


Saturday, September 14, 2013

NVRAM usage in Emebedded System

Refer to: Non-volatile random-access memory

NVRAM can be replaced by SRAM with battery . 

In Linux, mostly NVRAM is statically mapped to memory space.

MTD partition is built on top of it, which can be used for sequential

reading/writing or block device simulation  for filesystem. 

To verify data integrity on NVRAM:

bash-3.2# flash_eraseall -j /dev/mtd3
Erasing 16 Kibyte @ 1fc000 -- 99 % complete. Cleanmarker written at 1fc000.

bash-3.2# mkdir /mnt/flash

bash-3.2# mount -t jffs2 /dev/mtdblock3 /mnt/flash

bash-3.2# ls -al test.img
-rw-rw-rw- 1 root root 262144 Jan  9 00:34 test.img
bash-3.2# cp test.img /mnt/flash/

bash-3.2# md5sum /mnt/flash/test.img
ec87a838931d4d5d2e94a04644788a55  /mnt/flash/test.img