Mehdi Akiki

Posts tagged "from source to process"

  • Published on

    Investigation · Part 15 of 20 · From source to a running process

    When malloc Asks the Kernel for Memory: brk and mmap

    The usual rule says malloc uses brk below 128 KiB and mmap above. I traced seven allocations and a growing Rust Vec with strace: a 129 KiB block came from the heap, a freed 1 MiB block moved the limit, and Vec growth became a chain of mremap calls.
  • Published on

    Investigation · Part 14 of 20 · From source to a running process

    What fork Really Copies: Copy-on-Write Measured

    fork of a process with 2 GiB of touched memory took 16 ms here, because it copies page tables and not memory. I measured the copies that come later when the child writes, what reading costs, what happens to huge pages, and why posix_spawn stays under a millisecond.
  • Published on

    Investigation · Part 13 of 20 · From source to a running process

    Why the First Touch of Memory Is Slow: Demand Paging Measured

    Mapping 1 GiB takes no time, the first write to each page costs about a microsecond, and the second write 16 nanoseconds. I measured faults with and without huge pages, MAP_POPULATE, calloc and Rust vectors, and twice the compiler removed the work I wanted to measure.
  • Published on

    Investigation · Part 12 of 20 · From source to a running process

    Reading /proc/self/maps Line by Line

    I printed the memory map of a small C program and of a Rust program and explained every column and every line, then watched the addresses move with ASLR, stop moving with setarch -R, and go back to 0x400000 with -no-pie.
  • Published on

    Investigation · Part 11 of 20 · From source to a running process

    What Is on the Stack When a Process Starts: argv, envp and auxv

    Before the first instruction, the kernel writes argc, argv, envp and 22 pairs of numbers for the loader at the top of the stack. I read them from a C program, compared them with LD_SHOW_AUXV, and saw 4,000 bytes of environment move every local variable of main.