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>,
Mike Marciniszyn <infinipath@intel.com>,
Roland Dreier <roland@kernel.org>,
Sean Hefty <sean.hefty@intel.com>,
Hal Rosenstock <hal.rosenstock@gmail.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: [RFC][PATCH 5/5] mm,ib,qib: Use VM_PINNED
Date: Mon, 26 May 2014 16:56:10 +0200 [thread overview]
Message-ID: <20140526152108.075622852@infradead.org> (raw)
In-Reply-To: 20140526145605.016140154@infradead.org
[-- Attachment #1: peterz-mm-pinned-5.patch --]
[-- Type: text/plain, Size: 4013 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/qib/qib.h | 2 +-
drivers/infiniband/hw/qib/qib_file_ops.c | 6 +++---
drivers/infiniband/hw/qib/qib_user_pages.c | 16 ++++++----------
3 files changed, 10 insertions(+), 14 deletions(-)
--- a/drivers/infiniband/hw/qib/qib.h
+++ b/drivers/infiniband/hw/qib/qib.h
@@ -1376,7 +1376,7 @@ void qib_sdma_process_event(struct qib_p
#define QIB_RCVHDR_ENTSIZE 32
int qib_get_user_pages(unsigned long, size_t, struct page **);
-void qib_release_user_pages(struct page **, size_t);
+void qib_release_user_pages(struct page **, unsigned long, size_t);
int qib_eeprom_read(struct qib_devdata *, u8, void *, int);
int qib_eeprom_write(struct qib_devdata *, u8, const void *, int);
u32 __iomem *qib_getsendbuf_range(struct qib_devdata *, u32 *, u32, u32);
--- a/drivers/infiniband/hw/qib/qib_file_ops.c
+++ b/drivers/infiniband/hw/qib/qib_file_ops.c
@@ -423,7 +423,7 @@ static int qib_tid_update(struct qib_ctx
dd->pageshadow[ctxttid + tid] = NULL;
}
}
- qib_release_user_pages(pagep, cnt);
+ qib_release_user_pages(pagep, /* vaddr */, cnt);
} else {
/*
* Copy the updated array, with qib_tid's filled in, back
@@ -535,7 +535,7 @@ static int qib_tid_free(struct qib_ctxtd
RCVHQ_RCV_TYPE_EXPECTED, dd->tidinvalid);
pci_unmap_page(dd->pcidev, phys, PAGE_SIZE,
PCI_DMA_FROMDEVICE);
- qib_release_user_pages(&p, 1);
+ qib_release_user_pages(&p, /* vaddr */, 1);
}
}
done:
@@ -1796,7 +1796,7 @@ static void unlock_expected_tids(struct
dd->pageshadow[i] = NULL;
pci_unmap_page(dd->pcidev, phys, PAGE_SIZE,
PCI_DMA_FROMDEVICE);
- qib_release_user_pages(&p, 1);
+ qib_release_user_pages(&p, /* vaddr */, 1);
cnt++;
}
}
--- a/drivers/infiniband/hw/qib/qib_user_pages.c
+++ b/drivers/infiniband/hw/qib/qib_user_pages.c
@@ -54,16 +54,12 @@ static void __qib_release_user_pages(str
static int __qib_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 && !capable(CAP_IPC_LOCK)) {
- ret = -ENOMEM;
+ ret = mm_mpin(start_page, num_pages * PAGE_SIZE);
+ if (ret)
goto bail;
- }
for (got = 0; got < num_pages; got += ret) {
ret = get_user_pages(current, current->mm,
@@ -74,13 +70,12 @@ static int __qib_get_user_pages(unsigned
goto bail_release;
}
- current->mm->pinned_vm += num_pages;
-
ret = 0;
goto bail;
bail_release:
__qib_release_user_pages(p, got, 0);
+ mm_munpin(start_page, num_pages * PAGE_SIZE);
bail:
return ret;
}
@@ -143,15 +138,16 @@ int qib_get_user_pages(unsigned long sta
return ret;
}
-void qib_release_user_pages(struct page **p, size_t num_pages)
+void qib_release_user_pages(struct page **p, unsigned long start_page, size_t num_pages)
{
if (current->mm) /* during close after signal, mm can be NULL */
down_write(¤t->mm->mmap_sem);
__qib_release_user_pages(p, num_pages, 1);
+
if (current->mm) {
- current->mm->pinned_vm -= num_pages;
+ mm_munpin(start_page, num_pages * PAGE_SIZE);
up_write(¤t->mm->mmap_sem);
}
}
--
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 ` [RFC][PATCH 4/5] mm,ib,ipath: " Peter Zijlstra
2014-05-26 14:56 ` Peter Zijlstra [this message]
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.075622852@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).