From patchwork Thu Feb 23 00:57:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 5761 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp38128wrd; Wed, 22 Feb 2023 16:59:18 -0800 (PST) X-Google-Smtp-Source: AK7set/1Q1t5BJE3E4jWdX/INsJVGQ3Meh+tIJOIpMw/vMTwhxLFn3ptlCFm1JyhSXPoMtLOBN9z X-Received: by 2002:a05:6a21:6d8d:b0:bf:d38c:5e73 with SMTP id wl13-20020a056a216d8d00b000bfd38c5e73mr12621232pzb.23.1677113957735; Wed, 22 Feb 2023 16:59:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677113957; cv=none; d=google.com; s=arc-20160816; b=KAOkbEwaZ1wxVCbxXall/C2iDlklSrxlR20lk9hUG/VdmPdSQvtX+LbZvd+NmkPGNw 4KnetXHqXHiptUw4kF8JYoEVtpMNqX3X269eGvtViXNt9lnJwD5sqBWVTfnrj/Jmm94g aOgSNDeJcHv7K6ToMjNhcDRsuCCZuhcq5Pho4kBS3NboJQ9PRnKbK6LakULvP7HBdh6H TknbLwE5gdvphdSuW44Uv/stOFrsmcx5GoysYxQ3UHXHl9MWoOg+vCCRB/eIrgjHBQlI bblWXhfJidvdZgziA7Q6XYWHw/LyZFMyHJ3Zl4KObHR38MGr1aQBCLzbbKoSnN+q9dAM kEsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=5DZ3zrglXkc4zRJ24Mq++0gtFytF9RdLpBxclVHmdr8=; b=rgMWxEtaCaZgM+IpOzsgyoLRjg+YqfGTx424L0W1Kqb4OPeK+r9m1rSsD0zM7yz2LR KM1S/PJ6L36J70pj5D+m5GfeNP/WEJ0Zm6aKccCaomXaxRCiguewEyeEayP4CNuVoX3r P743qqFUe4PGcSE6lXL5fR5viO/ezKzMwPMGMPvAqLhHtgxWO+T0yMl+njapF1L1oN1q m9mmburVB3oZUiaUuZu5PUWJPZZCOujaavnZcnn2TGqIHNztrNfl03ogrB3zFhIQe80p 9Q0d3GncOEkZ9Y9/p41ZrzG08tlxoQ5Dkgg1ttTtk17rtz1dDYEg404L9kxUqi0Dtq6Z wjMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=P+0z1HKg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b25-20020a631b19000000b004fc298179b2si4197075pgb.123.2023.02.22.16.59.05; Wed, 22 Feb 2023 16:59:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=P+0z1HKg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232984AbjBWA6H (ORCPT + 99 others); Wed, 22 Feb 2023 19:58:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232981AbjBWA6D (ORCPT ); Wed, 22 Feb 2023 19:58:03 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 265421D92A for ; Wed, 22 Feb 2023 16:58:02 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-53700262a47so59044717b3.4 for ; Wed, 22 Feb 2023 16:58:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=5DZ3zrglXkc4zRJ24Mq++0gtFytF9RdLpBxclVHmdr8=; b=P+0z1HKgEn/jmZlepeouDrAc3nsZOERgHaJzjMzI0moOn4Q1pfkcsgiN2ROL3srMPJ 9ZxjgHEw5llWiD79l0pJMTARN5/8hGRbMIa8H6z3gJqfI2s9Rl31staN5cKjCnKcvT9y UhcLs/Nejr1R69gb/NRqPIUXT75aZIqW3n66ae1dAwxzWpi2f3Nwhc51Gr+lnGFVjuPb x/duqcnpvsCEjLSPrm+XlIvPEbkEVFZRl7i94LhnhE+9C0yAm0OxXnRGwK2Qp0THJWoh yAVA6FQvNP7gm/zHD775wLwrx2HjOCX/uEcb2ENEkxOekuVJ4iyxSd4/R18rdQY8yBfZ 09Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5DZ3zrglXkc4zRJ24Mq++0gtFytF9RdLpBxclVHmdr8=; b=us/dJ0GeKHoovv6p75MCc44sfqx8PT7kwC5jF3h7jYMW1LSefD3xm8/pwxVxBeblZR /rrcYGw8WFZA+wA2MITWqx1OyY7LV/xs52qYGkguh1NcGkszqyDdysK7gKYCXuLRZ239 L05TiOlE8L0eJrj1dL5V51/Iq9zE9C1Q0I12x5UGKyNhSXXXuwYmmj8BRO42Sncgt7TV svduCGNT6g34kYtaHEN4ck/fx8OzI2GSBIOU3q6Du7gKgvfeO1PcyZYxTbDCe/tACsGz oPJiwIDPJOv6vA74I3nPU9GzKLTEq+ueaUpaIPxBjU390G4R8wOxny55unFtrsp9cf8o jhxA== X-Gm-Message-State: AO0yUKUFXHKBekoEMJTBQHrHVnxEAEh5+XClXrHUgjCTYUwYVDwu1nrE NvbQU0I8dMNJ54nfyiw6KVIC1NeGLO8/vV8sNo6X X-Received: from axel.svl.corp.google.com ([2620:15c:2d4:203:3e99:dd9e:9db9:449c]) (user=axelrasmussen job=sendgmr) by 2002:a81:af07:0:b0:52e:bb19:26c0 with SMTP id n7-20020a81af07000000b0052ebb1926c0mr1506007ywh.2.1677113881400; Wed, 22 Feb 2023 16:58:01 -0800 (PST) Date: Wed, 22 Feb 2023 16:57:49 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230223005754.2700663-1-axelrasmussen@google.com> Subject: [PATCH v2 0/5] mm: userfaultfd: refactor and add UFFDIO_CONTINUE_MODE_WP From: Axel Rasmussen To: Alexander Viro , Andrew Morton , Hugh Dickins , Jan Kara , "Liam R. Howlett" , Matthew Wilcox , Mike Kravetz , Mike Rapoport , Muchun Song , Nadav Amit , Peter Xu , Shuah Khan Cc: James Houghton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Axel Rasmussen X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758581445302277503?= X-GMAIL-MSGID: =?utf-8?q?1758581445302277503?= This series, currently based on 6.2, is divided into two parts: - Commits 1-4 refactor userfaultfd ioctl code without behavior changes, with the main goal of improving consistency and reducing the number of function args. - Commit 5 adds UFFDIO_CONTINUE_MODE_WP. The refactors are sorted by increasing controversial-ness, the idea being we could drop some of the refactors if they are deemed not worth it. Changelog: v1->v2: refactor before adding the new flag, to avoid perpetuating messiness Axel Rasmussen (5): mm: userfaultfd: rename functions for clarity + consistency mm: userfaultfd: don't pass around both mm and vma mm: userfaultfd: combine 'mode' and 'wp_copy' arguments mm: userfaultfd: don't separate addr + len arguments mm: userfaultfd: add UFFDIO_CONTINUE_MODE_WP to install WP PTEs fs/userfaultfd.c | 121 +++++------- include/linux/hugetlb.h | 28 ++- include/linux/shmem_fs.h | 8 +- include/linux/userfaultfd_k.h | 57 +++--- include/uapi/linux/userfaultfd.h | 7 + mm/hugetlb.c | 35 ++-- mm/shmem.c | 13 +- mm/userfaultfd.c | 236 +++++++++++------------ tools/testing/selftests/vm/userfaultfd.c | 4 + 9 files changed, 245 insertions(+), 264 deletions(-) --- 2.39.2.637.g21b0678d19-goog