--- linux-2.6.16-rc4/mm/memory.c	2006-02-18 14:40:38 +0100
+++ linux-2.6.16-rc4-vs2.1.1-rc8/mm/memory.c	2006-02-18 15:33:58 +0100
@@ -2205,6 +2214,7 @@ static inline int handle_pte_fault(struc
 	pte_t entry;
 	pte_t old_entry;
 	spinlock_t *ptl;
+	int ret, type = VXPT_UNKNOWN;
 
 	old_entry = entry = *pte;
 	if (!pte_present(entry)) {
--- linux-2.6.16-rc4/mm/memory.c	2006-02-18 14:40:38 +0100
+++ linux-2.6.16-rc4-vs2.1.1-rc8/mm/memory.c	2006-02-18 15:33:58 +0100
@@ -2209,17 +2219,27 @@ *****
 	old_entry = entry = *pte;
 	if (!pte_present(entry)) {
 		if (pte_none(entry)) {
-			if (!vma->vm_ops || !vma->vm_ops->nopage)
-				return do_anonymous_page(mm, vma, address,
+			if (!vma->vm_ops || !vma->vm_ops->nopage) {
+				ret = do_anonymous_page(mm, vma, address,
 					pte, pmd, write_access);
-			return do_no_page(mm, vma, address,
+				type = VXPT_ANON;
+				goto out;
+			}
+			ret = do_no_page(mm, vma, address,
 					pte, pmd, write_access);
+			type = VXPT_NONE;
+			goto out;
 		}
-		if (pte_file(entry))
-			return do_file_page(mm, vma, address,
+		if (pte_file(entry)) {
+			ret = do_file_page(mm, vma, address,
 					pte, pmd, write_access, entry);
-		return do_swap_page(mm, vma, address,
+			type = VXPT_FILE;
+			goto out;
+		}
+		ret = do_swap_page(mm, vma, address,
 					pte, pmd, write_access, entry);
+		type = VXPT_SWAP;
+		goto out;
 	}
 
 	ptl = pte_lockptr(mm, pmd);
--- linux-2.6.16-rc4/mm/memory.c	2006-02-18 14:40:38 +0100
+++ linux-2.6.16-rc4-vs2.1.1-rc8/mm/memory.c	2006-02-18 15:33:58 +0100
@@ -2227,9 +2247,12 @@ static inline int handle_pte_fault(struc
 	if (unlikely(!pte_same(*pte, entry)))
 		goto unlock;
 	if (write_access) {
-		if (!pte_write(entry))
-			return do_wp_page(mm, vma, address,
+		if (!pte_write(entry)) {
+			ret = do_wp_page(mm, vma, address,
 					pte, pmd, ptl, entry);
+			type = VXPT_WRITE;
+			goto out;
+		}
 		entry = pte_mkdirty(entry);
 	}
 	entry = pte_mkyoung(entry);
--- linux-2.6.16-rc4/mm/memory.c	2006-02-18 14:40:38 +0100
+++ linux-2.6.16-rc4-vs2.1.1-rc8/mm/memory.c	2006-02-18 15:33:58 +0100
@@ -2249,7 +2272,10 @@ static inline int handle_pte_fault(struc
 	}
 unlock:
 	pte_unmap_unlock(pte, ptl);
-	return VM_FAULT_MINOR;
+	ret = VM_FAULT_MINOR;
+out:
+	vx_page_fault(mm, vma, type, ret);
+	return ret;
 }
 
 /*
--- linux-2.6.16-rc4/mm/slab.c	2006-02-18 14:40:38 +0100
+++ linux-2.6.16-rc4-vs2.1.1-rc8/mm/slab.c	2006-02-17 23:26:33 +0100
@@ -2756,6 +2758,7 @@ __cache_alloc(struct kmem_cache *cachep,
 
 	local_irq_save(save_flags);
 	objp = ____cache_alloc(cachep, flags);
+	vx_slab_alloc(cachep, flags);
 	local_irq_restore(save_flags);
 	objp = cache_alloc_debugcheck_after(cachep, flags, objp,
 					    caller);
--- linux-2.6.16-rc4/mm/slab.c	2006-02-18 14:40:38 +0100
+++ linux-2.6.16-rc4-vs2.1.1-rc8/mm/slab.c	2006-02-17 23:26:33 +0100
@@ -2801,6 +2804,7 @@ static void *__cache_alloc_node(struct k
 
 	obj = slab_get_obj(cachep, slabp, nodeid);
 	check_slabp(cachep, slabp);
+	vx_slab_alloc(cachep, flags);
 	l3->free_objects--;
 	/* move slabp to correct slabp list: */
 	list_del(&slabp->list);
--- linux-2.6.16-rc4/mm/slab_vs.h	1970-01-01 01:00:00 +0100
+++ linux-2.6.16-rc4-vs2.1.1-rc8/mm/slab_vs.h	2006-02-17 23:26:33 +0100
@@ -0,0 +1,23 @@
+
+static inline
+void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
+{
+	int what = cachep->gfpflags & GFP_ZONEMASK;
+
+	if (!current->vx_info)
+		return;
+
+	atomic_add(cachep->buffer_size, &current->vx_info->cacct.slab[what]);
+}
+
+static inline
+void vx_slab_free(struct kmem_cache *cachep)
+{
+	int what = cachep->gfpflags & GFP_ZONEMASK;
+
+	if (!current->vx_info)
+		return;
+
+	atomic_sub(cachep->buffer_size, &current->vx_info->cacct.slab[what]);
+}
+
--- linux-2.6.16-rc4/mm/slab.c	2006-02-18 14:40:38 +0100
+++ linux-2.6.16-rc4-vs2.1.1-rc8/mm/slab.c	2006-02-17 23:26:33 +0100
@@ -2933,6 +2938,7 @@ static inline void __cache_free(struct k
 
 	check_irq_off();
 	objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
+	vx_slab_free(cachep);
 
 	/* Make sure we are not freeing a object from another
 	 * node to the array cache on this cpu.
--- linux-2.6.16-rc4/mm/slab.c	2006-02-18 14:40:38 +0100
+++ linux-2.6.16-rc4-vs2.1.1-rc8/mm/slab.c	2006-02-17 23:26:33 +0100
@@ -487,6 +487,8 @@ struct kmem_cache {
 #define STATS_INC_FREEMISS(x)	do { } while (0)
 #endif
 
+#include "slab_vs.h"
+
 #if DEBUG
 /* Magic nums for obj red zoning.
  * Placed in the first word before and the first word after an obj.
