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 F1871C61DA4 for ; Wed, 15 Feb 2023 00:32:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4CBC46B0073; Tue, 14 Feb 2023 19:32:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 47BEC6B0075; Tue, 14 Feb 2023 19:32:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31D9F6B007D; Tue, 14 Feb 2023 19:32:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2460E6B0073 for ; Tue, 14 Feb 2023 19:32:41 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D0C9E1610B6 for ; Wed, 15 Feb 2023 00:32:40 +0000 (UTC) X-FDA: 80467650480.20.3736589 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 747EF4000F for ; Wed, 15 Feb 2023 00:32:38 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cfGW390h; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676421158; 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=0etdia8N+ECGaC0gAhXaKuBpC7aTnF6lYawwxL7alZU=; b=64g3+gZodZf055Ymm8Ix4PnRlfiLj5oYJLHCNV0J7ycwmuA4X2TvBVm6iWwCSFQ4WAMgqP sWWQrL2eWIsJ+oXzl9OA5vsGpAoCW7+fmzy/kpfKmoBPhP2vkNTS3LwX+C+OsgYSLCTQ4G rKzPskCDInKWYfE4VZaTgGy9IY/C0Y4= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cfGW390h; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676421158; a=rsa-sha256; cv=none; b=0IQw7i7En5ppW2Zz3OuRczAcjux+sk/trKvR83o05Tpu8eCxnD1BkzxTTyIVkGUCSEic6D tfemPPjhijt/vldhZ/oAJajelodbc1yOKdZxEtaezHRip3S9YhX7gZBiMOhx44+pAvsawi bAaJTIix2vtPpzZL0t7+YfE5QcLd2Ss= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676421157; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0etdia8N+ECGaC0gAhXaKuBpC7aTnF6lYawwxL7alZU=; b=cfGW390hFBPKIv50Qskfx916BPSKhAV0OmSqzpIee+F7bxyzPZPeipEPisj5uSL5PJNE3V B9dQZKKTSbdSf/zYIbZx66U7K55CBHzpqoNxM7HRQHm3kcxLzN5q7SEFCXwycygwLp6n6a v1qyR8WP8OtqTyRLm/Dgw8fHPXtST0Q= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-35-tI29yJspNlW03WZwqlhJ3g-1; Tue, 14 Feb 2023 19:32:36 -0500 X-MC-Unique: tI29yJspNlW03WZwqlhJ3g-1 Received: by mail-qt1-f200.google.com with SMTP id bz17-20020a05622a1e9100b003b9c1013018so10329874qtb.18 for ; Tue, 14 Feb 2023 16:32:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1676421156; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0etdia8N+ECGaC0gAhXaKuBpC7aTnF6lYawwxL7alZU=; b=KcC8YdwyzZeOuUBI94Gq7Y3LXPhrILQYKi0dL64Eu3SAP0dtsRf69xJ77Z805x6G2o 6xMz1tCz+aHGpfeTTQZpEWDFSsfS1Sh9RjdPvCAGWjwiMnelhqNU5aXq5u6oQa+cbThS DicW12hGAszBv1rPd+OMI3/ArQmqJB5qUp9vt+py4xWgxidDnl/m7ME4gzIeZHV7FSS1 doO1S5k2m3V9G79rbWizReM8xYzaXVwMof7Nm+3DvKyb5t5HMpgu1je4G8MStyRhzXnZ McztgqGdrM2keeiyD/YsMeDfii4sLwhfdnhWMO1Kh7z8Th55Pvx9WsN/YJ3eyEueZnJp BDWQ== X-Gm-Message-State: AO0yUKWswcC0+NmwwWRowbg4bTOtdKNGR2hoteXCYCByR3F5k32ylSg0 nf2+wwwqFitvkNdkRyxLDIeO4VtUOr2DUIReuT/a3OSA6lbJYZ2L8MNmJKRJ8ZVR2OIm098XpLq AzPuxKBvncsc= X-Received: by 2002:a05:622a:5c7:b0:3b8:36f8:830e with SMTP id d7-20020a05622a05c700b003b836f8830emr338498qtb.6.1676421156143; Tue, 14 Feb 2023 16:32:36 -0800 (PST) X-Google-Smtp-Source: AK7set9yOl2ngRxqcgHLXOhO5w1e7vPn8HhnvU3R6YCTj2Nylo/ep0JaoSfrJ2cQznmURLh3CZz7pw== X-Received: by 2002:a05:622a:5c7:b0:3b8:36f8:830e with SMTP id d7-20020a05622a05c700b003b836f8830emr338467qtb.6.1676421155789; Tue, 14 Feb 2023 16:32:35 -0800 (PST) Received: from x1n ([70.30.145.63]) by smtp.gmail.com with ESMTPSA id s6-20020a372c06000000b00727538eb831sm12902269qkh.86.2023.02.14.16.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Feb 2023 16:32:35 -0800 (PST) Date: Tue, 14 Feb 2023 19:32:29 -0500 From: Peter Xu To: Axel Rasmussen Cc: Matthew Wilcox , Alexander Viro , Mike Kravetz , Muchun Song , Andrew Morton , Hugh Dickins , Shuah Khan , "Liam R. Howlett" , Mike Rapoport , 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 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 747EF4000F X-Stat-Signature: agw3zcfxahj634pru73wjucfexgx8b9i X-HE-Tag: 1676421158-548261 X-HE-Meta: U2FsdGVkX1+O3UAmE9Z/xG1CT4mxLR6acubcQMQTFDV8iC0iV/gmK4h0katZaUI2amZpOZaqgd80ss6I8Ax/gQy1qjh+hkDSUlSZzO+Bv3E6G7JobQ2JYAwyg62JnCzPuSAoMA2Ph0NUaIyfX7rRNVXLFql2y/WfyUJ6epZtwH9HKIJ/JFPW6klDrNM/qh527m2J0A/SgRXHeYJ7QqQhZa0JOrCXEddV08vLNlvRAuNxoxo+c+T7XupV8miMUeJe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va/1cgZuMUJIcd018nmyyYYrayFt83o/VJBkq3g7c9hkzALQcCMsr7NKSOkxTvxlhR6TwUz49gviE9aVKiwPXqwmoJkA= 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 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". - 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. - Optionally, we can avoid passing over dst_mm/src_mm all around, when dst_vma/src_vma is there? How about we start from simple? -- Peter Xu