=== A low-cost conditional execution mechanism Links: + link:https://wiki.freebsd.org/SummerOfCode2024Projects/ZeroCostConditionalExecutionMechanism[FreeBSD wiki] URL: https://wiki.freebsd.org/SummerOfCode2024Projects/ZeroCostConditionalExecutionMechanism[] + Contact: Marko Vlaić Contact: Bojan Novković (mentor) This project aims to implement a low-cost conditional execution mechanism, similar to the `static_key` interface in Linux. The current working name is `zcond`, as in zero-cost conditional. The idea is to reduce the overhead of rarely used features in performance sensitive kernel code paths. Specifically, code blocks of the following, simple structure, are targeted: [source, c] ---- if(some_global_flag == true) { do_some_additional_task(); } ---- A block like this can cause performance overhead in a frequently executed piece of code. The motivating use case for the mechanism is tracing (as outlined here in the link:https://wiki.freebsd.org/SummerOfCodeIdeas#Unified_kernel_tracing_interface[wiki]), but the project will identify more areas where this mechanism could be applied. The backbone of the mechanism is runtime instruction hot patching, making it highly architecture dependent. Great care has to be given to security, because kernel instructions are overwritten at runtime. More details and some implementation ideas can be found in the project proposal on the link:https://wiki.freebsd.org/SummerOfCode2024Projects/ZeroCostConditionalExecutionMechanism[project wiki page]. More documents describing the implementation and design decisions will be produced, as the project moves along. The goal of the project is to produce a working implementation of the mechanism for the x86-64 architecture. It will then be applied to an existing piece of kernel code and benchmarked. If the benchmark results come out positive, it will be ported to other architectures. This project is a part of the link:https://summerofcode.withgoogle.com/[Google Summer of Code 2024.]. The project is still in its early stages, but any feedback would be highly appreciated. ==== Help wanted * General feedback on the mechanism, API and implementation * More use cases besides tracing are welcome * Code review * Name suggestions Sponsor: Google LLC (GSoC 2024)