All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] compaction: fix isolate_migratepages_block() for THP=n
Date: Mon, 27 Apr 2015 13:50:25 +0200	[thread overview]
Message-ID: <553E2281.4050102@suse.cz> (raw)
In-Reply-To: <1430134006-215317-1-git-send-email-kirill.shutemov@linux.intel.com>

On 27.4.2015 13:26, Kirill A. Shutemov wrote:
> PageTrans* helpers are always-false if THP is disabled compile-time.
> It means the fucntion will fail to detect hugetlb pages in this case.
> 
> Let's use PageCompound() instead. With small tweak to how we calculate
> next low_pfn it will make function ready to see tail pages.
> 
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

> ---
>  mm/compaction.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 018f08da99a2..6ef2fdf1d6b6 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -732,18 +732,18 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
>  		 * splitting and collapsing (collapsing has already happened
>  		 * if PageLRU is set) but the lock is not necessarily taken
>  		 * here and it is wasteful to take it just to check transhuge.
> -		 * Check TransHuge without lock and skip the whole pageblock if
> -		 * it's either a transhuge or hugetlbfs page, as calling
> +		 * Check PageCompound without lock and skip the whole pageblock
> +		 * if it's either a transhuge or hugetlbfs page, as calling
>  		 * compound_order() without preventing THP from splitting the
>  		 * page underneath us may return surprising results.
>  		 */
> -		if (PageTransHuge(page)) {
> -			if (!locked)
> -				low_pfn = ALIGN(low_pfn + 1,
> -						pageblock_nr_pages) - 1;
> +		if (PageCompound(page)) {
> +			int nr;
> +			if (locked)
> +				nr = 1 << compound_order(page);
>  			else
> -				low_pfn += (1 << compound_order(page)) - 1;
> -
> +				nr = pageblock_nr_pages;
> +			low_pfn = ALIGN(low_pfn + 1, nr) - 1;
>  			continue;
>  		}
>  
> @@ -763,11 +763,12 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
>  			if (!locked)
>  				break;
>  
> -			/* Recheck PageLRU and PageTransHuge under lock */
> +			/* Recheck PageLRU and PageCompound under lock */
>  			if (!PageLRU(page))
>  				continue;
> -			if (PageTransHuge(page)) {
> -				low_pfn += (1 << compound_order(page)) - 1;
> +			if (PageCompound(page)) {
> +				int nr = 1 << compound_order(page);
> +				low_pfn = ALIGN(low_pfn + 1, nr) - 1;
>  				continue;
>  			}
>  		}
> @@ -778,7 +779,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
>  		if (__isolate_lru_page(page, isolate_mode) != 0)
>  			continue;
>  
> -		VM_BUG_ON_PAGE(PageTransCompound(page), page);
> +		VM_BUG_ON_PAGE(PageCompound(page), page);
>  
>  		/* Successfully isolated */
>  		del_page_from_lru_list(page, lruvec, page_lru(page));
> 

--
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: Vlastimil Babka <vbabka@suse.cz>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] compaction: fix isolate_migratepages_block() for THP=n
Date: Mon, 27 Apr 2015 13:50:25 +0200	[thread overview]
Message-ID: <553E2281.4050102@suse.cz> (raw)
In-Reply-To: <1430134006-215317-1-git-send-email-kirill.shutemov@linux.intel.com>

On 27.4.2015 13:26, Kirill A. Shutemov wrote:
> PageTrans* helpers are always-false if THP is disabled compile-time.
> It means the fucntion will fail to detect hugetlb pages in this case.
> 
> Let's use PageCompound() instead. With small tweak to how we calculate
> next low_pfn it will make function ready to see tail pages.
> 
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

> ---
>  mm/compaction.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 018f08da99a2..6ef2fdf1d6b6 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -732,18 +732,18 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
>  		 * splitting and collapsing (collapsing has already happened
>  		 * if PageLRU is set) but the lock is not necessarily taken
>  		 * here and it is wasteful to take it just to check transhuge.
> -		 * Check TransHuge without lock and skip the whole pageblock if
> -		 * it's either a transhuge or hugetlbfs page, as calling
> +		 * Check PageCompound without lock and skip the whole pageblock
> +		 * if it's either a transhuge or hugetlbfs page, as calling
>  		 * compound_order() without preventing THP from splitting the
>  		 * page underneath us may return surprising results.
>  		 */
> -		if (PageTransHuge(page)) {
> -			if (!locked)
> -				low_pfn = ALIGN(low_pfn + 1,
> -						pageblock_nr_pages) - 1;
> +		if (PageCompound(page)) {
> +			int nr;
> +			if (locked)
> +				nr = 1 << compound_order(page);
>  			else
> -				low_pfn += (1 << compound_order(page)) - 1;
> -
> +				nr = pageblock_nr_pages;
> +			low_pfn = ALIGN(low_pfn + 1, nr) - 1;
>  			continue;
>  		}
>  
> @@ -763,11 +763,12 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
>  			if (!locked)
>  				break;
>  
> -			/* Recheck PageLRU and PageTransHuge under lock */
> +			/* Recheck PageLRU and PageCompound under lock */
>  			if (!PageLRU(page))
>  				continue;
> -			if (PageTransHuge(page)) {
> -				low_pfn += (1 << compound_order(page)) - 1;
> +			if (PageCompound(page)) {
> +				int nr = 1 << compound_order(page);
> +				low_pfn = ALIGN(low_pfn + 1, nr) - 1;
>  				continue;
>  			}
>  		}
> @@ -778,7 +779,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
>  		if (__isolate_lru_page(page, isolate_mode) != 0)
>  			continue;
>  
> -		VM_BUG_ON_PAGE(PageTransCompound(page), page);
> +		VM_BUG_ON_PAGE(PageCompound(page), page);
>  
>  		/* Successfully isolated */
>  		del_page_from_lru_list(page, lruvec, page_lru(page));
> 


  reply	other threads:[~2015-04-27 11:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27 11:26 [PATCH] compaction: fix isolate_migratepages_block() for THP=n Kirill A. Shutemov
2015-04-27 11:26 ` Kirill A. Shutemov
2015-04-27 11:50 ` Vlastimil Babka [this message]
2015-04-27 11:50   ` Vlastimil Babka
2015-04-28 22:14 ` Andrew Morton
2015-04-28 22:14   ` Andrew Morton
2015-04-28 22:28   ` Kirill A. Shutemov
2015-04-28 22:28     ` Kirill A. Shutemov
2015-04-28 22:37     ` Andrew Morton
2015-04-28 22:37       ` Andrew Morton
2015-04-28 22:44       ` Kirill A. Shutemov
2015-04-28 22:44         ` Kirill A. Shutemov
2015-06-03  9:14         ` Vlastimil Babka
2015-06-03  9:14           ` Vlastimil Babka
2015-06-03 11:24           ` Kirill A. Shutemov
2015-06-03 11:24             ` Kirill A. Shutemov

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=553E2281.4050102@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=kirill.shutemov@linux.intel.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.