linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Anton Salikhmetov" <salikhmetov@gmail.com>
To: "Linus Torvalds" <torvalds@linux-foundation.org>
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: Tue, 22 Jan 2008 05:39:23 +0300	[thread overview]
Message-ID: <4df4ef0c0801211839p73b6b203q47549fba2be8438b@mail.gmail.com> (raw)
In-Reply-To: <alpine.LFD.1.00.0801211805220.2957@woody.linux-foundation.org>

2008/1/22, Linus Torvalds <torvalds@linux-foundation.org>:
>
>
> 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.

Thanks for your feedback, Linus!

I will use Peter Zijlstra's version of such an operation in my next
patch series.

>
> [ 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
>

  reply	other threads:[~2008-01-22  2:39 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
2008-01-22  2:39     ` Anton Salikhmetov [this message]
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=4df4ef0c0801211839p73b6b203q47549fba2be8438b@mail.gmail.com \
    --to=salikhmetov@gmail.com \
    --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=staubach@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --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;
as well as URLs for NNTP newsgroup(s).