Re: patch to trim page table cache

Bill Hawes (whawes@star.net)
Sat, 18 Jul 1998 11:29:10 -0400


This is a multi-part message in MIME format.
--------------E50AA232B5AF5D26923D3931
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Linus Torvalds wrote:

> The page table caches should be completely per-CPU, and thus don't need
> any locking. At least that's tthe way it's _meant_ to be,

Yes, you're right -- I hadn't seen that the pxx_quicklist constructs
were just macros.

Revised patch sans locking changes is attached. One remaining question
is whether the kswapd process can migrate between CPUs in an SMP system.
If not, I'll need to find some way to drain the other CPU caches.

Regards,
Bill
--------------E50AA232B5AF5D26923D3931
Content-Type: text/plain; charset=us-ascii; name="mm_pgt109-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="mm_pgt109-patch"

--- linux-2.1.109/include/linux/mm.h.old Fri Jul 17 09:34:42 1998
+++ linux-2.1.109/include/linux/mm.h Fri Jul 17 21:03:39 1998
@@ -277,7 +281,8 @@

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(int);
+#define check_pgt_cache() trim_pgt_cache(0)
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 Sat Jul 18 09:14:43 1998
@@ -939,9 +954,13 @@
*/
int pgt_cache_water[2] = { 25, 50 };

-void check_pgt_cache(void)
+/*
+ * Note: the pxx_quicklists are per CPU, so we don't need
+ * the kernel lock for this operation.
+ */
+void trim_pgt_cache(int must_free)
{
- if(pgtable_cache_size > pgt_cache_water[0]) {
+ if(pgtable_cache_size > (must_free ? 0 : pgt_cache_water[0])) {
do {
if(pgd_quicklist)
free_pgd_slow(get_pgd_fast());
--- linux-2.1.109/mm/vmscan.c.old Fri Jul 17 09:10:45 1998
+++ linux-2.1.109/mm/vmscan.c Sat Jul 18 09:37:59 1998
@@ -453,6 +453,12 @@
/* Always trim SLAB caches when memory gets low. */
kmem_cache_reap(gfp_mask);

+ /*
+ * Trim back the page table cache.
+ * N.B. For SMP, depends on kswapd migrating to different CPUs
+ */
+ trim_pgt_cache(1);
+
/* We try harder if we are waiting .. */
stop = 3;
if (gfp_mask & __GFP_WAIT)
@@ -533,7 +539,6 @@
add_wait_queue(&kswapd_wait, &wait);
while (1) {
int tries;
- int tried = 0;

current->state = TASK_INTERRUPTIBLE;
flush_signals(current);

--------------E50AA232B5AF5D26923D3931--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html