linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Question on pte bits
@ 2002-12-06 14:57 Martin Maletinsky
  2002-12-06 16:08 ` Rik van Riel
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Maletinsky @ 2002-12-06 14:57 UTC (permalink / raw)
  To: linux-mm, kernelnewbies

Hello,

Looking at some memory managment functions in 2.4.18, I came accross the function follow_page, which is called by get_user_pages, to parse a processes page tables.

After getting the corresponding page table entry, the function makes a check, which I don't quite understand - if write access is requested to the page, it not only checks
the write permission in the page table entry (with pte_write()), but also the dirty bit (with pte_dirty()). Why does a page need to be dirty in the case write == 1 (see
line 444 in the code excerpt below?

Thanks in advance for any help
with best regards
Martin Maletinsky

P.S. Please put me on CC: in your reply, since I am not in the mailing list.

static struct page * follow_page(struct mm_struct *mm, unsigned long address, int write) 
425 {
426         pgd_t *pgd;
427         pmd_t *pmd;
428         pte_t *ptep, pte;
429 
430         pgd = pgd_offset(mm, address);
431         if (pgd_none(*pgd) || pgd_bad(*pgd))
432                 goto out;
433 
434         pmd = pmd_offset(pgd, address);
435         if (pmd_none(*pmd) || pmd_bad(*pmd))
436                 goto out;
437 
438         ptep = pte_offset_atomic(pmd, address);
439 
440         pte = *ptep;
441         pte_kunmap(ptep);
442         if (pte_present(pte)) {
443                 if (!write ||
444                     (pte_write(pte) && pte_dirty(pte)))
445                         return pte_page(pte);
446         }
447 
448 out:
449         return 0;
450 }


--
Supercomputing System AG          email: maletinsky@scs.ch
Martin Maletinsky                 phone: +41 (0)1 445 16 05
Technoparkstrasse 1               fax:   +41 (0)1 445 16 10
CH-8005 Zurich
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-12-06 16:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-06 14:57 Question on pte bits Martin Maletinsky
2002-12-06 16:08 ` Rik van Riel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox