libxtc 0.4.0
Async concurrency for C: Tokio + Seastar + BEAM, in one library
Loading...
Searching...
No Matches
os_tuning.h
1/*-
2 * Copyright (c) 2026, The XTC Project
3 * Use of this source code is governed by the ISC License.
4 *
5 * src/inc/os_tuning.h
6 * Power/kernel-tuning advisor surface (PLAN.md 19.21).
7 */
8
9#ifndef XTC_OS_TUNING_H
10#define XTC_OS_TUNING_H
11
12#include "xtc_export.h"
13
14/*
15 * Run a battery of cheap, read-only host-tuning probes and log one
16 * NOTICE-level (XTC_LOG_INFO, the closest level this logger has) line
17 * per probe that is NOT already in its recommended state. Silent on
18 * a well-tuned host. Meaningful only on Linux; a no-op everywhere
19 * else. Never writes to /proc or /sys. A probe whose source file is
20 * missing or unreadable (absent on this kernel, or hidden inside a
21 * container) is skipped silently -- that is "unknown", not "a
22 * finding". Safe to call more than once (each call re-probes); meant
23 * to be called once, at startup.
24 *
25 * INTERNAL: this is the __os_* implementation. The public entry is
26 * xtc_tuning_check() (xtc_stats.h), a thin wrapper -- so consumers on
27 * the xtc_exec / xtc_loop path can reach the advisor. Not exported
28 * (no XTC_API): the __os_* symbol stays library-local per the ABI
29 * gate; xtc_app_start and stats.c's xtc_tuning_check call it directly.
30 */
31void __os_tuning_check(void);
32
33#if defined(__linux__)
34/*
35 * Internal / test hooks: point each probe at a fixture file instead
36 * of the real /sys or /proc path, so the parsing + threshold logic is
37 * unit-testable without root or a real kernel-tuning knob. NULL (the
38 * default) restores the real path. Not part of the stable API.
39 */
40void __xtc_os_tuning_governor_path_override(const char *path);
41void __xtc_os_tuning_pstate_status_path_override(const char *path);
42void __xtc_os_tuning_cmdline_path_override(const char *path);
43void __xtc_os_tuning_thp_path_override(const char *path);
44void __xtc_os_tuning_swappiness_path_override(const char *path);
45void __xtc_os_tuning_autogroup_path_override(const char *path);
46
47/* Test-only: force the io_uring-under-seccomp probe's verdict instead
48 * of issuing the real syscall, so the "blocked" log line is
49 * exercisable without actually running under a blocking seccomp
50 * filter. 0 = do the real probe (default), 1 = pretend EPERM,
51 * -1 = pretend "usable". */
52void __xtc_os_tuning_uring_force(int mode);
53#endif
54
55#endif /* XTC_OS_TUNING_H */