Is there anyone who has used the memleak tool from bcc to profile userspace memory allocations? I've been trying to adapt it to do that, but it seems highly unreliable, ie the first batch of outstanding allocations seems fine when tested with a dummy C app, but usually in the following batches the entry disappears/increases artificially for some reason. My guess would be that the hash tables overflow because of the high frequency of allocations in the userspace? Has anyone managed to do mem userspace wide profiling with ebpf (or any other tool for that matter)?
Asked
Active
Viewed 507 times
0
-
Any chance you could post the source code of the dummy application? Alternatively, could you try running `tools/cobjnew.sh 1` to count the number of allocations per second? – pchaigno Aug 17 '18 at 08:15
-
Sure @pchaigno: https://pastebin.com/7pjvDGTu. It is a modified version of Sasha Goldshtein memleak that suits my needs. I've stripped quite a bit of overhead (got rid of the combined stacks bit since it had it's own hashtables and other minor stuff such as ebpf_printk's) and now I see that with intervals greater than 10-20 seconds, everything works as expected, it registers high frequency allocs. Could it be the case with lower intervals that by the time the python program wants to print stuff, the C code hasn't had the chance to finish? – Andrei Diaconu Aug 17 '18 at 09:05
-
@pchaigno Oh the dummy app, misread sorry: https://pastebin.com/eGbwZ5fe – Andrei Diaconu Aug 17 '18 at 09:34
-
So the vanilla version of memleak works for your dummy app.? – pchaigno Aug 17 '18 at 12:54
-
From what I have tested, the vanilla, when run with the pid of my dummy app, works fine for all batches (no data is lost, no data is erroneous). This is what made me think that something bad happens in kernel when runing the memleak userspace wide (that the high frequency allocs mess up something). – Andrei Diaconu Aug 17 '18 at 13:19
-
if you try to allocate data with the dummy app while memleak works, you will see what I mean by losing data (try allocating a lot of times in 5 seconds) – Andrei Diaconu Aug 17 '18 at 13:21