Re: [PATCH -v6 2/2] Updating ctime and mtime for memory-mapped files

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: Miklos Szeredi <miklos@...>, <peterz@...>, <linux-mm@...>, <jakob@...>, <linux-kernel@...>, <valdis.kletnieks@...>, <riel@...>, <ksm@...>, <staubach@...>, <jesper.juhl@...>, <akpm@...>, <protasnb@...>, <r.e.wolff@...>, <hidave.darkstar@...>, <hch@...>
Date: Friday, January 18, 2008 - 6:04 pm

2008/1/19, Linus Torvalds <torvalds@linux-foundation.org>:

Thank you very much for taking part in this discussion. Personally,
it's very important to me.  But I'm not sure that I understand which
bit can be lost.

Please let me explain.

The logic for my vma_wrprotect() routine was taken from the
page_check_address() function in mm/rmap.c. Here is a code snippet of
the latter function:

        pgd = pgd_offset(mm, address);
        if (!pgd_present(*pgd))
                return NULL;

        pud = pud_offset(pgd, address);
        if (!pud_present(*pud))
                return NULL;

        pmd = pmd_offset(pud, address);
        if (!pmd_present(*pmd))
                return NULL;

        pte = pte_offset_map(pmd, address);
        /* Make a quick check before getting the lock */
        if (!pte_present(*pte)) {
                pte_unmap(pte);
                return NULL;
        }

        ptl = pte_lockptr(mm, pmd);
        spin_lock(ptl);
        if (pte_present(*pte) && page_to_pfn(page) == pte_pfn(*pte)) {
                *ptlp = ptl;
                return pte;
        }
        pte_unmap_unlock(pte, ptl);

The page_check_address() function is called from the
page_mkclean_one() routine as follows:

        pte = page_check_address(page, mm, address, &ptl);
        if (!pte)
                goto out;

        if (pte_dirty(*pte) || pte_write(*pte)) {
                pte_t entry;

                flush_cache_page(vma, address, pte_pfn(*pte));
                entry = ptep_clear_flush(vma, address, pte);
                entry = pte_wrprotect(entry);
                entry = pte_mkclean(entry);
                set_pte_at(mm, address, pte, entry);
                ret = 1;
        }

        pte_unmap_unlock(pte, ptl);

The write-protection of the PTE is done using the pte_wrprotect()
entity. I intended to do the same during msync() with MS_ASYNC. I
understand that I'm taking a risk of looking a complete idiot now,
however I don't see any difference between the two situations.

I presumed that the code in mm/rmap.c was absolutely correct, that's
why I basically reused the design.

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH -v6 0/2] Fixing the issue with memory-mapped file times, Anton Salikhmetov, (Thu Jan 17, 6:31 pm)
Re: [PATCH -v6 0/2] Fixing the issue with memory-mapped file..., Anton Salikhmetov, (Fri Jan 18, 3:48 pm)
Re: [PATCH -v6 0/2] Fixing the issue with memory-mapped file..., Anton Salikhmetov, (Fri Jan 18, 6:31 am)
[PATCH -v6 2/2] Updating ctime and mtime for memory-mapped f..., Anton Salikhmetov, (Thu Jan 17, 6:31 pm)
Re: [PATCH -v6 2/2] Updating ctime and mtime for memory-mapp..., Anton Salikhmetov, (Mon Jan 21, 10:36 am)
Re: [PATCH -v6 2/2] Updating ctime and mtime for memory-mapp..., Anton Salikhmetov, (Fri Jan 18, 3:58 pm)
Re: [PATCH -v6 2/2] Updating ctime and mtime for memory-mapp..., Anton Salikhmetov, (Fri Jan 18, 5:03 pm)
Re: [PATCH -v6 2/2] Updating ctime and mtime for memory-mapp..., Anton Salikhmetov, (Fri Jan 18, 6:04 pm)
Re: [PATCH -v6 2/2] Updating ctime and mtime for memory-mapp..., Anton Salikhmetov, (Fri Jan 18, 6:35 pm)
Re: [PATCH -v6 2/2] Updating ctime and mtime for memory-mapp..., Anton Salikhmetov, (Fri Jan 18, 6:39 am)
[PATCH -v6 1/2] Massive code cleanup of sys_msync(), Anton Salikhmetov, (Thu Jan 17, 6:31 pm)
Re: [PATCH -v6 1/2] Massive code cleanup of sys_msync(), Miklos Szeredi, (Fri Jan 18, 5:33 am)
Re: [PATCH -v6 1/2] Massive code cleanup of sys_msync(), Anton Salikhmetov, (Fri Jan 18, 6:30 am)