On Wed, 2003-06-25 at 18:59, Ravi wrote: > > --- Jim Bauer <jfbauer@nfr.com> wrote: > > > > You don't really need zap_page_range() to remove the old > > > mapping. Since you know the virtual address at which the > > > page is mapped, you can also find out where the corresponding > > > PTE (page table entry) is. Then you can clear the entry > > > with ptep_get_and_clear(). This lets you save the old PTE, > > > from which you can get to the page using pte_page(). You > > > can then free the page or do whatever else you want with it. > > > > Know of a good example of this? > > I couldn't find an example in any 2.5.x driver. But here is > what is needed: > > { > struct mm_struct *mm; > pgd_t *pgd; > pmd_t *pmd; > pte_t *ptep, pte; > struct page *old_page; > struct page *new_page = ...; /* new page to be mapped in */ > pgprot_t prot = ...; /* PTE flags. _PAGE_RW, PAGE_SHARED, etc. > * Set appropriately. */ > > mm = current->mm; > spin_lock(&mm->page_table_lock); > pgd = pgd_offset(mm, address); > pmd = pmd_offset(pgd, address); > ptep = pte_offset_map(pmd, address); > pte = ptep_get_and_clear(ptep); > set_pte(ptep, mk_pte(new_page, prot)); > spin_unlock(&mm->page_table_lock); > old_page = pte_page(pte); > ... > } > > Not many error checks are needed in this case since we > know that the required address definitely has a mapping > in the process page table. > I tried this, but the user-space program's mapping was still refering to the old pages. However, if I ran it through gdb and single stepped it then it saw the new buffer. It I used gdb, but did not single step, then the prog being debugged saw the old pages, but gdb saw the new ones? Anyone care to explain that? -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/