From: Nick Piggin <npiggin@kernel.dk>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Nick Piggin <npiggin@kernel.dk>,
"Xen-devel@lists.xensource.com" <Xen-devel@lists.xensource.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Memory Management List <linux-mm@kvack.org>,
Trond Myklebust <Trond.Myklebust@netapp.com>,
Bryan Schumaker <bjschuma@netapp.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: Re: [PATCH RFC] vmalloc: eagerly clear ptes on vunmap
Date: Tue, 30 Nov 2010 23:42:49 +1100 [thread overview]
Message-ID: <20101130124249.GB15778@amd> (raw)
In-Reply-To: <4CF40DCB.5010007@goop.org>
On Mon, Nov 29, 2010 at 12:32:11PM -0800, Jeremy Fitzhardinge wrote:
> When unmapping a region in the vmalloc space, clear the ptes immediately.
> There's no point in deferring this because there's no amortization
> benefit.
>
> The TLBs are left dirty, and they are flushed lazily to amortize the
> cost of the IPIs.
>
> This specific motivation for this patch is a regression since 2.6.36 when
> using NFS under Xen, triggered by the NFS client's use of vm_map_ram()
> introduced in 56e4ebf877b6043c289bda32a5a7385b80c17dee. XFS also uses
> vm_map_ram() and could cause similar problems.
I do wonder whether there are cache benefits from batching page table
updates, especially the batched per cpu maps (and in your version they
get double-cleared as well). I think this patch is good, but I think
perhaps making it configurable would be nice.
So... main question, does it allow Xen to use lazy flushing and avoid
vm_unmap_aliases() calls?
>
> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
> Cc: Nick Piggin <npiggin@kernel.dk>
>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index a3d66b3..9960644 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -566,7 +566,6 @@ static void __purge_vmap_area_lazy(unsigned long *start, unsigned long *end,
> if (va->va_end > *end)
> *end = va->va_end;
> nr += (va->va_end - va->va_start) >> PAGE_SHIFT;
> - unmap_vmap_area(va);
> list_add_tail(&va->purge_list, &valist);
> va->flags |= VM_LAZY_FREEING;
> va->flags &= ~VM_LAZY_FREE;
> @@ -616,6 +615,8 @@ static void purge_vmap_area_lazy(void)
> */
> static void free_unmap_vmap_area_noflush(struct vmap_area *va)
> {
> + unmap_vmap_area(va);
> +
> va->flags |= VM_LAZY_FREE;
> atomic_add((va->va_end - va->va_start) >> PAGE_SHIFT, &vmap_lazy_nr);
> if (unlikely(atomic_read(&vmap_lazy_nr) > lazy_max_pages()))
> @@ -944,8 +945,10 @@ static void vb_free(const void *addr, unsigned long size)
> BUG_ON(vb->free);
> spin_unlock(&vb->lock);
> free_vmap_block(vb);
> - } else
> + } else {
> spin_unlock(&vb->lock);
> + vunmap_page_range((unsigned long)addr, (unsigned long)addr + size);
> + }
> }
>
> /**
> @@ -988,7 +991,6 @@ void vm_unmap_aliases(void)
>
> s = vb->va->va_start + (i << PAGE_SHIFT);
> e = vb->va->va_start + (j << PAGE_SHIFT);
> - vunmap_page_range(s, e);
> flush = 1;
>
> if (s < start)
>
WARNING: multiple messages have this Message-ID (diff)
From: Nick Piggin <npiggin@kernel.dk>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Nick Piggin <npiggin@kernel.dk>,
"Xen-devel@lists.xensource.com" <Xen-devel@lists.xensource.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Memory Management List <linux-mm@kvack.org>,
Trond Myklebust <Trond.Myklebust@netapp.com>,
Bryan Schumaker <bjschuma@netapp.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: Re: [PATCH RFC] vmalloc: eagerly clear ptes on vunmap
Date: Tue, 30 Nov 2010 23:42:49 +1100 [thread overview]
Message-ID: <20101130124249.GB15778@amd> (raw)
In-Reply-To: <4CF40DCB.5010007@goop.org>
On Mon, Nov 29, 2010 at 12:32:11PM -0800, Jeremy Fitzhardinge wrote:
> When unmapping a region in the vmalloc space, clear the ptes immediately.
> There's no point in deferring this because there's no amortization
> benefit.
>
> The TLBs are left dirty, and they are flushed lazily to amortize the
> cost of the IPIs.
>
> This specific motivation for this patch is a regression since 2.6.36 when
> using NFS under Xen, triggered by the NFS client's use of vm_map_ram()
> introduced in 56e4ebf877b6043c289bda32a5a7385b80c17dee. XFS also uses
> vm_map_ram() and could cause similar problems.
I do wonder whether there are cache benefits from batching page table
updates, especially the batched per cpu maps (and in your version they
get double-cleared as well). I think this patch is good, but I think
perhaps making it configurable would be nice.
So... main question, does it allow Xen to use lazy flushing and avoid
vm_unmap_aliases() calls?
>
> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
> Cc: Nick Piggin <npiggin@kernel.dk>
>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index a3d66b3..9960644 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -566,7 +566,6 @@ static void __purge_vmap_area_lazy(unsigned long *start, unsigned long *end,
> if (va->va_end > *end)
> *end = va->va_end;
> nr += (va->va_end - va->va_start) >> PAGE_SHIFT;
> - unmap_vmap_area(va);
> list_add_tail(&va->purge_list, &valist);
> va->flags |= VM_LAZY_FREEING;
> va->flags &= ~VM_LAZY_FREE;
> @@ -616,6 +615,8 @@ static void purge_vmap_area_lazy(void)
> */
> static void free_unmap_vmap_area_noflush(struct vmap_area *va)
> {
> + unmap_vmap_area(va);
> +
> va->flags |= VM_LAZY_FREE;
> atomic_add((va->va_end - va->va_start) >> PAGE_SHIFT, &vmap_lazy_nr);
> if (unlikely(atomic_read(&vmap_lazy_nr) > lazy_max_pages()))
> @@ -944,8 +945,10 @@ static void vb_free(const void *addr, unsigned long size)
> BUG_ON(vb->free);
> spin_unlock(&vb->lock);
> free_vmap_block(vb);
> - } else
> + } else {
> spin_unlock(&vb->lock);
> + vunmap_page_range((unsigned long)addr, (unsigned long)addr + size);
> + }
> }
>
> /**
> @@ -988,7 +991,6 @@ void vm_unmap_aliases(void)
>
> s = vb->va->va_start + (i << PAGE_SHIFT);
> e = vb->va->va_start + (j << PAGE_SHIFT);
> - vunmap_page_range(s, e);
> flush = 1;
>
> if (s < start)
>
--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2010-11-30 12:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-26 8:10 Could we do immediate pte zaps in vunmap? Jeremy Fitzhardinge
2010-11-27 10:36 ` Nick Piggin
2010-11-29 20:32 ` [PATCH RFC] vmalloc: eagerly clear ptes on vunmap Jeremy Fitzhardinge
2010-11-29 20:32 ` Jeremy Fitzhardinge
2010-11-30 12:42 ` Nick Piggin [this message]
2010-11-30 12:42 ` Nick Piggin
2010-11-30 17:45 ` Jeremy Fitzhardinge
2010-11-30 17:45 ` Jeremy Fitzhardinge
2010-12-01 0:29 ` Andrew Morton
2010-12-01 0:29 ` Andrew Morton
2010-12-01 3:09 ` Jeremy Fitzhardinge
2010-12-01 3:09 ` Jeremy Fitzhardinge
2010-12-01 3:23 ` Andrew Morton
2010-12-01 3:23 ` Andrew Morton
2010-12-01 8:16 ` Jeremy Fitzhardinge
2010-12-01 8:16 ` Jeremy Fitzhardinge
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=20101130124249.GB15778@amd \
--to=npiggin@kernel.dk \
--cc=Trond.Myklebust@netapp.com \
--cc=Xen-devel@lists.xensource.com \
--cc=akpm@linux-foundation.org \
--cc=bjschuma@netapp.com \
--cc=jeremy@goop.org \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.