From: Johannes Weiner <hannes@cmpxchg.org>
To: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Joonsoo Kim <js1304@gmail.com>, Minchan Kim <minchan@kernel.org>,
Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@redhat.com>,
Michel Lespinasse <walken@google.com>
Subject: Re: [PATCH 2/4] mm, rmap: allocate anon_vma_chain before starting to link anon_vma_chain
Date: Wed, 7 Aug 2013 02:08:03 -0400 [thread overview]
Message-ID: <20130807060803.GJ1845@cmpxchg.org> (raw)
In-Reply-To: <1375778620-31593-2-git-send-email-iamjoonsoo.kim@lge.com>
On Tue, Aug 06, 2013 at 05:43:38PM +0900, Joonsoo Kim wrote:
> If we allocate anon_vma_chain before starting to link, we can reduce
> the lock hold time. This patch implement it.
>
> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>
> diff --git a/mm/rmap.c b/mm/rmap.c
> index c2f51cb..1603f64 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -240,18 +240,21 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
> {
> struct anon_vma_chain *avc, *pavc;
> struct anon_vma *root = NULL;
> + LIST_HEAD(avc_list);
> +
> + list_for_each_entry(pavc, &src->anon_vma_chain, same_vma) {
> + avc = anon_vma_chain_alloc(GFP_KERNEL);
> + if (unlikely(!avc))
> + goto enomem_failure;
> +
> + list_add_tail(&avc->same_vma, &avc_list);
> + }
>
> list_for_each_entry_reverse(pavc, &src->anon_vma_chain, same_vma) {
> struct anon_vma *anon_vma;
>
> - avc = anon_vma_chain_alloc(GFP_NOWAIT | __GFP_NOWARN);
> - if (unlikely(!avc)) {
> - unlock_anon_vma_root(root);
> - root = NULL;
> - avc = anon_vma_chain_alloc(GFP_KERNEL);
> - if (!avc)
> - goto enomem_failure;
> - }
> + avc = list_entry((&avc_list)->next, typeof(*avc), same_vma);
list_first_entry() please
> + list_del(&avc->same_vma);
> anon_vma = pavc->anon_vma;
> root = lock_anon_vma_root(root, anon_vma);
> anon_vma_chain_link(dst, avc, anon_vma);
> @@ -259,8 +262,11 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
> unlock_anon_vma_root(root);
> return 0;
>
> - enomem_failure:
> - unlink_anon_vmas(dst);
> +enomem_failure:
> + list_for_each_entry_safe(avc, pavc, &avc_list, same_vma) {
> + list_del(&avc->same_vma);
> + anon_vma_chain_free(avc);
> + }
> return -ENOMEM;
> }
Otherwise, looks good.
Thanks!
--
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>
WARNING: multiple messages have this Message-ID (diff)
From: Johannes Weiner <hannes@cmpxchg.org>
To: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Joonsoo Kim <js1304@gmail.com>, Minchan Kim <minchan@kernel.org>,
Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@redhat.com>,
Michel Lespinasse <walken@google.com>
Subject: Re: [PATCH 2/4] mm, rmap: allocate anon_vma_chain before starting to link anon_vma_chain
Date: Wed, 7 Aug 2013 02:08:03 -0400 [thread overview]
Message-ID: <20130807060803.GJ1845@cmpxchg.org> (raw)
In-Reply-To: <1375778620-31593-2-git-send-email-iamjoonsoo.kim@lge.com>
On Tue, Aug 06, 2013 at 05:43:38PM +0900, Joonsoo Kim wrote:
> If we allocate anon_vma_chain before starting to link, we can reduce
> the lock hold time. This patch implement it.
>
> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>
> diff --git a/mm/rmap.c b/mm/rmap.c
> index c2f51cb..1603f64 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -240,18 +240,21 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
> {
> struct anon_vma_chain *avc, *pavc;
> struct anon_vma *root = NULL;
> + LIST_HEAD(avc_list);
> +
> + list_for_each_entry(pavc, &src->anon_vma_chain, same_vma) {
> + avc = anon_vma_chain_alloc(GFP_KERNEL);
> + if (unlikely(!avc))
> + goto enomem_failure;
> +
> + list_add_tail(&avc->same_vma, &avc_list);
> + }
>
> list_for_each_entry_reverse(pavc, &src->anon_vma_chain, same_vma) {
> struct anon_vma *anon_vma;
>
> - avc = anon_vma_chain_alloc(GFP_NOWAIT | __GFP_NOWARN);
> - if (unlikely(!avc)) {
> - unlock_anon_vma_root(root);
> - root = NULL;
> - avc = anon_vma_chain_alloc(GFP_KERNEL);
> - if (!avc)
> - goto enomem_failure;
> - }
> + avc = list_entry((&avc_list)->next, typeof(*avc), same_vma);
list_first_entry() please
> + list_del(&avc->same_vma);
> anon_vma = pavc->anon_vma;
> root = lock_anon_vma_root(root, anon_vma);
> anon_vma_chain_link(dst, avc, anon_vma);
> @@ -259,8 +262,11 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
> unlock_anon_vma_root(root);
> return 0;
>
> - enomem_failure:
> - unlink_anon_vmas(dst);
> +enomem_failure:
> + list_for_each_entry_safe(avc, pavc, &avc_list, same_vma) {
> + list_del(&avc->same_vma);
> + anon_vma_chain_free(avc);
> + }
> return -ENOMEM;
> }
Otherwise, looks good.
Thanks!
next prev parent reply other threads:[~2013-08-07 6:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-06 8:43 [PATCH 1/4] mm, rmap: do easy-job first in anon_vma_fork Joonsoo Kim
2013-08-06 8:43 ` Joonsoo Kim
2013-08-06 8:43 ` [PATCH 2/4] mm, rmap: allocate anon_vma_chain before starting to link anon_vma_chain Joonsoo Kim
2013-08-06 8:43 ` Joonsoo Kim
2013-08-07 6:08 ` Johannes Weiner [this message]
2013-08-07 6:08 ` Johannes Weiner
2013-08-07 7:17 ` Joonsoo Kim
2013-08-07 7:17 ` Joonsoo Kim
2013-08-06 8:43 ` [PATCH 3/4] mm, rmap: minimize lock hold when unlink_anon_vmas Joonsoo Kim
2013-08-06 8:43 ` Joonsoo Kim
2013-08-07 6:11 ` Johannes Weiner
2013-08-07 6:11 ` Johannes Weiner
2013-08-07 7:18 ` Joonsoo Kim
2013-08-07 7:18 ` Joonsoo Kim
2013-08-06 8:43 ` [PATCH 4/4] mm, page_alloc: optimize batch count in free_pcppages_bulk() Joonsoo Kim
2013-08-06 8:43 ` Joonsoo Kim
2013-08-06 8:48 ` Joonsoo Kim
2013-08-06 8:48 ` Joonsoo Kim
2013-08-06 12:58 ` [PATCH 1/4] mm, rmap: do easy-job first in anon_vma_fork Johannes Weiner
2013-08-06 12:58 ` Johannes Weiner
2013-08-07 7:16 ` Joonsoo Kim
2013-08-07 7:16 ` Joonsoo Kim
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=20130807060803.GJ1845@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=akpm@linux-foundation.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=js1304@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=minchan@kernel.org \
--cc=riel@redhat.com \
--cc=walken@google.com \
/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.