lkml.org 
[lkml]   [1998]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectUpdated patch for page table cache
I've reworked the patch for trimming the page table cache to address the
objections raised to the previous version. The patch makes no change to
the existing idle-loop water-mark code; instead it defines a
trim_pgt_cache() function to free one page at a time from the cache. It
cycles through all CPUs to distribute the trimming evenly. Currntly it's
called once per do_try_to_free_page(), but could be made part of the
swap state machine by adding a success return code.

This patch will allow machines of even modest memory size to obtain the
advantages of the page table cache when they aren't swapping, but have
full access to the memory when the system needs it.

The patch makes changes to the i386 arch-dependent part of the source
tree; I'll extend it to the other archs once there are no further
technical problems.

Regards,
Bill--- linux-2.1.109/include/linux/mm.h.old Fri Jul 17 09:34:42 1998
+++ linux-2.1.109/include/linux/mm.h Sun Jul 19 14:41:14 1998
@@ -278,6 +282,7 @@
extern void vmtruncate(struct inode * inode, unsigned long offset);
extern void handle_mm_fault(struct task_struct *tsk,struct vm_area_struct *vma, unsigned long address, int write_access);
extern void check_pgt_cache(void);
+extern void trim_pgt_cache(void);
extern void make_pages_present(unsigned long addr, unsigned long end);

extern unsigned long paging_init(unsigned long start_mem, unsigned long end_mem);
--- linux-2.1.109/mm/memory.c.old Fri Jul 3 10:33:11 1998
+++ linux-2.1.109/mm/memory.c Sun Jul 19 16:26:10 1998
@@ -939,6 +954,10 @@
*/
int pgt_cache_water[2] = { 25, 50 };

+/*
+ * Note: the pxx_quicklists are per CPU, so we don't need
+ * the kernel lock for this operation.
+ */
void check_pgt_cache(void)
{
if(pgtable_cache_size > pgt_cache_water[0]) {
@@ -951,4 +970,36 @@
free_pte_slow(get_pte_fast());
} while(pgtable_cache_size > pgt_cache_water[1]);
}
+}
+
+/*
+ * Free a page from the page table cache, cycling
+ * through the lists for each CPU.
+ *
+ * Note: must be called holding the kernel lock.
+ */
+void trim_pgt_cache(void)
+{
+ static int last_CPU = 0;
+ int cpu_id = cpu_logical_map(last_CPU);
+ unsigned long page;
+
+ if (!cpu_data[cpu_id].pgtable_cache_sz)
+ goto out;
+
+ if ((page = remove_pgd_quick(cpu_id)) != 0)
+ goto out_free;
+ if ((page = remove_pmd_quick(cpu_id)) != 0)
+ goto out_free;
+ page = remove_pte_quick(cpu_id);
+
+out_free:
+ cpu_data[cpu_id].pgtable_cache_sz--;
+ free_page(page);
+out:
+ /* advance the CPU counter for next time */
+ last_CPU++;
+ if (last_CPU > smp_num_cpus)
+ last_CPU = 0;
+ return;
}
--- linux-2.1.109/mm/vmscan.c.old Fri Jul 17 09:10:45 1998
+++ linux-2.1.109/mm/vmscan.c Sun Jul 19 16:23:42 1998
@@ -450,6 +452,9 @@
int i=6;
int stop;

+ /* Trim a page from the page table cache. */
+ trim_pgt_cache();
+
/* Always trim SLAB caches when memory gets low. */
kmem_cache_reap(gfp_mask);

--- linux-2.1.109/include/asm-i386/pgtable.h.old Fri Jul 17 09:28:56 1998
+++ linux-2.1.109/include/asm-i386/pgtable.h Sun Jul 19 15:47:22 1998
@@ -480,6 +480,33 @@
{
}

+/*
+ * These are used for freeing pages from the page table cache,
+ * so we just return an unsigned long value.
+ */
+extern __inline__ unsigned long remove_pgd_quick(int cpu_id)
+{
+ unsigned long *ret = cpu_data[cpu_id].pgd_quick;
+
+ if (ret)
+ cpu_data[cpu_id].pgd_quick = (unsigned long *)(*ret);
+ return (unsigned long)ret;
+}
+
+extern __inline__ unsigned long remove_pmd_quick(int cpu)
+{
+ return 0;
+}
+
+extern __inline__ unsigned long remove_pte_quick(int cpu_id)
+{
+ unsigned long *ret = cpu_data[cpu_id].pte_quick;
+
+ if (ret)
+ cpu_data[cpu_id].pte_quick = (unsigned long *)(*ret);
+ return (unsigned long)ret;
+}
+
extern void __bad_pte(pmd_t *pmd);
extern void __bad_pte_kernel(pmd_t *pmd);
\
 
 \ /
  Last update: 2005-03-22 13:43    [W:0.088 / U:0.744 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site