linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Dan Williams <dan.j.williams@intel.com>
Cc: akpm@linux-foundation.org, Jan Kara <jack@suse.cz>,
	linux-nvdimm@lists.01.org, linux-mm@kvack.org,
	linux-fsdevel@vger.kernel.org,
	Ross Zwisler <ross.zwisler@linux.intel.com>,
	hch@lst.de,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: Re: [PATCH v2 2/2] mm: always enable thp for dax mappings
Date: Wed, 14 Jun 2017 12:05:46 +0200	[thread overview]
Message-ID: <20170614100546.GC20247@quack2.suse.cz> (raw)
In-Reply-To: <149739531127.20686.15813586620597484283.stgit@dwillia2-desk3.amr.corp.intel.com>

On Tue 13-06-17 16:08:31, Dan Williams wrote:
> The madvise policy for transparent huge pages is meant to avoid unwanted
> allocations of transparent huge pages. It allows a policy of disabling
> the extra memory pressure and effort to arrange for a huge page when it
> is not needed.
> 
> DAX by definition never incurs this overhead since it is statically
> allocated. The policy choice makes even less sense for device-dax which
> tries to guarantee a given tlb-fault size. Specifically, the following
> setting:
> 
> 	echo never > /sys/kernel/mm/transparent_hugepage/enabled
> 
> ...violates that guarantee and silently disables all device-dax
> instances with a 2M or 1G alignment. So, let's avoid that non-obvious
> side effect by force enabling thp for dax mappings in all cases.
> 
> It is worth noting that the reason this uses vma_is_dax(), and the
> resulting header include changes, is that previous attempts to add a
> VM_DAX flag were NAKd.
> 
> Cc: Jan Kara <jack@suse.cz>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

OK, makes sense. I can imagine some people would like to tune whether DAX
uses huge pages or not but that would make sense as a separate knob
(possibly on per-fs basis) and let's wait for real requests for this
functionality. So:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  include/linux/dax.h     |    5 -----
>  include/linux/fs.h      |    6 ++++++
>  include/linux/huge_mm.h |    5 +++++
>  3 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/dax.h b/include/linux/dax.h
> index 1f6b6072af64..cbaf3d53d66b 100644
> --- a/include/linux/dax.h
> +++ b/include/linux/dax.h
> @@ -151,11 +151,6 @@ static inline unsigned int dax_radix_order(void *entry)
>  #endif
>  int dax_pfn_mkwrite(struct vm_fault *vmf);
>  
> -static inline bool vma_is_dax(struct vm_area_struct *vma)
> -{
> -	return vma->vm_file && IS_DAX(vma->vm_file->f_mapping->host);
> -}
> -
>  static inline bool dax_mapping(struct address_space *mapping)
>  {
>  	return mapping->host && IS_DAX(mapping->host);
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 803e5a9b2654..5916ab3a12d5 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -18,6 +18,7 @@
>  #include <linux/bug.h>
>  #include <linux/mutex.h>
>  #include <linux/rwsem.h>
> +#include <linux/mm_types.h>
>  #include <linux/capability.h>
>  #include <linux/semaphore.h>
>  #include <linux/fiemap.h>
> @@ -3042,6 +3043,11 @@ static inline bool io_is_direct(struct file *filp)
>  	return (filp->f_flags & O_DIRECT) || IS_DAX(filp->f_mapping->host);
>  }
>  
> +static inline bool vma_is_dax(struct vm_area_struct *vma)
> +{
> +	return vma->vm_file && IS_DAX(vma->vm_file->f_mapping->host);
> +}
> +
>  static inline int iocb_flags(struct file *file)
>  {
>  	int res = 0;
> diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
> index c8119e856eb1..5a86f615f3cb 100644
> --- a/include/linux/huge_mm.h
> +++ b/include/linux/huge_mm.h
> @@ -1,6 +1,8 @@
>  #ifndef _LINUX_HUGE_MM_H
>  #define _LINUX_HUGE_MM_H
>  
> +#include <linux/fs.h> /* only for vma_is_dax() */
> +
>  extern int do_huge_pmd_anonymous_page(struct vm_fault *vmf);
>  extern int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
>  			 pmd_t *dst_pmd, pmd_t *src_pmd, unsigned long addr,
> @@ -95,6 +97,9 @@ static inline bool transparent_hugepage_enabled(struct vm_area_struct *vma)
>  	if (transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_FLAG))
>  		return true;
>  
> +	if (vma_is_dax(vma))
> +		return true;
> +
>  	if (transparent_hugepage_flags &
>  				(1 << TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG))
>  		return !!(vma->vm_flags & VM_HUGEPAGE);
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

--
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:[~2017-06-14 10:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-13 23:08 [PATCH v2 0/2] mm: force enable thp for dax Dan Williams
2017-06-13 23:08 ` [PATCH v2 1/2] mm: improve readability of transparent_hugepage_enabled() Dan Williams
2017-06-14 10:00   ` Jan Kara
2017-06-14 12:45   ` Michal Hocko
2017-06-14 19:26     ` Dan Williams
2017-06-15  8:07       ` Michal Hocko
2017-06-15 20:06         ` Andrew Morton
2017-06-15 22:23           ` Michal Hocko
2017-06-15 20:21         ` Dan Williams
2017-06-15 22:22           ` Michal Hocko
2017-06-15 23:44             ` Dan Williams
2017-06-14 16:53   ` Vlastimil Babka
2017-06-14 17:02     ` Dan Williams
2017-06-14 17:11       ` Vlastimil Babka
2017-06-13 23:08 ` [PATCH v2 2/2] mm: always enable thp for dax mappings Dan Williams
2017-06-14 10:05   ` Jan Kara [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=20170614100546.GC20247@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=dan.j.williams@intel.com \
    --cc=hch@lst.de \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=ross.zwisler@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).