OS-R1: Agentic Operating System Kernel Tuning with Reinforcement Learning

Hongyu Lin, Yuchen Li, Haoran Luo, Kaichun Yao, Libo Zhang, Mingjie Xing, Yanjun WuarXiv 2025 · DOI

Abstract

Operating system (OS) kernel tuning is a complex, high-dimensional optimization problem often referred to as a "black art." With over 18,000 configurable parameters in the Linux kernel, traditional heuristic and machine learning approaches often fail to scale or generalize. This paper introduces OS-R1, a novel framework that transforms kernel tuning into an agentic reinforcement learning task. By employing Group Relative Policy Optimization (GRPO) and a specialized two-phase training process—comprising reasoning standardization and performance-driven exploration—OS-R1 enables large language models (LLMs) to navigate the kernel configuration space effectively. Experimental results demonstrate that OS-R1-7B outperforms state-of-the-art models and human experts, yielding a 5.6% improvement over heuristic baselines in real-world application benchmarks.

1. Introduction

The Linux kernel serves as the backbone of modern computing, yet its performance is highly dependent on thousands of configuration parameters. Finding the optimal settings for specific workloads is notoriously difficult due to the sheer size of the search space and the intricate dependencies between flags. Existing methods, such as manual heuristic tuning, standard machine learning, and basic LLM assistance, suffer from scalability issues, high data requirements, or a tendency to produce invalid configurations (hallucinations).

Comparison of kernel tuning paradigms: Heuristic, Machine Learning-Based, LLM-Assisted, and the proposed OS-R1 Tuning.

OS-R1 addresses these challenges by treating the kernel as a dynamic environment where an AI agent can explore and learn through reinforcement learning (RL).

2. Methodology

The OS-R1 framework is built upon Group Relative Policy Optimization (GRPO), focusing on developing an agent capable of multi-step reasoning and tool use.

2.1 Agentic Framework and Tool-Augmented Reasoning

The agent does not merely predict values; it follows a Chain-of-Thought process to understand the impact of specific configurations. It is equipped with a domain-specific Knowledge Base, allowing it to query the function of various CONFIG_ flags before proposing changes.

The agentic loop of OS-R1, featuring tool-augmented reasoning and performance-based rewards.

2.2 Two-Phase Training Process

The training is divided into two distinct stages:

  • Phase 1 (Warm-up): Focuses on reasoning standardization, ensuring the model follows correct output formats and utilizes external tools effectively.
  • Phase 2 (Exploration): The model engages in active exploration of the configuration space, receiving rewards based on actual system performance gains and the validity of its proposed configurations.

2.3 Multi-Component Reward Function

To mitigate hallucinations and ensure system stability, OS-R1 employs a composite reward function based on:

  • Format Reward: Adherence to structural instructions.
  • Answer Validity: Correctness and legality of the generated kernel flags.
  • Performance Reward: Measured improvements in system throughput or latency.

3. Experimental Evaluation

The framework was trained on a structured dataset of over 3,000 samples and evaluated across diverse benchmarks.

3.1 Benchmarks and Datasets

Evaluation utilized UnixBench for core system metrics and real-world applications including Nginx, Redis, and PostgreSQL. To manage the 18,000+ parameters, configurations were organized into functional "Configuration Groups."

3.2 Key Results

OS-R1-7B demonstrated superior performance, achieving a UnixBench score of 662.2, surpassing GPT-4o (632.9) and DeepSeek-R1 (650.5). In application-specific tuning, the model provided a 5.6% performance boost over expert-tuned baselines. Notably, the RL-driven approach improved the validity rate of generated configurations from 12.2% to 78.1%.

4. Conclusion and Future Work

OS-R1 successfully applies advanced reasoning and RL techniques to the domain of low-level systems engineering. While currently focused on static Linux workloads on x86 architectures, future research will explore real-time dynamic tuning, cross-architecture support for ARM and RISC-V, and multi-objective optimization to balance performance with energy efficiency.

Summary updated

BibTeX
@misc{lin2025os,
  author = {Hongyu Lin and Yuchen Li and Haoran Luo and Kaichun Yao and Libo Zhang and Mingjie Xing and Yanjun Wu},
  title = {{OS-R1: Agentic Operating System Kernel Tuning with Reinforcement Learning}},
  year = {2025},
  eprint = {2508.12551},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.12551},
}
Figure