mm - a page-centric kswapd

Benjamin C R LaHaise (
Wed, 6 Aug 1997 06:08:24 +0000 ( )

Greetings all!

I've just managed to get a preliminary version of my memory management
changes working, and it seems to be performing quite well in my tests -
it's the first time I've been able to run X on my 8 meg 486 w/nfs
mounted /usr without crashing or being insanely slow. This version only
works on i386 machines because I haven't made the appropriate changes to
the various asm-*/pgtable.h.

In order to provide a means to find ptes mapped to a given page, all page
tables are now allocated with an order of 1. The second page provides a
single pointer to the next pte on the list of a given page. For
debugging purposes, a circular singly linked list is used, although it is
my intention for the list not to be circular. This is in contrast to
Mark Hemment's idea of using per-page pools that hold pointers to the
ptes mapped to a page (which may very well be better =).

In any case, this mechanism can be easily changed as pte linking is done
through the functions in asm/pgtable.h:
pte_link(pte_t *pte_p, unsigned long page)
pte_unlink(pte_t *pte_p, unsigned long page)

There are a couple of additional primatives defined in pgtable.h:
pmd_t *pte_getpmd(pte_t *pte_p)
pgd_t *pmd_getpgd(pmd_t *pmd_p)
struct mm_struct *pgd_getmm(pgd_t *pgd_p)

This allows one to find the mm_struct a given pte belows to....
nescessary if you want to find the vm_operations to apply to a given page
(see the new mm/vmscan.c)

The code in vmscan.c now scans pages using a single handed clock
algorithm (as mm/filemap.c:shrink_mmap did) - yeah it's pretty bad, but
I've been trying to make the basic code stable (it now seems to be - all
the pte_links in the right places ;). The behaviour wrt shared pages is
very different from the old kswapd - such pages only get touched once for
all mappings as opposed to the many times by the old code. This means
shared pages do *not* have an advantage over non-shared pages, making
kswapd able to free pages much faster.

The willdo list:
- steal_specific_page
-> use to build free pages of orders approaching max
- try_to_flip_page_to(dst_page, priv_page)
- kswapd using active/inactive/freeable queues
- smp friendly page fault handler

The patch is located at
It needs to be applied with patch -S -p2 -d linux_dir/ ... your favourite
options. Any comments/feedback/suggestions would be appreciated, as
that's what this is all about!