Re: [RFC PATCH 00/30] Code tagging framework and applications
From: Suren Baghdasaryan <surenb@google.com>
Date: 2022-09-01 23:36:42
Also in:
io-uring, linux-arch, linux-bcache, linux-iommu, linux-mm, lkml, xen-devel
On Thu, Sep 1, 2022 at 3:54 PM Roman Gushchin [off-list ref] wrote:
On Thu, Sep 01, 2022 at 06:37:20PM -0400, Kent Overstreet wrote:quoted
On Thu, Sep 01, 2022 at 03:27:27PM -0700, Roman Gushchin wrote:quoted
On Wed, Aug 31, 2022 at 01:56:08PM -0700, Yosry Ahmed wrote:quoted
This is very interesting work! Do you have any data about the overhead this introduces, especially in a production environment? I am especially interested in memory allocations tracking and detecting leaks.+1 I think the question whether it indeed can be always turned on in the production or not is the main one. If not, the advantage over ftrace/bpf/... is not that obvious. Otherwise it will be indeed a VERY useful thing.Low enough overhead to run in production was my primary design goal. Stats are kept in a struct that's defined at the callsite. So this adds _no_ pointer chasing to the allocation path, unless we've switch to percpu counters at that callsite (see the lazy percpu counters patch), where we need to deref one percpu pointer to save an atomic. Then we need to stash a pointer to the alloc_tag, so that kfree() can find it. For slab allocations this uses the same storage area as memcg, so for allocations that are using that we won't be touching any additional cachelines. (I wanted the pointer to the alloc_tag to be stored inline with the allocation, but that would've caused alignment difficulties). Then there's a pointer deref introduced to the kfree() path, to get back to the original alloc_tag and subtract the allocation from that callsite. That one won't be free, and with percpu counters we've got another dependent load too - hmm, it might be worth benchmarking with just atomics, skipping the percpu counters. So the overhead won't be zero, I expect it'll show up in some synthetic benchmarks, but yes I do definitely expect this to be worth enabling in production in many scenarios.I'm somewhat sceptical, but I usually am. And in this case I'll be really happy to be wrong. On a bright side, maybe most of the overhead will come from few allocations, so an option to explicitly exclude them will do the trick. I'd suggest to run something like iperf on a fast hardware. And maybe some io_uring stuff too. These are two places which were historically most sensitive to the (kernel) memory accounting speed.
Thanks for the suggestions, Roman. I'll see how I can get this done. I'll have to find someone with access to fast hardware (Android is not great for that) and backporting the patchset to the supported kernel version. Will do my best. Thanks, Suren.
Thanks! -- To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com.