google / kernel-sanitizers

Linux Kernel Sanitizers, fast bug-detectors for the Linux kernel
https://google.github.io/kernel-sanitizers/
442 stars 87 forks source link

kfence: Implement static key based sampling method #91

Closed melver closed 4 years ago

melver commented 4 years ago

This implements a sampling based method using static keys aka. jump labels. Jump labels use code patching to turn on or off branches at runtime. Typically the cost of enabling or disabling is high due to IPIs, however, even with the default sample rate of 100ms, no measurable performance degradation can be observed.

Doing a simple sysbench run shows that the overhead is negligible and no performance difference to the non-KFENCE version is noticable. More detailed results from sysbench run here: https://github.com/google/kasan/issues/72

My proposal is that we make this variant the main sampling method of interest, and if it survives further testing, remove all other sampling methods in favor of simply having this one. This should hopefully also get us closer to the preparation of a patch series for LKML.