Giter Site home page Giter Site logo

pi-qdisc-linux's Introduction

PI queue disc implementation in the Linux Kernel

This repository hosts the implementation of the Proportional Integral (PI) controller queue discipline within the Linux Kernel. The PI controller serves as a queuing discipline, offering an alternative to RED (Random Early Detection). The code presented here has been adapted for Linux Kernel version 6.2.0-36-generic, originating from Suraj Singh, Gurupungav Narayanan, and Adwaith Gautham's Linux PI code for Linux Kernel version 5.0.0+, available at https://github.com/linux-pi-programmers/

Steps to patch the PI qdisc in the Linux Kernel

  1. Install Prerequisites:

    $ sudo apt install bison flex libssl-dev libelf-dev pkg-config libbpf-dev libcap-dev libmnl-dev
  2. Enable Source Code Download:

    $ sudo software-properties-gtk

    Then, tick the "Source code" checkbox in the "Ubuntu Software" tab and update sources lists:

    $ sudo apt-get update
  3. Obtain Kernel Source Code and Headers:

    $ cd ~/Desktop
    $ sudo apt-get source linux
    $ sudo apt-get install linux-headers-$(uname -r)
  4. Set Permissions of Source Code Directory:

    $ sudo chmod 777 ~/Desktop/linux-<KERNEL_VERSION> -R

    KERNEL_VERSION is the kernel version, e.g., "6.2.0-36-generic" in my case.

  5. Edit pkt_sched.h

    Edit file ‘/usr/src/linux-headers-<KERNEL_VERSION>/include/uapi/linux/pkt_sched.h’ to add enums and a struct for interprocess communication via netlink. The code snippet to be added is as follows:

    // PI
    enum {
        TCA_PI_UNSPEC,
        TCA_PI_QREF,
        TCA_PI_LIMIT,
        TCA_PI_W,
        TCA_PI_A,
        TCA_PI_B,
        TCA_PI_ECN,
        TCA_PI_BYTEMODE,
        __TCA_PI_MAX
    };
    
    struct tc_pi_xstats {
        __u64 prob;
        __u32 qlen;
        __u32 packets_in;
        __u32 overlimit;
        __u32 maxq;
        __u32 dropped;
        __u32 ecn_mark;
    };
    
    #define TCA_PI_MAX   (__TCA_PI_MAX - 1)	
  6. Copy sch_pi.c

    Copy sch_pi.c from this repository to ‘~/Desktop/linux-<KERNEL_VERSION>/net/sched/’ directory.

  7. Edit Makefile

    Edit file ‘~/Desktop/linux-<KERNEL_VERSION>/net/sched/Makefile’ and add the following line below the line that reads ‘CONFIG_NET_SCH_PIE’.

    obj-m += sch_pi.o

    This modification ensures that sch_pi is built as a loadable kernel module.

  8. Copy Kernel Configuration and Prepare

    $ cd ~/Desktop/linux-<KERNEL_VERSION>
    $ cp /boot/config-$(uname -r) .config
    $ make oldconfig
    $ make prepare
    $ make scripts
    $ cp -v /usr/src/linux-headers-$(uname -r)/Module.symvers .

    This sequence ensures that the kernel configuration is copied, checked for compatibility, and the source code is prepared for building the modules. The module.symvers file is also copied as is crucial for maintaining symbol versioning consistency when loading a module.

  9. Compile and install kernel modules in net/sched

    $ cd net/sched
    $ make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
    $ sudo make -C /lib/modules/$(uname -r)/build M=$(pwd) modules_install
    $ depmod -a

    This sequence compiles and builds the kernel modules in net/sched directory. It also generates a module dependency file.

  10. Clone iproute2

    cd ~/Desktop && git clone https://github.com/iproute2/iproute2.git
  11. Edit pkt_sched.h in iproute2

    Edit file ~/Desktop/iproute2/include/uapi/linux/pkt_sched.h and add the same code snippet as mentioned in step 5.

  12. Copy q_pi.c in iproute2 Copy q_pi.c from this repository to ‘~/Desktop/iproute2/tc/’ directory.

  13. Edit Makefile in iproute2

    Look for the line that reads ‘TC_MODULES += q_pie.o’. Below that line, add the following line:

    TC_MODULES += q_pi.o

    This will ensure that the q_pi.o module is included as part of the build process.

  14. Compile and Install iproute2

    $ cd ~/Desktop/iproute2
    $ make
    $ sudo make install    
  15. Verify installation of PI module

    $ tc qdisc add dev <INTERFACE_NAME> root pi
    $ tc qdisc show

    <INTERFACE_NAME> is the name of the interface where you wish to add the PI qdisc.

    If you see an entry for the pi qdisc then the module is successfully loaded.

References

pi-qdisc-linux's People

Contributors

h-n41k avatar

Watchers

 avatar  avatar

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.