From: "Mike Rapoport" <rppt@linux.vnet.ibm.com>
To: Andrea Arcangeli <aarcange@redhat.com>
Cc: Pavel Emelyanov <xemul@virtuozzo.com>,
linux-mm <linux-mm@kvack.org>,
Mike Rapoport <rppt@linux.vnet.ibm.com>
Subject: [RFC PATCH 2/5] userfaultfd: introduce userfaultfd_should_wait helper
Date: Tue, 16 May 2017 13:35:59 +0300 [thread overview]
Message-ID: <1494930962-3318-3-git-send-email-rppt@linux.vnet.ibm.com> (raw)
In-Reply-To: <1494930962-3318-1-git-send-email-rppt@linux.vnet.ibm.com>
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
---
fs/userfaultfd.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index b061e96..fee5f08 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -91,21 +91,31 @@ struct userfaultfd_wake_range {
unsigned long len;
};
+static bool userfaultfd_should_wake(struct userfaultfd_wait_queue *uwq,
+ struct userfaultfd_wake_range *range)
+{
+ unsigned long start, len, address;
+
+ /* len == 0 means wake all */
+ address = uwq->msg.arg.pagefault.address;
+ start = range->start;
+ len = range->len;
+ if (len && (start > address || start + len <= address))
+ return false;
+
+ return true;
+}
+
static int userfaultfd_wake_function(wait_queue_t *wq, unsigned mode,
int wake_flags, void *key)
{
struct userfaultfd_wake_range *range = key;
int ret;
struct userfaultfd_wait_queue *uwq;
- unsigned long start, len;
uwq = container_of(wq, struct userfaultfd_wait_queue, wq);
ret = 0;
- /* len == 0 means wake all */
- start = range->start;
- len = range->len;
- if (len && (start > uwq->msg.arg.pagefault.address ||
- start + len <= uwq->msg.arg.pagefault.address))
+ if (!userfaultfd_should_wake(uwq, range))
goto out;
WRITE_ONCE(uwq->waken, true);
/*
--
2.7.4
--
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:[~2017-05-16 10:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-16 10:35 [RFC PATCH 0/5] userfaultfd: non-cooperative: syncronous events Mike Rapoport
2017-05-16 10:35 ` [RFC PATCH 1/5] userfaultfd: introduce userfault_init_waitqueue helper Mike Rapoport
2017-05-16 10:35 ` Mike Rapoport [this message]
2017-05-16 10:36 ` [RFC PATCH 3/5] userfaultfd: non-cooperative: generalize wake key structure Mike Rapoport
2017-05-16 10:36 ` [RFC PATCH 4/5] userfaultfd: non-cooperative: use fault_pending_wqh for all events Mike Rapoport
2017-05-16 10:36 ` [RFC PATCH 5/5] userfaultfd: non-cooperative: allow synchronous EVENT_REMOVE Mike Rapoport
2017-06-27 13:39 ` [RFC PATCH 0/5] userfaultfd: non-cooperative: syncronous events Mike Rapoport
2017-08-11 13:46 ` Blake Caldwell
2017-08-14 4:58 ` Mike Rapoport
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=1494930962-3318-3-git-send-email-rppt@linux.vnet.ibm.com \
--to=rppt@linux.vnet.ibm.com \
--cc=aarcange@redhat.com \
--cc=linux-mm@kvack.org \
--cc=xemul@virtuozzo.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).