Uprobes: userspace probes >= Linux 3.5

https://lwn.net/Articles/499190/

https://github.com/andreoli/fulltrace

Prominent features in Linux 3.5

1.1. ext4 metadata checksums

Modern filesystems such as ZFS and Btrfs have proved that ensuring the integrity of the filesystem using checksums is a valuable feature. Ext4 has added the ability to store checksums of various metadata fields. Every time a metadata field is read, the checksum of the read data is compared with the stored checksums, if they are different it means that the medata is corrupted (note that this feature doesn‘t cover data, only the internal metadata structures, and it doesn‘t have "self-healing" capabilities). The amount of code added to implement this feature is: 1659 insertions(+), 162 deletions(-).

Any ext4 filesystem can be upgraded to use checksums using the "tune2fs -O metadata_csum" command, or "mkfs -O metadata_csum" at creation time. Once this feature is enabled in a filesystem, older kernels with no checksum support will only be able to mount it in read-only mode.

As far as performance impact goes, it shouldn‘t be noticeable for common desktop and server workloads. A mail server ffsb simulation show nearly no change. On a test doing only file creation and deletion and extent tree modifications, a performance drop of about 20 percent was measured. However, it‘s a workload very heavily oriented towards metadata, in most real-world workloads metadata is usually a small fraction of total IO, so unless your workload is metadata-oriented, the cost of enabling this feature should be negligible.

Recommended LWN article: "Improving ext4: bigalloc, inline data, and metadata checksums"

Implementation details: Ext4 Metadata checksums

Code: (commit 123456789101112131415161718192021222324

1.2. Uprobes: userspace probes

Uprobes, the user-space counterpart of kprobes, enables to place performance probes in any memory address of a user application, and collect debugging and performance information non-disruptively, which can be used to find performance problems. These probes can be placed dynamically in a running process, there is no need to restart the program or modify the binaries. The probes are usually managed with a instrumentation application, such as perf probe, systemtap or LTTng.

A sample usage of uprobes with perf could be to profile libc‘s malloc() calls:

  • $ perf probe -x /lib64/libc.so.6 malloc -> Added new event: probe_libc:malloc (on 0x7eac0)

A probe has been created. Now, let‘s record the global usage of malloc across all the system during 1 second:

  • $ perf record -e probe_libc:malloc -agR sleep 1

Now you can watch the results with the TUI interface doing "$ perf report", or watch a plain text output without the call graph info in the stdio output with "$ perf report -g flat --stdio"

If you don‘t know which function you want to probe, you can get a list of probe-able funcions in libraries and executables using the -F parameter, for example: "$ perf probe -F -x /lib64/libc.so.6" or "$ perf probe -F -x /bin/zsh". You can use multiple probes as well and mix them with kprobes and regular PMU events or kernel tracepoints.

The uprobes code is one of the longest standing out-of-the-tree patches. It originates from SystemTap and has been included for years in Fedora and RHEL kernels.

Recommended LWN article: Uprobes in 3.5

Code: (commit 123456789101112131415)

时间: 2024-10-18 13:07:17

Uprobes: userspace probes >= Linux 3.5的相关文章

Linux ALSA 音频系统:物理链路篇

1. Overview 硬件平台及软件版本: Kernel - 3.4.5 SoC - Samsung exynos CODEC - WM8994 Machine - goni_wm8994 Userspace - tinyalsa Linux ALSA 音频系统架构大致如下: +--------+ +--------+ +--------+ |tinyplay| |tinycap | |tinymix | +--------+ +--------+ +--------+ | ^ ^ V | V

linux 并发 RCU

What is RCU, Fundamentally? https://lwn.net/Articles/262464/ If you can fill the unforgiving secondwith sixty minutes worth of distance run,“Highly scalable” your code will be reckoned,And—which is more—you'll have parallel fun! With apologies to Rud

内核调试神器SystemTap — 更多功能与原理(三)

a linux trace/probe tool. 官网:https://sourceware.org/systemtap/ 用户空间 SystemTap探测用户空间程序需要utrace的支持,3.5以上的内核版本默认支持. 对于3.5以下的内核版本,需要自己打相关补丁. 更多信息:http://sourceware.org/systemtap/wiki/utrace 需要: debugging information for the named program utrace support i

内存管理概述、内存分配与释放、地址映射机制(mm_struct, vm_area_struct)、malloc/free 的实现

http://blog.csdn.net/pi9nc/article/details/23334659 注:本分类下文章大多整理自<深入分析linux内核源代码>一书,另有参考其他一些资料如<linux内核完全剖析>.<linux c 编程一站式学习>等,只是为了更好地理清系统编程和网络编程中的一些概念性问题,并没有深入地阅读分析源码,我也是草草翻过这本书,请有兴趣的朋友自己参考相关资料.此书出版较早,分析的版本为2.4.16,故出现的一些概念可能跟最新版本内核不同.

kubernetes service 和 ingress

一 总述 1 service 作用 POD 中运行的容器存在动态.弹性的变化(容器的重启IP地址会变化),因此便产生了service,其资源为此类POD对象提供一个固定.统一的访问接口及负载均衡能力,并借助DNS系统的服务发现功能,解决客户端发现容器难得问题 service 和POD 对象的IP地址在集群内部可达,但集群外部用户无法接入服务,解决的思路有:1 在POD上做端口暴露(hostPort)2 在工作节点上公用网络名称空间(hostNetwork)3 使用service 的NodePor

Linux Perf Probes for Oracle Tracing

Luca Canali on 21 Jan 2016 Topic: this post is about Linux perf and uprobes for tracing and profiling Oracle workloads for advanced troubleshooting. Context The recent progress and maturity of some of the Linux dynamic tracing tools has raised intere

[中英对照]User-Space Device Drivers in Linux: A First Look

如对Linux用户态驱动程序开发有兴趣,请阅读本文,否则请飘过. User-Space Device Drivers in Linux: A First Look | 初识Linux用户态设备驱动程序 User-Space Device Drivers in Linux: A First Look Mats Liljegren Senior Software Architect Device drivers in Linux are traditionally run in kernel spa

Memory Allocation API In Linux Kernel &amp;&amp; Linux Userspace、kmalloc vmalloc Difference、Kernel Large Section Memory Allocation

目录 1. 内核态(ring0)内存申请和用户态(ring3)内存申请 2. 内核态(ring0)内存申请:kmalloc/kfree.vmalloc/vfree 3. 用户态(ring3)内存申请:malloc/free 4. 内核内存申请原则 5. 内核中分配物理地址连续的大段内存 1. 内核态(ring0)内存申请和用户态(ring3)内存申请  0x1: 差异点 在内核中申请内存和在用户空间中申请内存不同,有以下因素引起了复杂性,包括 1. 内核的虚拟和物理地址被限制到1GB 2. 内核

Linux UserSpace Back-Door、Rootkit Attack And Defensive Tchnology

catalog 0. 引言 1. Pam后门 2. SSH后门 3. Hijacking SSH 4. Hijacking SSH By Setup A Tunnel Which Allows Multiple Sessions Over The Same SSH Connection Without Re-Authentication 5. Hijacking Active SSH Screen Sessions 0. 引言 0x1: 安全攻防观点 1. Know Your Enemy : K