Homework 4 -- Programming


This is a group assignment, per the instructions given at the beginning of the semester. Turn in one copy of the programming assignment; however, each of you must turn in individual written assignments.

In addition, each team member must turn in the group programming evaluation with their own written assignments.


You're going to be modifying a kernel. We do not want you to submit an entire kernel source tree; instead, you'll submit the output of "diff" -- the differences between your code and the original. You'll also need to submit a working or a non-working cover sheet. Finally, turn in any test programs or data, a README file documenting your work (including clear explanations of what each file is), and output from test runs.

Changing the Paging System

As discussed in class, there is no bias in the Linux paging system against reclaiming dirty pages. Perhaps there should be.

The assignment is to modify the kernel so that with some probability, dirty pages are not subject to reclamation. This doesn't need to be a random number; you can compare a counter against some threshhold.

Most of what you will need to change is in mm/vmscan.c. You will not be writing very much (kernel) code; expect to spend a fair amount of time studying that file to understand what changes to make.

You also need to write a test program to measure paging performance with this change. For this, you are required to implement a system call to switch the new paging policy on and off, and to change the probability value. You'll use this to test and see how your new paging algorithm affects paging recalmation policy. By now, I believe that everyone should be an expert on implementing system calls...

After all the implementation is done, use following scenario to test your new kernel and do comparison as follows.

  1. sequential page access, with new algorithm
  2. sequential page access, with original algorithm
  3. random page access, with new algorithm
  4. random page access, with original algorithm

Look to see how many dirty pages are reclaimed between the original algorithm and our new paging policy. Try to see the pattern and the reason behind it.

You may find that /proc/meminfo and /proc/vmstat are useful; see 'man 5 proc' for (somewhat) more information. Run the test program for an unmodified kernel and for 3 different probability values for the new one.


Your vmware directory is not backed up. For safety's sake, make a copy of your changes — not the whole kernel tree! — on another machine.

Danger, Will Robinson

If two people boot the same virtual machine at the same time, it will corrupt the (virtual) disk. Please co-ordinate usage with other members of your team.