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 CE285C61DA4 for ; Thu, 9 Mar 2023 22:28:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231361AbjCIW2R (ORCPT ); Thu, 9 Mar 2023 17:28:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231358AbjCIW2L (ORCPT ); Thu, 9 Mar 2023 17:28:11 -0500 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 782A25983B for ; Thu, 9 Mar 2023 14:28:06 -0800 (PST) Received: by mail-lf1-x12f.google.com with SMTP id g17so4259349lfv.4 for ; Thu, 09 Mar 2023 14:28:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678400884; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=29CZKSnro71XuZ/X2KIXin8EzPbyFRqqtGaiLs6Be54=; b=ticBqftLOEJj1O6T3FL+5n3IsSOfX3ueB2Y43c8FDQ4uOap3RiQmFGRUOH0CB76bmW N4BGaFG13x1VB9kT7Z8vnkrRrGYaw77ky/ykS/Jmwl71i3RmTDV4O+xeeuwHr4iE1dgv JAIyFgMl9jpJ+0UVxiYjYFnwr670JmKMbOVIwPKo69cU7FGny9TbyTP+gLuuGLQLE3Zv fzD3zBQe5tY7651xIBF57WbqmhFJ4mUepK3lQQ0vSdYk9sw/A2m4DRm7oq0l+v72ZL69 eL7guQznFBOxwk8BviPN0K1jHCUmLQTgJCAAjCSb0wk3j4VK5EL/MjbBQnCJSWtqCsuC JtSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678400884; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=29CZKSnro71XuZ/X2KIXin8EzPbyFRqqtGaiLs6Be54=; b=3nVJp8/ATXkCjTUZ39S6tLCeLGfrdOEp6uAKibTtu5uoqoAX0ZbIzoHWzMMpTJXDSH TfQQNcCC+PwhyfpHWTy2YuweGEjJ4zDWhuqXKQyMavVPtsjf2Fj4ppW4KAIarWeycsUH dd+P0b/8KPf4K8Xwz10aYBDEoiwu9+uyKXDG+qbawv69iFGbhBa3laJy6qKdXt+/4lRr t4kr245IZOzsBdSt0u7GUEmcckz/PW6vv6R+yDb6nPj9djru8EX3NI1spaIXPhYYv2JL SRBPAMJXu0NXF/uSs4CVIb+Uo350GcMAS8kdmfejcQyQi665+GQn2kMojMQofLZnQkYG mlrw== X-Gm-Message-State: AO0yUKU08dGC+44nosUHql/+eCu54XdNPs3fxPOtgjtIKqhtwX4yBhHi ehpeLplQDZvr664myTjVGam95q0QayDtUBfpTKsr3g== X-Google-Smtp-Source: AK7set8XKEHB+Eqae38HNHUfYvdzRQBggEBNTeVTBQ831nGlT2poOPKyEfQFXV6pveIx4Q21go/izYSd6MSOZsP2EmI= X-Received: by 2002:ac2:53aa:0:b0:4dc:807a:d140 with SMTP id j10-20020ac253aa000000b004dc807ad140mr7177100lfh.10.1678400884282; Thu, 09 Mar 2023 14:28:04 -0800 (PST) MIME-Version: 1.0 References: <20230308221932.1548827-1-axelrasmussen@google.com> <20230308221932.1548827-5-axelrasmussen@google.com> In-Reply-To: From: Axel Rasmussen Date: Thu, 9 Mar 2023 14:27:27 -0800 Message-ID: Subject: Re: [PATCH v4 4/4] mm: userfaultfd: add UFFDIO_CONTINUE_MODE_WP to install WP PTEs To: Mike Rapoport Cc: Alexander Viro , Andrew Morton , Hugh Dickins , Jan Kara , "Liam R. Howlett" , Matthew Wilcox , Mike Kravetz , Muchun Song , Nadav Amit , Peter Xu , Shuah Khan , James Houghton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 9, 2023 at 1:11=E2=80=AFAM Mike Rapoport wrot= e: > > On Wed, Mar 08, 2023 at 02:19:32PM -0800, Axel Rasmussen wrote: > > UFFDIO_COPY already has UFFDIO_COPY_MODE_WP, so when installing a new > > PTE to resolve a missing fault, one can install a write-protected one. > > This is useful when using UFFDIO_REGISTER_MODE_{MISSING,WP} in > > combination. > > > > This was motivated by testing HugeTLB HGM [1], and in particular its > > interaction with userfaultfd features. Existing userfaultfd code > > supports using WP and MINOR modes together (i.e. you can register an > > area with both enabled), but without this CONTINUE flag the combination > > is in practice unusable. > > > > So, add an analogous UFFDIO_CONTINUE_MODE_WP, which does the same thing > > as UFFDIO_COPY_MODE_WP, but for *minor* faults. > > > > Update the selftest to do some very basic exercising of the new flag. > > > > [1]: https://patchwork.kernel.org/project/linux-mm/cover/20230218002819= .1486479-1-jthoughton@google.com/ > > > > Acked-by: Peter Xu > > Signed-off-by: Axel Rasmussen > > Acked-by: Mike Rapoport (IBM) > > > --- > > fs/userfaultfd.c | 8 ++++++-- > > include/linux/userfaultfd_k.h | 3 ++- > > include/uapi/linux/userfaultfd.h | 7 +++++++ > > mm/userfaultfd.c | 5 +++-- > > tools/testing/selftests/mm/userfaultfd.c | 4 ++++ > > 5 files changed, 22 insertions(+), 5 deletions(-) > > > > diff --git a/include/uapi/linux/userfaultfd.h b/include/uapi/linux/user= faultfd.h > > index 005e5e306266..14059a0861bf 100644 > > --- a/include/uapi/linux/userfaultfd.h > > +++ b/include/uapi/linux/userfaultfd.h > > @@ -297,6 +297,13 @@ struct uffdio_writeprotect { > > struct uffdio_continue { > > struct uffdio_range range; > > #define UFFDIO_CONTINUE_MODE_DONTWAKE ((__u64)1<<0) > > + /* > > + * UFFDIO_CONTINUE_MODE_WP will map the page write protected on > > + * the fly. UFFDIO_CONTINUE_MODE_WP is available only if the > > + * write protected ioctl is implemented for the range > > + * according to the uffdio_register.ioctls. > > + */ > > +#define UFFDIO_CONTINUE_MODE_WP ((__u64)1<<1) > > Please add the description of the new flag to Documentation/ and to the > userfaultfd man pages. Funny enough, neither flag is mentioned in Documentation/ today - I'll add a short passage about both. Happy to update the man pages as well, I'll send that patch separately. Thanks for reviewing! > > > __u64 mode; > > > > /* > > -- > Sincerely yours, > Mike.