From: Peter Zijlstra <peterz@infradead.org>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Christoph Lameter <cl@linux.com>,
Thomas Gleixner <tglx@linutronix.de>,
Andrew Morton <akpm@linux-foundation.org>,
Hugh Dickins <hughd@google.com>, Mel Gorman <mgorman@suse.de>,
Peter Zijlstra <peterz@infradead.org>,
Roland Dreier <roland@kernel.org>,
Sean Hefty <sean.hefty@intel.com>,
Hal Rosenstock <hal.rosenstock@gmail.com>,
Mike Marciniszyn <infinipath@intel.com>
Subject: [RFC][PATCH 4/5] mm,ib,ipath: Use VM_PINNED
Date: Mon, 26 May 2014 16:56:09 +0200 [thread overview]
Message-ID: <20140526152108.018672523@infradead.org> (raw)
In-Reply-To: 20140526145605.016140154@infradead.org
[-- Attachment #1: peterz-mm-pinned-4.patch --]
[-- Type: text/plain, Size: 5490 bytes --]
XXX: got lost, need the start vaddr in the release paths, help?
Use the mm_mpin() call to prepare the vm for a 'persistent'
get_user_pages() call.
Cc: Christoph Lameter <cl@linux.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Mike Marciniszyn <infinipath@intel.com>
Cc: Roland Dreier <roland@kernel.org>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
---
drivers/infiniband/hw/ipath/ipath_file_ops.c | 6 ++---
drivers/infiniband/hw/ipath/ipath_kernel.h | 4 +--
drivers/infiniband/hw/ipath/ipath_user_pages.c | 28 +++++++++++--------------
3 files changed, 18 insertions(+), 20 deletions(-)
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -456,7 +456,7 @@ static int ipath_tid_update(struct ipath
ipath_stats.sps_pageunlocks++;
}
}
- ipath_release_user_pages(pagep, cnt);
+ ipath_release_user_pages(pagep, /* vaddr */, cnt);
} else {
/*
* Copy the updated array, with ipath_tid's filled in, back
@@ -572,7 +572,7 @@ static int ipath_tid_free(struct ipath_p
pci_unmap_page(dd->pcidev,
dd->ipath_physshadow[porttid + tid],
PAGE_SIZE, PCI_DMA_FROMDEVICE);
- ipath_release_user_pages(&p, 1);
+ ipath_release_user_pages(&p, /* vaddr */, 1);
ipath_stats.sps_pageunlocks++;
} else
ipath_dbg("Unused tid %u, ignoring\n", tid);
@@ -2025,7 +2025,7 @@ static void unlock_expected_tids(struct
dd->ipath_pageshadow[i] = NULL;
pci_unmap_page(dd->pcidev, dd->ipath_physshadow[i],
PAGE_SIZE, PCI_DMA_FROMDEVICE);
- ipath_release_user_pages_on_close(&ps, 1);
+ ipath_release_user_pages_on_close(&ps, /* vaddr */, 1);
cnt++;
ipath_stats.sps_pageunlocks++;
}
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -1082,8 +1082,8 @@ static inline void ipath_sdma_desc_unres
#define IPATH_DFLT_RCVHDRSIZE 9
int ipath_get_user_pages(unsigned long, size_t, struct page **);
-void ipath_release_user_pages(struct page **, size_t);
-void ipath_release_user_pages_on_close(struct page **, size_t);
+void ipath_release_user_pages(struct page **, unsigned long, size_t);
+void ipath_release_user_pages_on_close(struct page **, unsigned long, size_t);
int ipath_eeprom_read(struct ipath_devdata *, u8, void *, int);
int ipath_eeprom_write(struct ipath_devdata *, u8, const void *, int);
int ipath_tempsense_read(struct ipath_devdata *, u8 regnum);
--- a/drivers/infiniband/hw/ipath/ipath_user_pages.c
+++ b/drivers/infiniband/hw/ipath/ipath_user_pages.c
@@ -39,7 +39,7 @@
#include "ipath_kernel.h"
static void __ipath_release_user_pages(struct page **p, size_t num_pages,
- int dirty)
+ int dirty)
{
size_t i;
@@ -56,16 +56,12 @@ static void __ipath_release_user_pages(s
static int __ipath_get_user_pages(unsigned long start_page, size_t num_pages,
struct page **p, struct vm_area_struct **vma)
{
- unsigned long lock_limit;
size_t got;
int ret;
- lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
-
- if (num_pages > lock_limit) {
- ret = -ENOMEM;
+ ret = mm_mpin(start_page, num_pages * PAGE_SIZE);
+ if (ret)
goto bail;
- }
ipath_cdbg(VERBOSE, "pin %lx pages from vaddr %lx\n",
(unsigned long) num_pages, start_page);
@@ -78,14 +74,12 @@ static int __ipath_get_user_pages(unsign
if (ret < 0)
goto bail_release;
}
-
- current->mm->pinned_vm += num_pages;
-
ret = 0;
goto bail;
bail_release:
__ipath_release_user_pages(p, got, 0);
+ mm_munpin(start_page, num_pages * PAGE_SIZE);
bail:
return ret;
}
@@ -172,13 +166,13 @@ int ipath_get_user_pages(unsigned long s
return ret;
}
-void ipath_release_user_pages(struct page **p, size_t num_pages)
+void ipath_release_user_pages(struct page **p, unsigned long start_page,
+ size_t num_pages)
{
down_write(¤t->mm->mmap_sem);
__ipath_release_user_pages(p, num_pages, 1);
-
- current->mm->pinned_vm -= num_pages;
+ mm_munpin(start_page, num_pages * PAGE_SIZE);
up_write(¤t->mm->mmap_sem);
}
@@ -186,6 +180,7 @@ void ipath_release_user_pages(struct pag
struct ipath_user_pages_work {
struct work_struct work;
struct mm_struct *mm;
+ unsigned long start_page;
unsigned long num_pages;
};
@@ -195,13 +190,15 @@ static void user_pages_account(struct wo
container_of(_work, struct ipath_user_pages_work, work);
down_write(&work->mm->mmap_sem);
- work->mm->pinned_vm -= work->num_pages;
+ mm_munpin(work->start_page, work->num_pages * PAGE_SIZE);
up_write(&work->mm->mmap_sem);
mmput(work->mm);
kfree(work);
}
-void ipath_release_user_pages_on_close(struct page **p, size_t num_pages)
+void ipath_release_user_pages_on_close(struct page **p,
+ unsigned long start_page,
+ size_t num_pages)
{
struct ipath_user_pages_work *work;
struct mm_struct *mm;
@@ -218,6 +215,7 @@ void ipath_release_user_pages_on_close(s
INIT_WORK(&work->work, user_pages_account);
work->mm = mm;
+ work->start_page = start_page;
work->num_pages = num_pages;
queue_work(ib_wq, &work->work);
--
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>
next prev parent reply other threads:[~2014-05-26 15:29 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-26 14:56 [RFC][PATCH 0/5] VM_PINNED Peter Zijlstra
2014-05-26 14:56 ` [RFC][PATCH 1/5] mm: Introduce VM_PINNED and interfaces Peter Zijlstra
2014-05-29 1:48 ` Rik van Riel
2014-05-29 8:01 ` Peter Zijlstra
2014-05-26 14:56 ` [RFC][PATCH 2/5] mm,perf: Make use of VM_PINNED Peter Zijlstra
2014-05-26 14:56 ` [RFC][PATCH 3/5] mm,ib,umem: Use VM_PINNED Peter Zijlstra
2014-05-26 14:56 ` Peter Zijlstra [this message]
2014-05-26 14:56 ` [RFC][PATCH 5/5] mm,ib,qib: " Peter Zijlstra
2014-05-26 20:19 ` [RFC][PATCH 0/5] VM_PINNED Konstantin Khlebnikov
2014-05-26 20:32 ` Peter Zijlstra
2014-05-26 20:49 ` Konstantin Khlebnikov
2014-05-27 10:29 ` Peter Zijlstra
2014-05-27 10:54 ` Peter Zijlstra
2014-05-27 11:11 ` Konstantin Khlebnikov
2014-05-27 11:50 ` Vlastimil Babka
2014-05-27 13:09 ` Peter Zijlstra
2014-05-27 13:05 ` Peter Zijlstra
2014-05-27 14:34 ` Christoph Lameter
2014-05-27 14:46 ` Peter Zijlstra
2014-05-27 15:14 ` Christoph Lameter
2014-05-27 15:31 ` Peter Zijlstra
2014-05-27 16:31 ` Christoph Lameter
2014-05-27 16:43 ` Peter Zijlstra
2014-05-27 16:56 ` Christoph Lameter
2014-05-27 17:29 ` Peter Zijlstra
2014-05-27 20:00 ` Christoph Lameter
2014-05-28 6:14 ` Peter Zijlstra
2014-08-01 10:16 ` Benjamin Herrenschmidt
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=20140526152108.018672523@infradead.org \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=hal.rosenstock@gmail.com \
--cc=hughd@google.com \
--cc=infinipath@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=roland@kernel.org \
--cc=sean.hefty@intel.com \
--cc=tglx@linutronix.de \
/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).