[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190417230219.GA5538@tower.DHCP.thefacebook.com>
Date: Wed, 17 Apr 2019 23:02:25 +0000
From: Roman Gushchin <guro@...com>
To: Andrew Morton <akpm@...ux-foundation.org>
CC: Roman Gushchin <guroan@...il.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Kernel Team <Kernel-team@...com>,
"Matthew Wilcox" <willy@...radead.org>,
Johannes Weiner <hannes@...xchg.org>,
"Vlastimil Babka" <vbabka@...e.cz>
Subject: Re: [PATCH v4 1/2] mm: refactor __vunmap() to avoid duplicated call
to find_vm_area()
On Wed, Apr 17, 2019 at 02:58:27PM -0700, Andrew Morton wrote:
> On Wed, 17 Apr 2019 12:40:01 -0700 Roman Gushchin <guroan@...il.com> wrote:
>
> > __vunmap() calls find_vm_area() twice without an obvious reason:
> > first directly to get the area pointer, second indirectly by calling
> > remove_vm_area(), which is again searching for the area.
> >
> > To remove this redundancy, let's split remove_vm_area() into
> > __remove_vm_area(struct vmap_area *), which performs the actual area
> > removal, and remove_vm_area(const void *addr) wrapper, which can
> > be used everywhere, where it has been used before.
> >
> > On my test setup, I've got 5-10% speed up on vfree()'ing 1000000
> > of 4-pages vmalloc blocks.
> >
> > Perf report before:
> > 22.64% cat [kernel.vmlinux] [k] free_pcppages_bulk
> > 10.30% cat [kernel.vmlinux] [k] __vunmap
> > 9.80% cat [kernel.vmlinux] [k] find_vmap_area
> > 8.11% cat [kernel.vmlinux] [k] vunmap_page_range
> > 4.20% cat [kernel.vmlinux] [k] __slab_free
> > 3.56% cat [kernel.vmlinux] [k] __list_del_entry_valid
> > 3.46% cat [kernel.vmlinux] [k] smp_call_function_many
> > 3.33% cat [kernel.vmlinux] [k] kfree
> > 3.32% cat [kernel.vmlinux] [k] free_unref_page
> >
> > Perf report after:
> > 23.01% cat [kernel.kallsyms] [k] free_pcppages_bulk
> > 9.46% cat [kernel.kallsyms] [k] __vunmap
> > 9.15% cat [kernel.kallsyms] [k] vunmap_page_range
> > 6.17% cat [kernel.kallsyms] [k] __slab_free
> > 5.61% cat [kernel.kallsyms] [k] kfree
> > 4.86% cat [kernel.kallsyms] [k] bad_range
> > 4.67% cat [kernel.kallsyms] [k] free_unref_page_commit
> > 4.24% cat [kernel.kallsyms] [k] __list_del_entry_valid
> > 3.68% cat [kernel.kallsyms] [k] free_unref_page
> > 3.65% cat [kernel.kallsyms] [k] __list_add_valid
> > 3.19% cat [kernel.kallsyms] [k] __purge_vmap_area_lazy
> > 3.10% cat [kernel.kallsyms] [k] find_vmap_area
> > 3.05% cat [kernel.kallsyms] [k] rcu_cblist_dequeue
> >
> > ...
> >
> > --- a/mm/vmalloc.c
> > +++ b/mm/vmalloc.c
> > @@ -2068,6 +2068,24 @@ struct vm_struct *find_vm_area(const void *addr)
> > return NULL;
> > }
> >
> > +static struct vm_struct *__remove_vm_area(struct vmap_area *va)
> > +{
> > + struct vm_struct *vm = va->vm;
> > +
> > + might_sleep();
>
> Where might __remove_vm_area() sleep?
>
> From a quick scan I'm only seeing vfree(), and that has the
> might_sleep_if(!in_interrupt()).
>
> So perhaps we can remove this...
Agree. Here is the patch.
Thank you!
--
>From 4adf58e4d3ffe45a542156ca0bce3dc9f6679939 Mon Sep 17 00:00:00 2001
From: Roman Gushchin <guro@...com>
Date: Wed, 17 Apr 2019 15:55:49 -0700
Subject: [PATCH] mm: remove might_sleep() in __remove_vm_area()
__remove_vm_area() has a redundant might_sleep() call, which isn't
really required, because the only place it can sleep is vfree()
and it already contains might_sleep_if(!in_interrupt()).
Suggested-by: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Roman Gushchin <guro@...com>
---
mm/vmalloc.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 69a5673c4cd3..4a91acce4b5f 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2079,8 +2079,6 @@ static struct vm_struct *__remove_vm_area(struct vmap_area *va)
{
struct vm_struct *vm = va->vm;
- might_sleep();
-
spin_lock(&vmap_area_lock);
va->vm = NULL;
va->flags &= ~VM_VM_AREA;
--
2.20.1
Powered by blists - more mailing lists