From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
To: nasa4836@gmail.com
Cc: Andrew Morton <akpm@linux-foundation.org>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
Michal Hocko <mhocko@suse.cz>,
Andrea Arcangeli <aarcange@redhat.com>,
steve.capper@linaro.org, davidlohr@hp.com,
kirill.shutemov@linux.intel.com, dave.hansen@linux.intel.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm, hugetlb: use list_for_each_entry in region_xxx
Date: Wed, 14 May 2014 14:12:08 -0400 [thread overview]
Message-ID: <5373b205.0429e00a.7447.ffffbab9SMTPIN_ADDED_BROKEN@mx.google.com> (raw)
In-Reply-To: <1400051359-19942-1-git-send-email-nasa4836@gmail.com>
On Wed, May 14, 2014 at 03:09:19PM +0800, Jianyu Zhan wrote:
> Commit 7b24d8616be3 ("mm, hugetlb: fix race in region tracking") has
> changed to use a per resv_map spinlock to serialize against any
> concurrent write operations to the resv_map, thus we don't need
> list_for_each_entry_safe to interate over file_region's any more.
> Use list_for_each_entry is enough.
>
> Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
> ---
> mm/hugetlb.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index c82290b..26b1464 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -156,7 +156,7 @@ struct file_region {
> static long region_add(struct resv_map *resv, long f, long t)
> {
> struct list_head *head = &resv->regions;
> - struct file_region *rg, *nrg, *trg;
> + struct file_region *rg, *nrg;
>
> spin_lock(&resv->lock);
> /* Locate the region we are either in or before. */
> @@ -170,7 +170,7 @@ static long region_add(struct resv_map *resv, long f, long t)
>
> /* Check for and consume any regions we now overlap with. */
> nrg = rg;
> - list_for_each_entry_safe(rg, trg, rg->link.prev, link) {
> + list_for_each_entry(rg, rg->link.prev, link) {
> if (&rg->link == head)
> break;
> if (rg->from > t)
We can call list_del(&rg->link) and kfree(rg) in this loop, so we need to get
the pointer to next entry before running code inside the loop. *_safe variants
do this job, so changing this is wrong, I think.
> @@ -261,7 +261,7 @@ out_nrg:
> static long region_truncate(struct resv_map *resv, long end)
> {
> struct list_head *head = &resv->regions;
> - struct file_region *rg, *trg;
> + struct file_region *rg;
> long chg = 0;
>
> spin_lock(&resv->lock);
> @@ -280,7 +280,7 @@ static long region_truncate(struct resv_map *resv, long end)
> }
>
> /* Drop any remaining regions. */
> - list_for_each_entry_safe(rg, trg, rg->link.prev, link) {
> + list_for_each_entry(rg, rg->link.prev, link) {
> if (&rg->link == head)
> break;
> chg += rg->to - rg->from;
ditto.
Thanks,
Naoya Horiguchi
--
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>
prev parent reply other threads:[~2014-05-14 18:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-14 7:09 Jianyu Zhan
2014-05-14 18:12 ` Naoya Horiguchi [this message]
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=5373b205.0429e00a.7447.ffffbab9SMTPIN_ADDED_BROKEN@mx.google.com \
--to=n-horiguchi@ah.jp.nec.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=dave.hansen@linux.intel.com \
--cc=davidlohr@hp.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--cc=nasa4836@gmail.com \
--cc=steve.capper@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox