Showing posts with label kernel. Show all posts
Showing posts with label kernel. Show all posts

Tuesday, January 19, 2016

linux: how to activate and test kernel coredump property

[root@istanbul tmp]# sysctl -a | grep pattern
kernel.core_pattern = /tmp/core-%e-%s-%u-%g-%p-%t


test.c code:
#include <stdlib.h>
#include <time.h>
#include <stdio.h>

int main(int argc, char **argv)
{
    srand(time(NULL));
    int * nullpointer = NULL;
    printf("%d\n", *nullpointer);

    return 0;
}

# gcc -o testapp test.c

[root@istanbul tmp]# ./testapp
Segmentation fault
[root@istanbul tmp]# ls


no core file found.


[root@istanbul tmp]# ulimit -c
99999999


[root@istanbul tmp]# ls -alt /tmp/core-* | head -1
-rw------- 1 root root 241664 Jan 19 11:31 /tmp/core-testapp-11-0-0-2127-1453195860 


If you don't want to use testapp you can do it easily by using sleep command, too. 

sleep 10 &
killall -SIGSEGV sleep

Friday, January 15, 2016

linux: gettimeofday - VDSO Virtual Dynamic Shared Object

strace -c date
ciktisinda yaptigim incelemede gettimeofday syscall cagrisinin yapilmadigini gozlemledim sonrasinda yaptigim arastirmada VDSO mimarisi ile bir cozum uygulandigini gordum.

detaylar:
Many application workloads (especially databases and financial service applications) perform extremely frequent gettimeofday or similar time function calls. Optimizing the efficiency of this calls can provide major benefits.
A Virtual Dynamic Shared Object (VDSO), is a shared library that allows application in user space to perform some kernel actions without as much overhead as a system call. The VDSO is often used to provide fast access to the gettimeofday system call data.
Enabling the VDSO instructs the kernel to use its definition of the symbols in the VDSO, rather than the ones found in any user-space shared libraries, particularly the glibc. The effects of enabling the VDSO are system-wide - either all processes use it or none do.
When enabled, the VDSO overrides the glibc definition of gettimeofday with it's own. This removes the overhead of a system call, as the call is made direct to the kernel memory, rather than going through the glibc.

Wednesday, January 13, 2016

linux: Inter-Process Communication


The types of inter process communication are:
  1. Signals - Sent by other processes or the kernel to a specific process to indicate various conditions.
  2. Pipes - Unnamed pipes set up by the shell normally with the "|" character to route output from one program to the input of another.
  3. FIFOS - Named pipes operating on the basis of first data in, first data out.
  4. Message queues - Message queues are a mechanism set up to allow one or more processes to write messages that can be read by one or more other processes.
  5. Semaphores - Counters that are used to control access to shared resources. These counters are used as a locking mechanism to prevent more than one process from using the resource at a time.
  6. Shared memory - The mapping of a memory area to be shared by multiple processes.

linux: process state codes

The codes used are:
CodeMeaning
DUninterruptible sleep (usually IO)
RRunning or runnable (on run queue)
SInterruptible sleep (waiting for an event to complete)
TStopped, either by a job control signal or because it is being traced.
Wpaging (not valid since the 2.6.xx kernel)
Xdead (should never be seen)
ZDefunct (“zombie”) process, terminated but not reaped by its parent.
For BSD formats and when the stat keyword is used, additional characters may be displayed:
CodeMeaning
<high-priority (not nice to other users)
Nlow-priority (nice to other users)
Lhas pages locked into memory (for real-time and custom IO)
sis a session leader
lis multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+is in the foreground process group

D state occurs then the process is in uninterruptible sleep. This state is bad, because you can't do anything with the process in D state. 

Friday, January 8, 2016

linux: IRQBALANCE

In a computer, an interrupt request (or IRQ) is a hardware signal sent to the processor that temporarily stops a running program and allows a special program, an interrupt handler, to run instead. Hardware interrupts are used to handle events such as receiving data from a modem or network card, key presses, or mouse movements.

IRQBALANCE

irqbalance is a command line tool that distributes hardware interrupts across processors to improve system performance. It runs as a daemon by default, but can be run once only with the --oneshot option.

http://www.thegeekstuff.com/2014/01/linux-interrupts/

Scaling in the Linux Networking Stack

Scaling in the Linux Networking Stack

  RSS: Receive Side Scaling
  RPS: Receive Packet Steering
  RFS: Receive Flow Steering
  Accelerated Receive Flow Steering
  XPS: Transmit Packet Steering