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 E999DC636CC for ; Wed, 15 Feb 2023 06:38:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D88D6B0073; Wed, 15 Feb 2023 01:38:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 563316B0074; Wed, 15 Feb 2023 01:38:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4293B6B0075; Wed, 15 Feb 2023 01:38:05 -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 3282E6B0073 for ; Wed, 15 Feb 2023 01:38:05 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 05A494147B for ; Wed, 15 Feb 2023 06:38:05 +0000 (UTC) X-FDA: 80468571330.20.EBA13DF Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf30.hostedemail.com (Postfix) with ESMTP id 3BACA801EA for ; Wed, 15 Feb 2023 06:38:02 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=banI3owi; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676443083; 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=oLDtQxAWmmqYS20ncYILDFQzTssZ2/dzeNQbqHKEtT0=; b=uFZBs0LSxF/hWNJSHs5sJcQ92jV3pVuPr2BTUu7/77DveRaWX75JdjZNdSxfPT0EJCxaJB RkuSjF/cg+Tl5JpUF+vysUKQ0Nniux1phLuWmcLrUAFmfNutdBwItnW/v0dXart3/tgPs2 M00jxUmCPwEE5l3oH29cDAHBTvdnOIU= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=banI3owi; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676443083; a=rsa-sha256; cv=none; b=8C3dd2KwaBA8PMcSya6VjBb2x6gK4y1dp54BwB6RTlAkmim74DBQM/gYWUI1CLGZX6jV6g XYRqATmjtaPH3NeKdcqF/jzaVTlZDJlwTINwQS93wJkWO4g2mW9Z3KdALc1tXohOViqIEs LZH+YaNuVhJqTsJ/PJb5FmFTdh+jWcE= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3F82CB81F86; Wed, 15 Feb 2023 06:38:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98798C433D2; Wed, 15 Feb 2023 06:37:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676443080; bh=nbfks5SxqpR0gszR04yvv2KhvKHnEe8MOnFIrLhiFeE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=banI3owiXJMy4ikQsPCws6BAl+NVP/yRML79hRHm+Cnwifzt7jE2PIYEV62dfrP45 C1Wu4BDDNJQjjLFHzsCJh+5tVobqqS0SE3axS851ssrcuRWzv1TUjO7KcI7R+UmVky Fv5GTCz3DtvW2/ILGMCQzooaPjvDQFr99L6sKhDmm3TSkIiLvrC7emttWZCiE4oIQm kCfrOMyyoCHgvK/PjzKTwqQvUNA5Zmne6PUB+hwZAG7jaD1/VMkt15ZO6Nlajuqkbd /niuTN2iphHLaPwTwbCfDLY9hU2bldFDVUX0+WAdwP1LKi67U0IFoExjnTSXSJsVFS sPJNIO/4dBqrQ== Date: Wed, 15 Feb 2023 08:37:43 +0200 From: Mike Rapoport To: Peter Xu Cc: Axel Rasmussen , Matthew Wilcox , Alexander Viro , Mike Kravetz , Muchun Song , Andrew Morton , Hugh Dickins , Shuah Khan , "Liam R. Howlett" , Nadav Amit , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, James Houghton Subject: Re: [PATCH] mm: userfaultfd: add UFFDIO_CONTINUE_MODE_WP to install WP PTEs Message-ID: References: <20230214215046.1187635-1-axelrasmussen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 3BACA801EA X-Stat-Signature: hn18ss5fgjo9pdmub6a75dph3m1ys47t X-HE-Tag: 1676443082-124747 X-HE-Meta: U2FsdGVkX1/IKsQOhd3y6IitWzHXJPU9mEcw+zmyhDrXKVyV3f4J0AJVbPyLsch6Dxg9z8VjGVnlvRRmZMyOcgLeGW/jVsbzO60COdBTijupwTu38HpT2uUNFwpkg/ge+3aLRHGk9vfrxiR4oJzL9ujACvnuE/YxKTHaVkCsbjSPnuPkJrLAgv7IV1YKsp6ij6Kr+kwm16k02M9Z3TNqUh3gnYXADwjltUOp2ylcFwvLw5DdaMeVZQw44+M5cGM7uQRktgOHRaEsFwdCD3o1AKtacKvVGzNUP2DHYUy/GUVwVFInQp5WDdhm38DG5v1nfVSVp7CI763nEohNTgmXXH1RlxbPhMiaWvPHdbMtXMHaUv8G8QboOX8Tn40hzgpQzUyH+8UwI148MPmXZpKY02CeezWaanqV11Of37nMXQPjkQ1D9aRVxXxpGzQVe4BJTQrTY1EIrACmewkD/qtRc8uGJZrKwhXbMgrOklcnC7toQoemGWEd0FtqPHr72h+5jfNGrMEFNcq7H1y1lxUxrSQePs9r8zKkjnhTcSNoEr4z9fUYmeAQYicY4aB0K9Bd70zpmRRjU0L75exsnZaw9QLpg+uYS+AMlnSbyDP4QYOD5OJGPc9RBJWVCfP+lhI16veqyX1EOMQRIum7GK8fZN6QNm08itFNWVpd+4C6oTCmTU9OtOwd+svLtmea11ez5OYtHiy0X0+wSerxOOyKvX4SHg3eIwC5t9nVWEOvTgbX7FgMqMoN00Y38AGBM2kDX8p9waK3Kk1QZpmpMKuA1vwgzhN4IPAzOIf7UPenuDA/MYU/3ZEQ8+/utmLntwjW6zAJxFnXPKnzC8dui6rZStz6LvuosH9pdjPk8f2n1s9oTXe3dsavgLv7E2IqAtAb9ZdOFqfD+jpt2PrsGDWUXS4LfkqTjyXpfCvutO6lGziixuBBYag4aSNmIXOBsmDTrMy6kT5dw11U9y3KWAI j4dTPaWO 7H9BA26qUc/xRB0A5xdZvSefvc3Fjy17FIjtUQ5xJNFwrxBAuKrTygxq7kAU+UR8EYd1P+sdyv5EKzb569gelM5PF1IGYSuU6VnShynIO3kHpVYQXFPn9xU4ZE6c3eOiZezpKoP+9sgGKcpTyJu8LiaQB9I0yG8UQaq/hGzRBJLGU+WhZMsstglQpNUhrNAi4xdCrJrfVO98FiPE1mmbCkGEZRfBJvOUXTEGPeddn8t34b8T16M7xRzMYZOeP5INZVke3g4fgeYMdqCFPO5dlstJKudKx5k62vSPhUiENG3aw7cpqSA9fyfu65KbO8+kM3BLvU8tk+H1mp9hzIscldCLzazVMEdx98cJf 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: On Tue, Feb 14, 2023 at 07:32:29PM -0500, Peter Xu wrote: > On Tue, Feb 14, 2023 at 02:37:51PM -0800, Axel Rasmussen wrote: > > Agreed, it would likely be a nice cleanup. Peter, any objections? I > > wouldn't mind writing a commit to do this sort of refactor, and rebase > > my change on top of that. > > No objection here. Personally I actually prefer keeping the parameters > around if possible because it's straightforward and no thinking of any > possible indirect accesses all over the place. But maybe growing as long as > 8 is still a moot point.. It's just that I don't really know whether it'll > look that good if we put everything into a struct*. > > Things like src_start/dst_start/.. do not look good to be there: each layer > could loop over its own range of start/end/... so even if not in the > function parameter we'll need a variable to hold them anyway. > > But I do see a few low hanging fruits: > > - I don't see why we need to pass over mmap_changing over all of the > __mcopy_atomic() callers. One chance is we simply pass in the ctx* to > replace "dst_mm + mmap_changing". Now ctx* is completely private to fs/userfaultfd.c and I think it'd be better to keep it this way. > - Merge mcopy_atomic_mode and mode, having last 2 bits for the existing > three modes, then bit 3 for WP, good enough to set it for the new case. Agree, having flags instead of an enum and bools sounds better to me. > - Optionally, we can avoid passing over dst_mm/src_mm all around, when > dst_vma/src_vma is there? +1 > How about we start from simple? > > -- > Peter Xu > -- Sincerely yours, Mike.