]> sourceware.org Git - systemtap.git/commit
stp_utrace: remove kmem cache usage
authorSultan Alsawaf <sultan@openresty.com>
Tue, 19 Jan 2021 23:00:50 +0000 (15:00 -0800)
committerSultan Alsawaf <sultan@openresty.com>
Tue, 19 Jan 2021 23:00:50 +0000 (15:00 -0800)
commit23ef716aa40abe6473497f7d198003d0f199df58
tree2587b519d379ad0bbaf1483844475e3159402de2
parent1529bfce83b4fa1e3865572462a47568942d8056
stp_utrace: remove kmem cache usage

Some kernels appear to have trouble registering the same kmem_cache in
parallel, resulting in the following error as well as some other mayhem,
such as staprun hangs and kernel freezes:
sysfs: cannot create duplicate filename '/kernel/slab/:0000144'

This occurs when stap modules are registered in parallel with one
another.

The justification for using kmem caches in utrace is that the utrace
struct sizes are not powers of 2, and a lot of them can be allocated, so
leaving them to the kernel's default kmem caches can waste quite a bit
of memory. However, this is only a problem for the utrace struct, and
not really the utrace_engine struct, as the utrace_engine struct is 56
bytes on 64-bit, and can be allocated by the kernel's internal 64-byte
kmem cache with only 8 bytes wasted per allocation.

The same cannot be said for the utrace struct, since it's 144 bytes. It
would therefore be allocated from the 256-byte kmem cache, resulting in
112 bytes wasted per allocation. We can remedy this by reusing existing
memory in the struct for the 16-byte RCU callback head, bringing the
overall struct size down to 128 bytes and thus eliminating the need for
a kmem cache. This is safe because the reused struct members are no
longer used once the struct is ready to be freed.

This also eliminates a pesky rcu_barrier() we no longer required.
runtime/stp_utrace.c
This page took 0.026439 seconds and 5 git commands to generate.