lkml.org 
[lkml]   [1998]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: Major 2.1.x problem index
> On Fri, 19 Jun 1998, Alan Cox wrote:
>
> > http://roadrunner.swansea.uk.linux.org/jobs.shtml holds the major showstopper
> > items for a 2.2 release, and a few other bugs indexed on a web page.

I've written a piece of code to solve mlock problem.
I'm certainly not a mm guru so the code may be wrong.
Do people agree with the implemented approach to fix the problem?

Best wishes
Andrey V.
Savochkin
--- linux.orig/mm/mlock.c Wed Jun 17 14:57:33 1998
+++ linux/mm/mlock.c Sun Jun 21 20:00:32 1998
@@ -126,26 +126,7 @@
if (!(newflags & VM_LOCKED))
pages = -pages;
vma->vm_mm->locked_vm += pages;
-
-#if 0
-/*
- * This is horribly broken. See the comment on the same
- * brokenness in mm/mmap.c (essentially, this doesn't
- * work anyway for PROT_NONE and writable pages, and now
- * that we properly get the mmap semaphore it would just
- * lock up on us).
- *
- * Fix the same way.
- */
- if (newflags & VM_LOCKED) {
- while (start < end) {
- int c;
- get_user(c,(int *) start);
- __asm__ __volatile__("": :"r" (c));
- start += PAGE_SIZE;
- }
- }
-#endif
+ make_pages_present(start, end);
}
return retval;
}
--- linux.orig/mm/memory.c Wed Jun 17 14:57:33 1998
+++ linux/mm/memory.c Tue Jun 23 19:06:55 1998
@@ -918,6 +918,72 @@
oom(tsk);
}

+/*
+ * mm semaphore and global kernel lock should be held,
+ * pages should belong to the same vma.
+ */
+void make_pages_present(unsigned long addr, unsigned long end)
+{
+ struct vm_area_struct * vma;
+ pgd_t *pgd;
+ pmd_t *pmd;
+ pte_t *pte;
+ pte_t origentry;
+ int writable, needfix;
+
+ vma = find_vma(current->mm, addr);
+ pgd = pgd_offset(current->mm, addr);
+
+ while (1) {
+ pmd = pmd_alloc(pgd, addr);
+ if (!pmd)
+ goto no_memory;
+ pte = pte_alloc(pmd, addr);
+ if (!pte)
+ goto no_memory;
+
+ writable = vma->vm_flags & VM_MAYWRITE;
+ needfix = writable;
+ flush_cache_page(vma, addr);
+ origentry = *pte;
+ if (pte_none(origentry) || !pte_present(origentry))
+ do_no_page(current, vma, addr, writable, pte,
+ origentry);
+ else if (writable && !pte_write(origentry))
+ do_wp_page(current, vma, addr, writable, pte);
+ else
+ needfix = 0;
+
+ /* do_xxx_page() can make the page writtable when it
+ * isn't. Now we fix the protection. The page can't
+ * be accessed before the fix because:
+ * 1) the code hasn't blocked
+ * 2) global kernel lock is held
+ * 3) user space pages can't be accessed from
+ * interrupts.
+ */
+ if (needfix) {
+ pte_t entry;
+ flush_cache_page(vma, addr);
+ entry = pte_modify(*pte, vma->vm_page_prot);
+ if (vma->vm_flags & VM_WRITE)
+ entry = pte_mkwrite(entry);
+ if (!pte_dirty(origentry))
+ entry = pte_mkclean(entry);
+ set_pte(pte, entry);
+ flush_tlb_page(vma, addr);
+ }
+ update_mmu_cache(vma, addr, *pte);
+
+ addr += PAGE_SIZE;
+ if (addr >= end)
+ break;
+ }
+ return;
+no_memory:
+ oom(current);
+}
+
/* Low and high watermarks for page table cache.
The system should try to have pgt_water[0] <= cache elements <= pgt_water[1]
*/
--- linux.orig/include/linux/mm.h Wed Jun 17 14:49:08 1998
+++ linux/include/linux/mm.h Sun Jun 21 20:27:45 1998
@@ -292,6 +292,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 make_pages_present(unsigned long addr, unsigned long end);

extern unsigned long paging_init(unsigned long start_mem, unsigned long end_mem);
extern void mem_init(unsigned long start_mem, unsigned long end_mem);[unhandled content-type:application/x-gunzip]
\
 
 \ /
  Last update: 2005-03-22 13:43    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site