Received: by 10.223.185.116 with SMTP id b49csp4683291wrg; Tue, 27 Feb 2018 00:21:13 -0800 (PST) X-Google-Smtp-Source: AH8x22691xJWYTvazpZpycaZRBiqJeeMYUDCHCTRzrjbeXMM68tH9a9mz/rb4lpGwZQ5fcDoDrzZ X-Received: by 10.167.129.24 with SMTP id b24mr13340933pfi.183.1519719673154; Tue, 27 Feb 2018 00:21:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519719673; cv=none; d=google.com; s=arc-20160816; b=Z4MkMvEjfrx2/++/b8g+1uWWgv/2k3J7v840InaTX8JdPktZl2T1mITbeBLLTinNtk mVMuZ7xEgwpQeBS5QmYd5n2fkSRqat3VrpU2ijMyuniossfxfvhT54Ia1ritrY4LqJXg opVSEH7p61VRM2d0RavmuKzRB24Ejv/bEa1zZGhztKejygIdg3LPCiS5+aSm2hJ2C4n4 DfbFXm7tH9ux4D+XQBIwCz4WusLa42IVITQt4jRfaESk3XMvd5gfFFNu+j61Nn25yhXo ll8LuR3zp8szzcWDwtuDHGJ7m/f8c1L7MIH2GislT87LWSlPO9QI5W8+/Kh7hautZF6d n2lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=kgpLMBLRu6CT24PrvNJ5K7RJpbzV5ddmilv68HAJ0E4=; b=oqNtD6IgBKSMiygzIQTxtJQsYeagi8mW3LIb7oIuy5bbQe/XLnO2SPgpUiW8KNaPcQ 6q4c2uU4EPdwcIcOSsE79Uq7ZN3vHHF3FUhtFnIhOrp00OlPloeA7ytJgUUDo7MWELsb /E7ajyLqNT5MO5eJgMoP7YUEGzi2jVQ4NEjDbMggJLgDhWYvHqREEWuPBaAdTqzNMzXO 1tgeErPJY8iDh2+9XVpEum8mpdvS8A9MFDXoRIADsfOFt4PusVveQoutg3DarcI49R/6 cKKrFVFT08gRSjAv+sc1YMZEMq1FLCy83WVtvE8+GF4nHLM2KbZzah75M9enPwYeszXZ 1gxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1-v6si8403757plk.597.2018.02.27.00.20.58; Tue, 27 Feb 2018 00:21:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752272AbeB0IUL (ORCPT + 99 others); Tue, 27 Feb 2018 03:20:11 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36834 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752201AbeB0IUH (ORCPT ); Tue, 27 Feb 2018 03:20:07 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1R8JOaw064718 for ; Tue, 27 Feb 2018 03:20:07 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gd2k8tnpm-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 27 Feb 2018 03:20:06 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 27 Feb 2018 08:20:01 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 27 Feb 2018 08:19:58 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1R8Jwd946465126; Tue, 27 Feb 2018 08:19:58 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C8B852043; Tue, 27 Feb 2018 07:11:45 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.8.77]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id A958852045; Tue, 27 Feb 2018 07:11:43 +0000 (GMT) Received: by rapoport-lnx (sSMTP sendmail emulation); Tue, 27 Feb 2018 10:19:56 +0200 From: Mike Rapoport To: Andrew Morton , Andrea Arcangeli Cc: Pavel Emelyanov , linux-mm , linux-api , lkml , crml , Mike Rapoport Subject: [PATCH 1/3] userfaultfd: introduce userfaultfd_init_waitqueue helper Date: Tue, 27 Feb 2018 10:19:50 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519719592-22668-1-git-send-email-rppt@linux.vnet.ibm.com> References: <1519719592-22668-1-git-send-email-rppt@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18022708-0012-0000-0000-000005B5E072 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022708-0013-0000-0000-00001931E93A Message-Id: <1519719592-22668-2-git-send-email-rppt@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-27_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802270100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The helper can be used for initialization of wait queue entries for both page-fault and non-cooperative events Signed-off-by: Mike Rapoport --- fs/userfaultfd.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index cec550c8468f..b32c7aaeca6b 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -131,6 +131,15 @@ static int userfaultfd_wake_function(wait_queue_entry_t *wq, unsigned mode, return ret; } +static inline void userfaultfd_init_waitqueue(struct userfaultfd_ctx *ctx, + struct userfaultfd_wait_queue *uwq) +{ + init_waitqueue_func_entry(&uwq->wq, userfaultfd_wake_function); + uwq->wq.private = current; + uwq->ctx = ctx; + uwq->waken = false; +} + /** * userfaultfd_ctx_get - Acquires a reference to the internal userfaultfd * context. @@ -444,12 +453,9 @@ int handle_userfault(struct vm_fault *vmf, unsigned long reason) /* take the reference before dropping the mmap_sem */ userfaultfd_ctx_get(ctx); - init_waitqueue_func_entry(&uwq.wq, userfaultfd_wake_function); - uwq.wq.private = current; + userfaultfd_init_waitqueue(ctx, &uwq); uwq.msg = userfault_msg(vmf->address, vmf->flags, reason, ctx->features); - uwq.ctx = ctx; - uwq.waken = false; return_to_userland = (vmf->flags & (FAULT_FLAG_USER|FAULT_FLAG_KILLABLE)) == -- 2.7.4