All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Hillf Danton <dhillf@gmail.com>
Cc: Linux-MM <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Michal Hocko <mhocko@suse.cz>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH] mm: hugetlb: bail out unmapping after serving reference page
Date: Wed, 22 Feb 2012 13:06:59 -0800	[thread overview]
Message-ID: <20120222130659.d75b6f69.akpm@linux-foundation.org> (raw)
In-Reply-To: <CAJd=RBALNtedfq+PLPnGKd4i4D0mLiVPdW_7pWWopnSZNC_vqA@mail.gmail.com>

On Wed, 22 Feb 2012 20:35:34 +0800
Hillf Danton <dhillf@gmail.com> wrote:

> When unmapping given VM range, we could bail out if a reference page is
> supplied and it is unmapped, which is a minor optimization.
> 
> Signed-off-by: Hillf Danton <dhillf@gmail.com>
> ---
> 
> --- a/mm/hugetlb.c	Wed Feb 22 19:34:12 2012
> +++ b/mm/hugetlb.c	Wed Feb 22 19:50:26 2012
> @@ -2280,6 +2280,9 @@ void __unmap_hugepage_range(struct vm_ar
>  		if (pte_dirty(pte))
>  			set_page_dirty(page);
>  		list_add(&page->lru, &page_list);
> +
> +		if (page == ref_page)
> +			break;
>  	}
>  	spin_unlock(&mm->page_table_lock);
>  	flush_tlb_range(vma, start, end);

Perhaps add a little comment to this explaining what's going on?


It would be sufficient to do

	if (ref_page)
		break;

This is more efficient, and doesn't make people worry about whether
this value of `page' is the same as the one which
pte_page(huge_ptep_get()) earlier returned.

Why do we evaluate `page' twice inside that loop anyway?  And why do we
check for huge_pte_none() twice?  It looks all messed up.



--
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 internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Hillf Danton <dhillf@gmail.com>
Cc: Linux-MM <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Michal Hocko <mhocko@suse.cz>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH] mm: hugetlb: bail out unmapping after serving reference page
Date: Wed, 22 Feb 2012 13:06:59 -0800	[thread overview]
Message-ID: <20120222130659.d75b6f69.akpm@linux-foundation.org> (raw)
In-Reply-To: <CAJd=RBALNtedfq+PLPnGKd4i4D0mLiVPdW_7pWWopnSZNC_vqA@mail.gmail.com>

On Wed, 22 Feb 2012 20:35:34 +0800
Hillf Danton <dhillf@gmail.com> wrote:

> When unmapping given VM range, we could bail out if a reference page is
> supplied and it is unmapped, which is a minor optimization.
> 
> Signed-off-by: Hillf Danton <dhillf@gmail.com>
> ---
> 
> --- a/mm/hugetlb.c	Wed Feb 22 19:34:12 2012
> +++ b/mm/hugetlb.c	Wed Feb 22 19:50:26 2012
> @@ -2280,6 +2280,9 @@ void __unmap_hugepage_range(struct vm_ar
>  		if (pte_dirty(pte))
>  			set_page_dirty(page);
>  		list_add(&page->lru, &page_list);
> +
> +		if (page == ref_page)
> +			break;
>  	}
>  	spin_unlock(&mm->page_table_lock);
>  	flush_tlb_range(vma, start, end);

Perhaps add a little comment to this explaining what's going on?


It would be sufficient to do

	if (ref_page)
		break;

This is more efficient, and doesn't make people worry about whether
this value of `page' is the same as the one which
pte_page(huge_ptep_get()) earlier returned.

Why do we evaluate `page' twice inside that loop anyway?  And why do we
check for huge_pte_none() twice?  It looks all messed up.




  reply	other threads:[~2012-02-22 21:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-22 12:35 [PATCH] mm: hugetlb: bail out unmapping after serving reference page Hillf Danton
2012-02-22 12:35 ` Hillf Danton
2012-02-22 21:06 ` Andrew Morton [this message]
2012-02-22 21:06   ` Andrew Morton
2012-02-23 13:05   ` Hillf Danton
2012-02-23 13:05     ` Hillf Danton
2012-02-23 20:12     ` Andrew Morton
2012-02-23 20:12       ` Andrew Morton
2012-03-21 21:00       ` Andrew Morton
2012-03-21 21:00         ` Andrew Morton
2012-03-22 13:21         ` Hillf Danton
2012-03-22 13:21           ` Hillf Danton

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=20120222130659.d75b6f69.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dhillf@gmail.com \
    --cc=hughd@google.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.cz \
    /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.