From: Linus Torvalds <torvalds@linux-foundation.org>
To: Anton Salikhmetov <salikhmetov@gmail.com>
Cc: linux-mm@kvack.org, jakob@unthought.net,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
valdis.kletnieks@vt.edu, riel@redhat.com, ksm@42.dk,
staubach@redhat.com, jesper.juhl@gmail.com,
a.p.zijlstra@chello.nl, Andrew Morton <akpm@linux-foundation.org>,
protasnb@gmail.com, miklos@szeredi.hu, r.e.wolff@bitwizard.nl,
hidave.darkstar@gmail.com, hch@infradead.org
Subject: Re: [PATCH -v7 2/2] Update ctime and mtime for memory-mapped files
Date: Mon, 21 Jan 2008 18:16:46 -0800 (PST) [thread overview]
Message-ID: <alpine.LFD.1.00.0801211805220.2957@woody.linux-foundation.org> (raw)
In-Reply-To: <12009619584168-git-send-email-salikhmetov@gmail.com>
On Tue, 22 Jan 2008, Anton Salikhmetov wrote:
>
> /*
> + * Scan the PTEs for pages belonging to the VMA and mark them read-only.
> + * It will force a pagefault on the next write access.
> + */
> +static void vma_wrprotect(struct vm_area_struct *vma)
> +{
> + unsigned long addr;
> +
> + for (addr = vma->vm_start; addr < vma->vm_end; addr += PAGE_SIZE) {
> + spinlock_t *ptl;
> + pgd_t *pgd = pgd_offset(vma->vm_mm, addr);
> + pud_t *pud = pud_offset(pgd, addr);
> + pmd_t *pmd = pmd_offset(pud, addr);
> + pte_t *pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
This is extremely expensive over bigger areas, especially sparsely mapped
ones (it does all the lookups for all four levels over and over and over
again for eachg page).
I think Peter Zijlstra posted a version that uses the regular kind of
nested loop (with inline functions to keep the thing nice and clean),
which gets rid of that.
[ The sad/funny part is that this is all how we *used* to do msync(), back
in the days: we're literally going back to the "pre-cleanup" logic. See
commit 204ec841fbea3e5138168edbc3a76d46747cc987: "mm: msync() cleanup"
for details ]
Quite frankly, I really think you might be better off just doing a
git revert 204ec841fbea3e5138168edbc3a76d46747cc987
and working from there! I just checked, and it still reverts cleanly, and
you'd end up with a nice code-base that (a) has gotten years of testing
and (b) already has the looping-over-the-pagetables code.
Linus
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2008-01-22 2:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-22 0:32 [PATCH -v7 0/2] Fixing the issue with memory-mapped file times Anton Salikhmetov
2008-01-22 0:32 ` [PATCH -v7 1/2] Massive code cleanup of sys_msync() Anton Salikhmetov
2008-01-22 0:32 ` [PATCH -v7 2/2] Update ctime and mtime for memory-mapped files Anton Salikhmetov
2008-01-22 1:40 ` Jesper Juhl
2008-01-22 1:51 ` Anton Salikhmetov
2008-01-22 1:54 ` Jesper Juhl
2008-01-22 1:57 ` Anton Salikhmetov
2008-01-22 2:18 ` Jesper Juhl
2008-01-22 2:07 ` Anton Salikhmetov
2008-01-22 2:16 ` Jesper Juhl
2008-01-22 2:16 ` Linus Torvalds [this message]
2008-01-22 2:39 ` Anton Salikhmetov
2008-01-22 8:52 ` Miklos Szeredi
2008-01-22 4:39 ` Andi Kleen
2008-01-22 1:34 ` [PATCH -v7 0/2] Fixing the issue with memory-mapped file times Jesper Juhl
2008-01-22 1:40 ` Anton Salikhmetov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.1.00.0801211805220.2957@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=hidave.darkstar@gmail.com \
--cc=jakob@unthought.net \
--cc=jesper.juhl@gmail.com \
--cc=ksm@42.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=miklos@szeredi.hu \
--cc=protasnb@gmail.com \
--cc=r.e.wolff@bitwizard.nl \
--cc=riel@redhat.com \
--cc=salikhmetov@gmail.com \
--cc=staubach@redhat.com \
--cc=valdis.kletnieks@vt.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox