![]() This looks like what happens when the clock_gettime system call runs. Interested, you can see all 18,000 lines here.ġ8,000 lines is a lot so here are some interesting excerpts. Sudo trace-cmd report printed out 18,000 lines of output. Sudo trace-cmd record -p function -P 25314 # record for PID 25314 Hugo’s PID on my computer right now is 25314, so I recorded all the kernel functions with: sudo trace-cmd record -help # I read the help! I use a static site generatorĬalled Hugo. Okay, but just seeing one function is kind of boring! Let’s say I want to knowĮverything that’s happening for one program. Cool! We have done our first ftrace! next ftrace trick: let’s trace a process! See that we traced for about 1.5 seconds and in that time Chrome had about 500 This is neat – it shows me the process name (chrome), process ID (15144), CPU (000), and function that got traced.īy looking at the whole report, ( sudo trace-cmd report | grep chrome) I can Awesome! It created a 2.5MBįile called trace.dat. I ran it for a few seconds and then hit Ctrl+C. Let’s start trace-cmd and make it trace the do_page_fault function! $ sudo trace-cmd record -p function -l do_page_fault The kernel needs to give the application physical memory to use. Tries to actually write to memory that it allocated, there’s a page fault and ![]() When Linux allocates memory, it often does it lazily (“you weren’t really Easy enough.įor this first ftrace demo, I decided I wanted to know when my kernel was handling a page fault. getting started with trace-cmd: let’s trace just one functionįirst, I needed to install trace-cmd with sudo apt-get install trace-cmd. Trace-cmd on LWN at trace-cmd: A front-end for Ftrace. Normal program with command line arguments. So there is an easier-to-use interface called trace-cmd!!! trace-cmd is a Luckily, team ftrace also thought this interface wasn’t that user friendly and This filesystem interface to the tracing system (“put values in these magicįiles and things will happen”) seems theoretically possible to use but really Starts out by telling you to cd /sys/kernel/debug/tracing and then do variousįor me this is way too annoying – a simple example of using ftrace this way is something like cd /sys/kernel/debug/tracing If you read Debugging the kernel using Ftrace it ![]() Unlike strace and perf, ftrace isn’t a program exactly – you don’t Harder to use than strace) but that it’s worth knowing about. I think ftrace is a bit of a niche tool (it’s definitely less broadly useful and Involved (in that case, it was the virtual memory system)! Understand better what was happening in the kernel and what systems were Looking at what functions were being called helped us I do! For example this week at work we had a program that was frozen and stuck I don’t read the kernel source code very often when debugging, but occasionally Problem, and you’ve gotten to the point where you’re staring at the source codeįor your kernel version and wondering what exactly is going on. Why would you want to do that? Well, suppose you’re debugging a weird I’m supposed to run a workshop tomorrow where I talkĪbout ftrace, so today is the day we talk about it! what’s ftrace?įtrace is a Linux kernel feature that lets you trace Linux kernel functionĬalls. ![]() I’ve known that ftrace exists for about 2.5 years now, but hadn’t gotten around So you might be able to use it even if you’re debugging an older system! Here’s the earliest documentation I found with some quick Gooogling. What could be more exciting than a newīetter yet, ftrace isn’t new! It’s been around since Linux kernel 2.6, or about 2008. Hello! Today we’re going to talk about a debugging tool we haven’t talked about
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |