From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3360CC46CD2 for ; Tue, 30 Jan 2024 07:13:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6F906B007B; Tue, 30 Jan 2024 02:13:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AF8EE6B0082; Tue, 30 Jan 2024 02:13:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A45E6B0085; Tue, 30 Jan 2024 02:13:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 87F976B007B for ; Tue, 30 Jan 2024 02:13:14 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5434B1A033B for ; Tue, 30 Jan 2024 07:13:14 +0000 (UTC) X-FDA: 81735111108.29.C66AE30 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id C6E2980015 for ; Tue, 30 Jan 2024 07:13:11 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=URcyGOpC; spf=pass (imf30.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706598791; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=iEFdq6DFhKK6EKe8MRU8y0jWU6sWDWsyvnbywOJJixk=; b=3n7QlkJs/uRyUICYNIUplKv3VwSwD4sTrU37/LCR6iu/8LCIuvefxZWmGTO8/lWi9c6zVk d/4D75QbAEBxvRzuXq6AKvDjtfFyNjXuUX3jTGbu3LsVyT3iznlKfcOGg/hm9LM0w0Wuar 5hszv7mss5Jg/tX8Il/PXH1Y1kxcu+Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706598791; a=rsa-sha256; cv=none; b=d3WqdW/HRdsYrJOB387QV79RZJN9+/BYQ/H1xqGAQfKpk8ir4+V/Pdnbg5XH7e7jDytEBz du9MyTZoZDXpJap0+Ov2+rD3Ng2qGuwy2MCLbNd3f3PbfSZFl5etwKFjKUMJND4/NhFm2z HRJd+gjtd7LASZdMfGhm8uk0KtKr6jU= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=URcyGOpC; spf=pass (imf30.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A8E12626BC; Tue, 30 Jan 2024 07:13:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA419C433F1; Tue, 30 Jan 2024 07:13:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706598790; bh=oGSi+REcwrs/+BSbLE+SMirHJl4MYtMgh21giqxANxg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=URcyGOpCzoFfcwqq4+CtiY0zXkzUO9VlQY0zXZlUmdU/BCjQzauXj54jpM831meQO K0X1PYj3jHRpSoJBdLjon7W6D2gr3dBeYY1I2DTnEoSy+3ntGiStVHJHGQqFrqnEuE qXDWE3IL4e5+sBByPpuqYshj25gNok0773hZ96ypP1OHtQi0h4a69v/CmfdSUR9V9l HMzflFgu+NjI0uhjuYV6FPn99jcAb5zSySMLqC/9UPS+6kBg4zCBUzzA14UphTx2LD b2410FHjjncrH15pUsiYUW+Y1e9XIOIkrr9OMjhE3FNyqpp/Ly5bT2S6h6ElteKOZN iQtMM9dXffgnQ== Date: Tue, 30 Jan 2024 09:12:44 +0200 From: Mike Rapoport To: Lokesh Gidra Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, selinux@vger.kernel.org, surenb@google.com, kernel-team@android.com, aarcange@redhat.com, peterx@redhat.com, david@redhat.com, axelrasmussen@google.com, bgeffon@google.com, willy@infradead.org, jannh@google.com, kaleshsingh@google.com, ngeoffray@google.com, timmurray@google.com Subject: Re: [PATCH v2 1/3] userfaultfd: move userfaultfd_ctx struct to header file Message-ID: References: <20240129193512.123145-1-lokeshgidra@google.com> <20240129193512.123145-2-lokeshgidra@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240129193512.123145-2-lokeshgidra@google.com> X-Stat-Signature: utrogx1y4q3p58otkdbyh7ghraoe9bht X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C6E2980015 X-Rspam-User: X-HE-Tag: 1706598791-743128 X-HE-Meta: U2FsdGVkX1/hpY4gJSb1f8UL9eYN3V4vAZqI4AHXWG5tzzvBsYRUDpYoS7CWuLUPj0wcwNGSJocBBtbOWDnnqgwnisAQgBgCMS6FD1imboZYH3XesiZ33UKrBktdsy2LcbciaZiqI0NW/gF+DCd+UFLNsxRHjQHaH8rftZY9W518/TWMtxdcmkQTZYJeSqQEyufAIfghNVvxYt79bgXg8nbxqnexdBY0xBs6FiVk4XY+5fHhl5AUUKzCWFWgLCey2oQ6fZLpXiQmXVnLaUXHpZKp1csKYax+XOuXO8LfplmivCZ88agV4/qqWTfdq/MOli5RC7/EDqjytPloGfVuJRKRH5TAQ7KvkJFVTAlwMpjAuYonrI3c4+/HH2+aS+oUObRDAnh4o3QdQBYWv4jC5iu9K3tY0cL9i1xmW4AI/FnWBLtGFt85Op/miDQwk4TlT8KxM6EteBEv22M8rXsP7iA1l8XQR44CW1kOL2jO2UEMrVX6WKgZf8AkofNyMqh5qjCOnF2TvEfPD/A7ad6ArwngWz4ktpRxqsTr2J/XNxB4xtEI57vBcYi6rl562fY68QDnHy+uUmv68q8fEECDKfN82wfWt4cqawwrnU/bU6Dj0YmCCT81tFA9tJeE7DCCZX/aU5wifOjUoMPCw4cae5b0Qo8fpq+2yTF+IKEWcW3CvMugFBoQBFpL1SFYwgvHo0euV32LswjckqMXN71HQAyjimr10W5Zxc4ABGzinO6kqLOlNseWLxBy1p3/wJAh9q8T0KgJgB+qKZsehU5cMC/UNK4RuV/epEJ6B1WUKrORNhcHFHhJBnKk6sDGSC/WQy6K/LPX4m/RfpYopqC+qiZTCdfkIQof1ye3Lc8hOwVDpSS2JXSBpx568cZXcw5sFZG/ST2Y1WdMs0bOUSjjn7NyIsZgdt0HhI5Y7pOFDBp/kAeRa5/5LiwszepRcq7M X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Mon, Jan 29, 2024 at 11:35:10AM -0800, Lokesh Gidra wrote: > Moving the struct to userfaultfd_k.h to be accessible from > mm/userfaultfd.c. There are no other changes in the struct. Just a thought, it maybe worth to move all of fs/userfaultfd.c to mm/userfaultfd.c ... > This is required to prepare for using per-vma locks in userfaultfd > operations. > > Signed-off-by: Lokesh Gidra Reviewed-by: Mike Rapoport (IBM) > --- > fs/userfaultfd.c | 39 ----------------------------------- > include/linux/userfaultfd_k.h | 39 +++++++++++++++++++++++++++++++++++ > 2 files changed, 39 insertions(+), 39 deletions(-) > > diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c > index 05c8e8a05427..58331b83d648 100644 > --- a/fs/userfaultfd.c > +++ b/fs/userfaultfd.c > @@ -50,45 +50,6 @@ static struct ctl_table vm_userfaultfd_table[] = { > > static struct kmem_cache *userfaultfd_ctx_cachep __ro_after_init; > > -/* > - * Start with fault_pending_wqh and fault_wqh so they're more likely > - * to be in the same cacheline. > - * > - * Locking order: > - * fd_wqh.lock > - * fault_pending_wqh.lock > - * fault_wqh.lock > - * event_wqh.lock > - * > - * To avoid deadlocks, IRQs must be disabled when taking any of the above locks, > - * since fd_wqh.lock is taken by aio_poll() while it's holding a lock that's > - * also taken in IRQ context. > - */ > -struct userfaultfd_ctx { > - /* waitqueue head for the pending (i.e. not read) userfaults */ > - wait_queue_head_t fault_pending_wqh; > - /* waitqueue head for the userfaults */ > - wait_queue_head_t fault_wqh; > - /* waitqueue head for the pseudo fd to wakeup poll/read */ > - wait_queue_head_t fd_wqh; > - /* waitqueue head for events */ > - wait_queue_head_t event_wqh; > - /* a refile sequence protected by fault_pending_wqh lock */ > - seqcount_spinlock_t refile_seq; > - /* pseudo fd refcounting */ > - refcount_t refcount; > - /* userfaultfd syscall flags */ > - unsigned int flags; > - /* features requested from the userspace */ > - unsigned int features; > - /* released */ > - bool released; > - /* memory mappings are changing because of non-cooperative event */ > - atomic_t mmap_changing; > - /* mm with one ore more vmas attached to this userfaultfd_ctx */ > - struct mm_struct *mm; > -}; > - > struct userfaultfd_fork_ctx { > struct userfaultfd_ctx *orig; > struct userfaultfd_ctx *new; > diff --git a/include/linux/userfaultfd_k.h b/include/linux/userfaultfd_k.h > index e4056547fbe6..691d928ee864 100644 > --- a/include/linux/userfaultfd_k.h > +++ b/include/linux/userfaultfd_k.h > @@ -36,6 +36,45 @@ > #define UFFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK) > #define UFFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS) > > +/* > + * Start with fault_pending_wqh and fault_wqh so they're more likely > + * to be in the same cacheline. > + * > + * Locking order: > + * fd_wqh.lock > + * fault_pending_wqh.lock > + * fault_wqh.lock > + * event_wqh.lock > + * > + * To avoid deadlocks, IRQs must be disabled when taking any of the above locks, > + * since fd_wqh.lock is taken by aio_poll() while it's holding a lock that's > + * also taken in IRQ context. > + */ > +struct userfaultfd_ctx { > + /* waitqueue head for the pending (i.e. not read) userfaults */ > + wait_queue_head_t fault_pending_wqh; > + /* waitqueue head for the userfaults */ > + wait_queue_head_t fault_wqh; > + /* waitqueue head for the pseudo fd to wakeup poll/read */ > + wait_queue_head_t fd_wqh; > + /* waitqueue head for events */ > + wait_queue_head_t event_wqh; > + /* a refile sequence protected by fault_pending_wqh lock */ > + seqcount_spinlock_t refile_seq; > + /* pseudo fd refcounting */ > + refcount_t refcount; > + /* userfaultfd syscall flags */ > + unsigned int flags; > + /* features requested from the userspace */ > + unsigned int features; > + /* released */ > + bool released; > + /* memory mappings are changing because of non-cooperative event */ > + atomic_t mmap_changing; > + /* mm with one ore more vmas attached to this userfaultfd_ctx */ > + struct mm_struct *mm; > +}; > + > extern vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason); > > /* A combined operation mode + behavior flags. */ > -- > 2.43.0.429.g432eaa2c6b-goog > -- Sincerely yours, Mike.