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: Sasha Levin <sasha.levin@oracle.com>, linux-mm@kvack.org
Subject: Re: [PATCH 1/4] thp: add debugfs handle to split all huge pages
Date: Tue, 5 Jan 2016 10:44:22 +0100	[thread overview]
Message-ID: <568B9076.2060405@suse.cz> (raw)
In-Reply-To: <1450957883-96356-2-git-send-email-kirill.shutemov@linux.intel.com>

On 12/24/2015 12:51 PM, Kirill A. Shutemov wrote:
> Writing 1 into 'split_huge_pages' will try to find and split all huge
> pages in the system. This is useful for debuging.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

It's not very optimized pfn scanner, but that shouldn't matter. I have 
but one suggestion and one fix below.

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

> ---
>   mm/huge_memory.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 59 insertions(+)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index a880f9addba5..99f2a0ecb621 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -27,6 +27,7 @@
>   #include <linux/userfaultfd_k.h>
>   #include <linux/page_idle.h>
>   #include <linux/swapops.h>
> +#include <linux/debugfs.h>
>
>   #include <asm/tlb.h>
>   #include <asm/pgalloc.h>
> @@ -3535,3 +3536,61 @@ static struct shrinker deferred_split_shrinker = {
>   	.scan_objects = deferred_split_scan,
>   	.seeks = DEFAULT_SEEKS,
>   };
> +
> +#ifdef CONFIG_DEBUG_FS
> +static int split_huge_pages_set(void *data, u64 val)
> +{
> +	struct zone *zone;
> +	struct page *page;
> +	unsigned long pfn, max_zone_pfn;
> +	unsigned long total = 0, split = 0;
> +
> +	if (val != 1)
> +		return -EINVAL;
> +
> +	for_each_populated_zone(zone) {
> +		max_zone_pfn = zone_end_pfn(zone);
> +		for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) {
> +			if (!pfn_valid(pfn))
> +				continue;
> +
> +			page = pfn_to_page(pfn);
> +			if (!get_page_unless_zero(page))
> +				continue;
> +
> +			if (zone != page_zone(page))
> +				goto next;

I would do this check before get_page(...). Doesn't matter much, but 
looks odd.

> +
> +			if (!PageHead(page) || !PageAnon(page) ||
> +					PageHuge(page))
> +				goto next;
> +
> +			total++;
> +			lock_page(page);
> +			if (!split_huge_page(page))
> +				split++;
> +			unlock_page(page);
> +next:
> +			put_page(page);
> +		}
> +	}
> +
> +	pr_info("%lu of %lu THP split", split, total);
> +
> +	return 0;
> +}
> +DEFINE_SIMPLE_ATTRIBUTE(split_huge_pages_fops, NULL, split_huge_pages_set,
> +		"%llu\n");
> +
> +static int __init split_huge_pages_debugfs(void)
> +{
> +	void *ret;
> +
> +	ret = debugfs_create_file("split_huge_pages", 0644, NULL, NULL,
> +			&split_huge_pages_fops);
> +	if (!ret)
> +		pr_warn("Failed to create fault_around_bytes in debugfs");

s/fault_around_bytes/split_huge_pages/

> +	return 0;
> +}
> +late_initcall(split_huge_pages_debugfs);
> +#endif
>

--
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>

  reply	other threads:[~2016-01-05  9:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-24 11:51 [PATCH 0/4] THP updates Kirill A. Shutemov
2015-12-24 11:51 ` [PATCH 1/4] thp: add debugfs handle to split all huge pages Kirill A. Shutemov
2016-01-05  9:44   ` Vlastimil Babka [this message]
2015-12-24 11:51 ` [PATCH 2/4] thp: fix regression in handling mlocked pages in __split_huge_pmd() Kirill A. Shutemov
2015-12-24 18:51   ` Dan Williams
2015-12-24 22:56     ` Kirill A. Shutemov
2015-12-25  1:10   ` Sasha Levin
2015-12-25  1:12     ` Dan Williams
2015-12-25  1:17       ` Sasha Levin
2015-12-28 12:58         ` Kirill A. Shutemov
2015-12-24 11:51 ` [PATCH 3/4] mm: stop __munlock_pagevec_fill() if THP enounted Kirill A. Shutemov
2015-12-25  1:09   ` Sasha Levin
2015-12-28 23:22   ` Andrew Morton
2015-12-29 11:27     ` Kirill A. Shutemov
2016-01-05 10:18   ` Vlastimil Babka
2015-12-24 11:51 ` [PATCH 4/4] thp: increase split_huge_page() success rate Kirill A. Shutemov
2015-12-28 23:30   ` Andrew Morton
2015-12-29 20:57     ` Kirill A. Shutemov
2016-01-05 10:22       ` Vlastimil Babka

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=568B9076.2060405@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-mm@kvack.org \
    --cc=sasha.levin@oracle.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.