Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1552079

Re: [patch] mm, thp: add new background defrag option

From Michal Hocko <mhocko@kernel.org>
Newsgroups linux.kernel
Subject Re: [patch] mm, thp: add new background defrag option
Date 2017-01-05 17:00 +0100
Message-ID <sWiCm-50p-39@gated-at.bofh.it> (permalink)
References <sW3tE-3b2-17@gated-at.bofh.it> <sWdjk-1Bv-41@gated-at.bofh.it> <sWgKd-3NE-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu 05-01-17 14:58:47, Vlastimil Babka wrote:
[...]
> I'm not a fan of either name, so I've tried to implement my own
> suggestion. Turns out it was easier than expected, as there's no kernel
> boot option for "defer", just for "enabled", so that particular worry
> was unfounded.
> 
> And personally I think that it's less confusing when one can enable defer
> and madvise together (and not any other combination), than having to dig
> up the difference between "defer" and "background".
> 
> I have only tested the sysfs manipulation, not actual THP, but seems to me
> that alloc_hugepage_direct_gfpmask() already happens to process the flags
> in a way that it works as expected.

IMHO this looks indeed much simpler implementation wise, more consistent
from the semantic point of view and less confusing from the usage POV.
 
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 10eedbf14421..cc5ae86169a8 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -150,7 +150,16 @@ static ssize_t triple_flag_store(struct kobject *kobj,
>  				 enum transparent_hugepage_flag deferred,
>  				 enum transparent_hugepage_flag req_madv)
>  {
> -	if (!memcmp("defer", buf,
> +	if (!memcmp("defer madvise", buf,
> +			min(sizeof("defer madvise")-1, count))
> +	    || !memcmp("madvise defer", buf,
> +			min(sizeof("madvise defer")-1, count))) {
> +		if (enabled == deferred)
> +			return -EINVAL;
> +		clear_bit(enabled, &transparent_hugepage_flags);
> +		set_bit(req_madv, &transparent_hugepage_flags);
> +		set_bit(deferred, &transparent_hugepage_flags);
> +	} else if (!memcmp("defer", buf,
>  		    min(sizeof("defer")-1, count))) {
>  		if (enabled == deferred)
>  			return -EINVAL;
> @@ -251,9 +260,12 @@ static ssize_t defrag_show(struct kobject *kobj,
>  {
>  	if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, &transparent_hugepage_flags))
>  		return sprintf(buf, "[always] defer madvise never\n");
> -	if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG, &transparent_hugepage_flags))
> -		return sprintf(buf, "always [defer] madvise never\n");
> -	else if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, &transparent_hugepage_flags))
> +	if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG, &transparent_hugepage_flags)) {
> +		if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, &transparent_hugepage_flags))
> +			return sprintf(buf, "always [defer] [madvise] never\n");
> +		else
> +			return sprintf(buf, "always [defer] madvise never\n");
> +	} else if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, &transparent_hugepage_flags))
>  		return sprintf(buf, "always defer [madvise] never\n");
>  	else
>  		return sprintf(buf, "always defer madvise [never]\n");

-- 
Michal Hocko
SUSE Labs

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[patch] mm, thp: add new background defrag option David Rientjes <rientjes@google.com> - 2017-01-05 00:50 +0100
  Re: [patch] mm, thp: add new background defrag option Mel Gorman <mgorman@techsingularity.net> - 2017-01-05 11:20 +0100
    Re: [patch] mm, thp: add new background defrag option Michal Hocko <mhocko@kernel.org> - 2017-01-05 11:40 +0100
    Re: [patch] mm, thp: add new background defrag option Vlastimil Babka <vbabka@suse.cz> - 2017-01-05 15:00 +0100
      Re: [patch] mm, thp: add new background defrag option Michal Hocko <mhocko@kernel.org> - 2017-01-05 17:00 +0100
      Re: [patch] mm, thp: add new background defrag option David Rientjes <rientjes@google.com> - 2017-01-06 00:00 +0100
        Re: [patch] mm, thp: add new background defrag option Vlastimil Babka <vbabka@suse.cz> - 2017-01-06 10:00 +0100
          Re: [patch] mm, thp: add new background defrag option Michal Hocko <mhocko@kernel.org> - 2017-01-06 15:10 +0100
          Re: [patch] mm, thp: add new background defrag option David Rientjes <rientjes@google.com> - 2017-01-06 23:30 +0100
            Re: [patch] mm, thp: add new background defrag option Vlastimil Babka <vbabka@suse.cz> - 2017-01-09 11:10 +0100
              Re: [patch] mm, thp: add new background defrag option Vlastimil Babka <vbabka@suse.cz> - 2017-01-09 13:10 +0100
              Re: [patch] mm, thp: add new background defrag option David Rientjes <rientjes@google.com> - 2017-01-10 03:30 +0100
                Re: [patch] mm, thp: add new background defrag option Hugh Dickins <hughd@google.com> - 2017-01-10 04:40 +0100
                Re: [patch] mm, thp: add new background defrag option Vlastimil Babka <vbabka@suse.cz> - 2017-01-10 09:50 +0100
                Re: [patch] mm, thp: add new background defrag option David Rientjes <rientjes@google.com> - 2017-01-11 01:00 +0100
                Re: [patch] mm, thp: add new background defrag option Michal Hocko <mhocko@kernel.org> - 2017-01-10 14:10 +0100
                [patch v2] mm, thp: add new defer+madvise defrag option David Rientjes <rientjes@google.com> - 2017-01-11 01:20 +0100
                Re: [patch v2] mm, thp: add new defer+madvise defrag option Vlastimil Babka <vbabka@suse.cz> - 2017-01-11 08:40 +0100
                Re: [patch v2] mm, thp: add new defer+madvise defrag option Michal Hocko <mhocko@kernel.org> - 2017-01-12 09:10 +0100
                Re: [patch v2] mm, thp: add new defer+madvise defrag option Mel Gorman <mgorman@techsingularity.net> - 2017-01-11 10:00 +0100
                Re: [patch v2] mm, thp: add new defer+madvise defrag option Andrew Morton <akpm@linux-foundation.org> - 2017-01-12 01:20 +0100

csiph-web