linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: salikhmetov@gmail.com
Cc: torvalds@linux-foundation.org, linux-mm@kvack.org,
	jakob@unthought.net, 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, 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 09:52:13 +0100	[thread overview]
Message-ID: <E1JHErd-0007qW-J7@pomaz-ex.szeredi.hu> (raw)
In-Reply-To: <4df4ef0c0801211839p73b6b203q47549fba2be8438b@mail.gmail.com> (salikhmetov@gmail.com)

> > >
> > >  /*
> > > + * 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.

But note, that those functions iterate over all the vmas for the given
page range, not just the one msync was performed on.  This might get
even more expensive, if the file is mapped lots of times.

The old version, that Linus was referring to, needs some modification
as well, because it doesn't write protect the ptes, just marks them
clean.

Miklos

  reply	other threads:[~2008-01-22  8:52 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
2008-01-22  8:52       ` Miklos Szeredi [this message]
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=E1JHErd-0007qW-J7@pomaz-ex.szeredi.hu \
    --to=miklos@szeredi.hu \
    --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=protasnb@gmail.com \
    --cc=r.e.wolff@bitwizard.nl \
    --cc=riel@redhat.com \
    --cc=salikhmetov@gmail.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).