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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 813DBC64EC7 for ; Wed, 15 Feb 2023 00:33:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229518AbjBOAd2 (ORCPT ); Tue, 14 Feb 2023 19:33:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230394AbjBOAdZ (ORCPT ); Tue, 14 Feb 2023 19:33:25 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 840FE234E9 for ; Tue, 14 Feb 2023 16:32:38 -0800 (PST) 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-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-527-ajm8ZUgWPvufTyMfWOmWFw-1; Tue, 14 Feb 2023 19:32:36 -0500 X-MC-Unique: ajm8ZUgWPvufTyMfWOmWFw-1 Received: by mail-qt1-f198.google.com with SMTP id n1-20020ac85a01000000b003ba2a2c50f9so10406561qta.23 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=Wlr1gxSgFCifCx0kWPoIR9kyjMpHZ+l7Gu85MKwuy0AHMd83KfRIW4EDBuEPRJDiDp 03EtC8VflunmQ8uVUdtiFiP1SC9x4J2t1n7SbqdzLIbs53DE4OPdlVxAQGFnN+Zj3jwz vP4oBFeLQsWazvh7qhH1PavB5eaudVFPR7vh2/C6KKAvW7RPP9+YT2ZCMo6786+PwmYP MawgU7AeRGLSacTPm7ptin4XYyLmTnZiM9QEr2nbZKhMgehvkqkI3enW4M2/KNee9iIK ynVjsIn7mVp/CXzIi91aBl62Gov4C+F3iayXWtP16c0ZjgDawEwxxS4LsFq/c7mKO77N lSfA== X-Gm-Message-State: AO0yUKWMq1BIfSyYFMm3io6snKudDSOPmuez5PtK34an7W8HGg1PjR9S GOV1s7H9gg6HNs0ta+OOouwNsrvSloqP2vOeQsZYxhRNS1WaR+yRa0eFEJVqzXFZNDQ5Uem4lA+ BcXNwz0OeBjnraNtjBRx9tJgp X-Received: by 2002:a05:622a:5c7:b0:3b8:36f8:830e with SMTP id d7-20020a05622a05c700b003b836f8830emr338507qtb.6.1676421156144; 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 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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