Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755571AbcCTMmt (ORCPT ); Sun, 20 Mar 2016 08:42:49 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:45089 "EHLO e06smtp17.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755514AbcCTMmj (ORCPT ); Sun, 20 Mar 2016 08:42:39 -0400 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: rapoport@il.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org From: Mike Rapoport To: Andrea Arcangeli Cc: Pavel Emelyanov , LKML , linux-mm@kvack.org, Mike Rapoport , Mike Rapoport Subject: [PATCH 1/5] uffd: Split the find_userfault() routine Date: Sun, 20 Mar 2016 14:42:17 +0200 Message-Id: <1458477741-6942-2-git-send-email-rapoport@il.ibm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1458477741-6942-1-git-send-email-rapoport@il.ibm.com> References: <1458477741-6942-1-git-send-email-rapoport@il.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16032012-0005-0000-0000-00000CF30390 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1670 Lines: 54 From: Pavel Emelyanov I will need one to lookup for userfaultfd_wait_queue-s in different wait queue Signed-off-by: Pavel Emelyanov Signed-off-by: Mike Rapoport --- fs/userfaultfd.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 66cdb44..4f0b53d 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -483,25 +483,30 @@ static int userfaultfd_release(struct inode *inode, struct file *file) } /* fault_pending_wqh.lock must be hold by the caller */ -static inline struct userfaultfd_wait_queue *find_userfault( - struct userfaultfd_ctx *ctx) +static inline struct userfaultfd_wait_queue *find_userfault_in( + wait_queue_head_t *wqh) { wait_queue_t *wq; struct userfaultfd_wait_queue *uwq; - VM_BUG_ON(!spin_is_locked(&ctx->fault_pending_wqh.lock)); + VM_BUG_ON(!spin_is_locked(&wqh->lock)); uwq = NULL; - if (!waitqueue_active(&ctx->fault_pending_wqh)) + if (!waitqueue_active(wqh)) goto out; /* walk in reverse to provide FIFO behavior to read userfaults */ - wq = list_last_entry(&ctx->fault_pending_wqh.task_list, - typeof(*wq), task_list); + wq = list_last_entry(&wqh->task_list, typeof(*wq), task_list); uwq = container_of(wq, struct userfaultfd_wait_queue, wq); out: return uwq; } +static inline struct userfaultfd_wait_queue *find_userfault( + struct userfaultfd_ctx *ctx) +{ + return find_userfault_in(&ctx->fault_pending_wqh); +} + static unsigned int userfaultfd_poll(struct file *file, poll_table *wait) { struct userfaultfd_ctx *ctx = file->private_data; -- 1.9.1