Git Product home page Git Product logo

qqyyhh / linux-cgroup2-pagecache-limit Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 179.48 MB

Add a new mechanic to cgroup-v2 and implement the control of page-cache.

Makefile 0.27% C 97.06% Assembly 1.44% C++ 0.75% Objective-C 0.10% Shell 0.11% Perl 0.13% Awk 0.01% Python 0.08% GDB 0.01% sed 0.01% Yacc 0.02% Lex 0.01% UnrealScript 0.01% SmPL 0.02% Gherkin 0.01% Roff 0.01% XS 0.01% Raku 0.01% Clojure 0.01%
pagecache cgroup linux

linux-cgroup2-pagecache-limit's Introduction

linux-cgroup2-pagecache-limit

Add a new mechanic to cgroup-v2 and implement the control of page-cache. Our linux version is 4.15.0 and the directory linux-source-4.15.0 is the corresponding source code tree.

modified files

To implement the new pagecache-limit mechanic, I modified the following files.

  • include/linux/memcontrol.h
  • include/linux/page_count.h
  • mm/filemap.c
  • mm/page_count
  • mm/memcontrol.c
  • mm/vmscan.c If you use other versions of linux, please replace these files.

how to use

You can install the new kernel following the instructions below:

# click Kernel hacking -> Complie-time checks -> compile the kernel with debug info
# generate drarf4 debuginfo
# provide GDB scripts for kernel debugging
make menuconfig
make -j8
make install 
make modules_install

Then you can boot the new kernel through GRUB. Before you boot the new kernel, you shold firstly disable the cgroup-v1 to allow cgroup-v2 using all sub-system:

vim /etc/default/grub
# append systemd.unified_cgroup_hierarchy=1 to GRUB_CMDLINE_LINUX
update-grup

After you boot the new kernel:

cd /sys/fs/cgroup/unified
echo '+memory' >cgroup.subtree_control
mkdir test & cd test & ls

You will see two new user interface files which is using to catch the usage of pagecache and the limitation of pagecache and you can use them like other user interface files.

  • memory.pagecache_current
  • memory.pagecache_limit

test

Run the scripts run_pagecache_test.sh. The script use dd to copy a file of 500M, and it limit the pagecache to 100M. After copying, you can use cat memory.pagecache_current to see how many bytes the dd process used. And you can also use free -h to see increments in buffer/cache usage. At the same time, we provide a simple program to test, test.c, you can replace dd cmd with ./test to do more tests.

linux-cgroup2-pagecache-limit's People

Contributors

qqyyhh avatar

Watchers

 avatar  avatar

Forkers

luchachen

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.