

Two kernel mysteries and the most technical talk I've ever seen
source link: http://www.brendangregg.com/blog/2019-10-15/kernelrecipes-kernel-ftrace-internals.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Two kernel mysteries and the most technical talk I've ever seen
15 Oct 2019
If you start digging into Linux kernel internals, like function disassembly and profiling, you may run into two mysteries of kernel engineering, as I did:
- What is this "__fentry__" stuff at the start of every kernel function? Profiling? Why doesn't it massively slow down the Linux kernel?
- How can Ftrace instrument all kernel functions almost instantly, and with low overhead?
To show what I mean, here's a screenshot for (1) (I used ElfMaster's kdress to turn my vmlinuz into vmlinux):
# gdb ./vmlinux /proc/kcore [...] (gdb) disas schedule Dump of assembler code for function schedule: 0xffffffff819b6530 <+0>: callq 0xffffffff81a01cd0 <__fentry__> 0xffffffff819b6535 <+5>: push %rbp [...]
That's at the start of every kernel function on Linux. What the heck!
And for (2), using my perf-tools:
# ~/Git/perf-tools/bin/funccount '*' Tracing "*"... Ctrl-C to end. ^C FUNC COUNT aa_af_perm 1 [...truncated...] _raw_spin_lock 1811959 __mod_node_page_state 1856254 _cond_resched 1921320 rcu_all_qs 1924218 __accumulate_pelt_segments 2883418 decay_load 8684460 Ending tracing...
Despite this tracing every kernel function on my laptop, I didn't notice any slow down. How??
At a Linux conference in Düsseldorf, 2014, I saw a talk by kernel maintainer Steven Rostedt that answered both questions. It was and is the most technical talk I've ever seen. Unfortunately, it wasn't videoed. Fortunately, he just gave an updated version at Kernel Recipes in Paris, 2019, titled ftrace: Where modifying a running kernel all started. You can now learn the answers to these mysteries and answer many more questions about kernel internals. Steven covers things that aren't documented elsewhere.
The video is on youtube:
The slides are on slideshare:
Thanks to Steven for updating and delivering the talk, and Kernel Recipes organizers for sharing this and other talks on video. I'll need to come back to a future Kernel Recipes!
I'd also recommend watching:
Recommend
-
28
The Best Explanation of RAW Photography I’ve Ever Seen Matt Birchler | 15 Dec 2020 | 1 min read Understa...
-
15
Startup Learnings The Smartest Thing I've Ever Seen PayPal Do Feb 1, 2017 PayPal is one of those companies that we all love to hate. They work with money so we all feel about PayPal the way we sort of naturally feel ab...
-
17
Additional information has surfaced, explaining how the renowned hacking organization executed their massive cyberattack New worrying repercussions have emerged as a result of the large chain reacti...
-
17
-
10
Have you ever seen anyone "fake" their way into a software development position? Collapse
-
7
New Mac app lets you search everything you’ve ever seen or heard
-
7
12 Epic Flying Cars That Are Unlike Any We've Ever Seen
-
10
5 Of The Strangest Xbox Controllers We've Ever Seen
-
4
10 Strangest PlayStation Controllers We've Ever Seen
-
7
The 11 craziest and most advanced Apple shortcuts I’ve ever seenTreat these like mini-apps, not shortcutsPublished in
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK