All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Toshi Kani <toshi.kani@hp.com>
Cc: akpm@linux-foundation.org, kirill.shutemov@linux.intel.com,
	willy@linux.intel.com, linux-mm@kvack.org,
	linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: Fix MAP_POPULATE and mlock() for DAX
Date: Sat, 20 Jun 2015 22:46:12 +0300	[thread overview]
Message-ID: <20150620194612.GA5268@node.dhcp.inet.fi> (raw)
In-Reply-To: <1434493710-11138-1-git-send-email-toshi.kani@hp.com>

On Tue, Jun 16, 2015 at 04:28:30PM -0600, Toshi Kani wrote:
> DAX has the following issues in a shared or read-only private
> mmap'd file.
>  - mmap(MAP_POPULATE) does not pre-fault
>  - mlock() fails with -ENOMEM
> 
> DAX uses VM_MIXEDMAP for mmap'd files, which do not have struct
> page associated with the ranges.  Both MAP_POPULATE and mlock()
> call __mm_populate(), which in turn calls __get_user_pages().
> Because __get_user_pages() requires a valid page returned from
> follow_page_mask(), MAP_POPULATE and mlock(), i.e. FOLL_POPULATE,
> fail in the first page.
> 
> Change __get_user_pages() to proceed FOLL_POPULATE when the
> translation is set but its page does not exist (-EFAULT), and
> @pages is not requested.  With that, MAP_POPULATE and mlock()
> set translations to the requested range and complete successfully.
> 
> MAP_POPULATE still provides a major performance improvement to
> DAX as it will avoid page faults during initial access to the
> pages.
> 
> mlock() continues to set VM_LOCKED to vma and populate the range.
> Since there is no struct page, the range is pinned without marking
> pages mlocked.
> 
> Note, MAP_POPULATE and mlock() already work for a write-able
> private mmap'd file on DAX since populate_vma_page_range() breaks
> COW, which allocates page caches.

I don't think that's true in all cases.

We would fail to break COW for mlock() if the mapping is populated with
read-only entries by the mlock() time. In this case follow_page_mask()
would fail with -EFAULT and faultin_page() will never executed.

-- 
 Kirill A. Shutemov

--
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: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Toshi Kani <toshi.kani@hp.com>
Cc: akpm@linux-foundation.org, kirill.shutemov@linux.intel.com,
	willy@linux.intel.com, linux-mm@kvack.org,
	linux-fsdevel@vger.kernel.org, linux-nvdimm@ml01.01.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: Fix MAP_POPULATE and mlock() for DAX
Date: Sat, 20 Jun 2015 22:46:12 +0300	[thread overview]
Message-ID: <20150620194612.GA5268@node.dhcp.inet.fi> (raw)
In-Reply-To: <1434493710-11138-1-git-send-email-toshi.kani@hp.com>

On Tue, Jun 16, 2015 at 04:28:30PM -0600, Toshi Kani wrote:
> DAX has the following issues in a shared or read-only private
> mmap'd file.
>  - mmap(MAP_POPULATE) does not pre-fault
>  - mlock() fails with -ENOMEM
> 
> DAX uses VM_MIXEDMAP for mmap'd files, which do not have struct
> page associated with the ranges.  Both MAP_POPULATE and mlock()
> call __mm_populate(), which in turn calls __get_user_pages().
> Because __get_user_pages() requires a valid page returned from
> follow_page_mask(), MAP_POPULATE and mlock(), i.e. FOLL_POPULATE,
> fail in the first page.
> 
> Change __get_user_pages() to proceed FOLL_POPULATE when the
> translation is set but its page does not exist (-EFAULT), and
> @pages is not requested.  With that, MAP_POPULATE and mlock()
> set translations to the requested range and complete successfully.
> 
> MAP_POPULATE still provides a major performance improvement to
> DAX as it will avoid page faults during initial access to the
> pages.
> 
> mlock() continues to set VM_LOCKED to vma and populate the range.
> Since there is no struct page, the range is pinned without marking
> pages mlocked.
> 
> Note, MAP_POPULATE and mlock() already work for a write-able
> private mmap'd file on DAX since populate_vma_page_range() breaks
> COW, which allocates page caches.

I don't think that's true in all cases.

We would fail to break COW for mlock() if the mapping is populated with
read-only entries by the mlock() time. In this case follow_page_mask()
would fail with -EFAULT and faultin_page() will never executed.

-- 
 Kirill A. Shutemov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

  reply	other threads:[~2015-06-20 19:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-16 22:28 [PATCH] mm: Fix MAP_POPULATE and mlock() for DAX Toshi Kani
2015-06-16 22:28 ` Toshi Kani
2015-06-20 19:46 ` Kirill A. Shutemov [this message]
2015-06-20 19:46   ` Kirill A. Shutemov
2015-06-22 20:55   ` Toshi Kani
2015-06-22 20:55     ` Toshi Kani
2015-06-23 11:44     ` Kirill A. Shutemov
2015-06-23 11:44       ` Kirill A. Shutemov
2015-06-23 22:10       ` Toshi Kani
2015-06-23 22:10         ` Toshi Kani

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=20150620194612.GA5268@node.dhcp.inet.fi \
    --to=kirill@shutemov.name \
    --cc=akpm@linux-foundation.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=toshi.kani@hp.com \
    --cc=willy@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 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.