Giter Site home page Giter Site logo

lkm's Introduction

A Linux Kernel Module Reference

The kernel module is designed to be non-monolithic with reusability in mind, comprising multiple layers:

  • lkm: The primary entry point for the kernel module.
  • chardev: This layer facilitates character-type device functionality.
  • resource-manager: This layer enables concurrent access and orderly execution of shared hardware resources. The term "orderly" here refers to an operation being processed sequentially, with no overlapping allowed.
  • realtime: This layer supports the execution of critical or time-sensitive operations that cannot be interrupted or preempted while also minimizing bus arbitration by hogging CPU cores.

Build:

$ make

Insert the kernel module:

$ sudo insmod mod.ko

Check if the kernel module has successfully initialized by verifying the presence of /dev/op0.

$ sudo ls /dev | grep op0

Run the sample userland application:

$ sudo ./test

Configure the kernel module using sysfs attribute groups:

$ ls -l /sys/class/eval/op0/realtime/
total 0
-rw-r--r-- 1 root root 4096 Sep  6 07:40 blocker_timeout
-rw-r--r-- 1 root root 4096 Sep  6 07:40 cpu_allowed
-r--r--r-- 1 root root 4096 Sep  6 07:40 cpu_max
-rw-r--r-- 1 root root 4096 Sep  6 07:40 worker_timeout

$ ls -l /sys/class/eval/op0/resource-manager/
total 0
-r--r--r-- 1 root root 4096 Sep  6 07:41 session_count
-rw-r--r-- 1 root root 4096 Sep  6 07:41 session_max

To read from an attribute:

$ cat /sys/class/eval/op0/realtime/cpu_max

To configure an attribute:

$ sudo sh -c "echo 1 > /sys/class/eval/op0/realtime/cpu_allowed"

Attribute Table:

Group Attribute Permission Description
realtime blocker_timeout RW The timeout value for a worker waiting for the blockers to enter the blocking mode.
realtime worker_timeout RW The timeout value for the blockers waiting for the worker to complete its execution.
realtime cpu_max RO Number of physical CPU core.
realtime cpu_allowed RW <0 results in non-real-time execution.
0 allows execution to occur in a kthread running with a real-time scheduling policy (e.g., SCHED_FIFO).
1, in addition to 0, disables local interrupts but without hogging other CPU cores.
>1, in addition to 0, hog other CPUs (and disables local interrupts) up to a maximum of cpu_max-1 cores.
resource-manager session_max RW Maximum allowed sessions open simultaneously.
resource-manager session_count RO Number of active sessions.

A worker is a single kthread where critical or time-sensitive operations are executed, whereas blockers are multiple kthreads used to hog CPU cores, preventing them from executing other tasks and wait for the worker to complete its execution.

'local interrupts' refers to interrupts that are associated with a specific CPU core.

lkm's People

Contributors

wxleong avatar

Watchers

 avatar  avatar

lkm's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.