Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4915812pxy; Tue, 27 Apr 2021 15:56:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNiswvdTgPQqTJ/vu0AHdt6hryvm62myCsD1hI7UFbLQ93WTLXSeheeL3O6GuKDGDQjBwQ X-Received: by 2002:a17:906:51d5:: with SMTP id v21mr25944554ejk.252.1619564176823; Tue, 27 Apr 2021 15:56:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619564176; cv=none; d=google.com; s=arc-20160816; b=mhKEDwgE+ExoqPW69vGX7Si1AXmtXczt+xUa3pxpx6hRnKyXHUkDi0OqpBlgsO+Agi XD8vxolgDbvxWc3W47MOMfH2PNv5ovkmeWxqnDtJbfyaFpskWgPGaUJE9BFhPrVaDjS9 PFlGVzfSq5eLve1wmgI8oyWrpL0sdbDOA464BsqNRu+DumxgQi6Ne0CMBZ70ATcJm/RL vuKLiUJJc4/w+Lf+UKRUXNST0MWudg7AwI6hVOpD9xoDF0WszpqnULJIARHwUQ+4nLk0 K6h0td4Nw7SAT/gr9E+/kXreoFwuC+Aj1Usl6HSgiwMI8NOEeBKVqOI8rHmxHNWvaQnJ GMyg== 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:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=WF9F3v0DTQrGhMQixNFSEHJ4K48zSV5jue/NqesrNqw=; b=D5IlqEAbHtfBVTtFLhfTTcaJWINDmXhtsO23oH/CVQYql2SsVNdnnvtEi4vIUzXsRI MltidMmEy7REeuUyS+X4Q4U6Dw+xfHY6QV4FX3tPlasHOwp6IZvayNTZoqZcrG974VEo JFlGv4GjT3gIKy7zmy94mwmFG3wp/V9S7ZoTPYIAIphwIH0RLOHVcwWoW0t6h0oYEyVh DlNjE3Z6jSZpwVYRYMVY392/1XuQkggIvDW/i37r8k7A6KvSRdYX9TKHP8r2RmW/BF52 aC6OOBk9N/4WBrNxMwY6ylbJdJEeV6OmkNp6YGUCuVOLJ3eaTCwdcOpxgDrL4ETLpFvW LZew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=E0rIUMeW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w20si1052700eje.81.2021.04.27.15.55.51; Tue, 27 Apr 2021 15:56:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=E0rIUMeW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S239138AbhD0Wyu (ORCPT + 99 others); Tue, 27 Apr 2021 18:54:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239394AbhD0Wxn (ORCPT ); Tue, 27 Apr 2021 18:53:43 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59CD1C06138C for ; Tue, 27 Apr 2021 15:52:58 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id k134-20020a25248c0000b02904edb2914343so11566055ybk.1 for ; Tue, 27 Apr 2021 15:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=WF9F3v0DTQrGhMQixNFSEHJ4K48zSV5jue/NqesrNqw=; b=E0rIUMeWAgoXEpCSgGFacuFM+ZLoAqWK7X4u5Xdgp+31PQA56XOa/QGxtgDLfgqrvC fr65eCoJ4hgjT9GAidrf06HXEtn9lSMolBwlNj048rZQVvrKH9YfsUU1ugb3m9oRNh8m 4RC9F9WnRcm39mYHDuCLvgGZ2oHStv2UTB/8crxk7MzT8treUGVHoVfJoYLCpDZ8TDZ4 6QwRE+oATYg5O1bFgPNt+nxv6gKrGrEqpxWkvwFrM9CwXBDQfmtfYIz+zGcdSoAI+Ump rf9KbzeE1cMzuP/ldh5eNn8qw967pwi8MhrMX3npQf0JNsMoZbitUZ/LU1YHNQWWcQTj dN2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WF9F3v0DTQrGhMQixNFSEHJ4K48zSV5jue/NqesrNqw=; b=C1RAXhtGjMJNNBuOn/f74p3pRUCLdboExCvFcmaLhLfgam3tTpeO3o+nmeoe6kj0zG 6VketTJa1mwq3UM2GApw+88gN2hHOZuhwHRprZZ5noqLS8TstcHBAJOjZMSmBuJqtnxb xvm1EGhbLfm01QBnXErliALpoO7kSuVQe0pcrDLRH5WXzD4WzVTKeB51G2pBpypTa0QG c3Ya8/MhXf+ygsSEP5/SSo17pDziYHtXU/aTGea543NGGDJlHlO3ZMlhhltq6V4MK/Gg c7JWrS8n7dZsam+v1DN9vBbtXpM0UpAWz+8rtER7hLCOrlBljYvQylr5dQ9o3x/xyXHB cJ3w== X-Gm-Message-State: AOAM530u7dAwwF+GViSlTv+MrM6wT+e5qDsrm/OBk1utuGflNfYVIQqP cWKtJadNN0uPR4Y0cns7sfmsfuW21v0f39a1bKbq X-Received: from ajr0.svl.corp.google.com ([2620:15c:2cd:203:c423:570b:b823:c33e]) (user=axelrasmussen job=sendgmr) by 2002:a25:e803:: with SMTP id k3mr35760658ybd.268.1619563977590; Tue, 27 Apr 2021 15:52:57 -0700 (PDT) Date: Tue, 27 Apr 2021 15:52:39 -0700 In-Reply-To: <20210427225244.4326-1-axelrasmussen@google.com> Message-Id: <20210427225244.4326-6-axelrasmussen@google.com> Mime-Version: 1.0 References: <20210427225244.4326-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog Subject: [PATCH v5 05/10] userfaultfd/shmem: advertise shmem minor fault support From: Axel Rasmussen To: Alexander Viro , Andrea Arcangeli , Andrew Morton , Hugh Dickins , Jerome Glisse , Joe Perches , Lokesh Gidra , Mike Kravetz , Mike Rapoport , Peter Xu , Shaohua Li , Shuah Khan , Stephen Rothwell , Wang Qing Cc: linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, Axel Rasmussen , Brian Geffon , "Dr . David Alan Gilbert" , Mina Almasry , Oliver Upton Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that the feature is fully implemented (the faulting path hooks exist so userspace is notified, and the ioctl to resolve such faults is available), advertise this as a supported feature. Signed-off-by: Axel Rasmussen --- Documentation/admin-guide/mm/userfaultfd.rst | 3 ++- fs/userfaultfd.c | 3 ++- include/uapi/linux/userfaultfd.h | 7 ++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/mm/userfaultfd.rst b/Documentation/admin-guide/mm/userfaultfd.rst index 3aa38e8b8361..6528036093e1 100644 --- a/Documentation/admin-guide/mm/userfaultfd.rst +++ b/Documentation/admin-guide/mm/userfaultfd.rst @@ -77,7 +77,8 @@ events, except page fault notifications, may be generated: - ``UFFD_FEATURE_MINOR_HUGETLBFS`` indicates that the kernel supports ``UFFDIO_REGISTER_MODE_MINOR`` registration for hugetlbfs virtual memory - areas. + areas. ``UFFD_FEATURE_MINOR_SHMEM`` is the analogous feature indicating + support for shmem virtual memory areas. The userland application should set the feature flags it intends to use when invoking the ``UFFDIO_API`` ioctl, to request that those features be diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 468556fb04a9..9f3b8684cf3c 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -1940,7 +1940,8 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx, /* report all available features and ioctls to userland */ uffdio_api.features = UFFD_API_FEATURES; #ifndef CONFIG_HAVE_ARCH_USERFAULTFD_MINOR - uffdio_api.features &= ~UFFD_FEATURE_MINOR_HUGETLBFS; + uffdio_api.features &= + ~(UFFD_FEATURE_MINOR_HUGETLBFS | UFFD_FEATURE_MINOR_SHMEM); #endif uffdio_api.ioctls = UFFD_API_IOCTLS; ret = -EFAULT; diff --git a/include/uapi/linux/userfaultfd.h b/include/uapi/linux/userfaultfd.h index bafbeb1a2624..159a74e9564f 100644 --- a/include/uapi/linux/userfaultfd.h +++ b/include/uapi/linux/userfaultfd.h @@ -31,7 +31,8 @@ UFFD_FEATURE_MISSING_SHMEM | \ UFFD_FEATURE_SIGBUS | \ UFFD_FEATURE_THREAD_ID | \ - UFFD_FEATURE_MINOR_HUGETLBFS) + UFFD_FEATURE_MINOR_HUGETLBFS | \ + UFFD_FEATURE_MINOR_SHMEM) #define UFFD_API_IOCTLS \ ((__u64)1 << _UFFDIO_REGISTER | \ (__u64)1 << _UFFDIO_UNREGISTER | \ @@ -185,6 +186,9 @@ struct uffdio_api { * UFFD_FEATURE_MINOR_HUGETLBFS indicates that minor faults * can be intercepted (via REGISTER_MODE_MINOR) for * hugetlbfs-backed pages. + * + * UFFD_FEATURE_MINOR_SHMEM indicates the same support as + * UFFD_FEATURE_MINOR_HUGETLBFS, but for shmem-backed pages instead. */ #define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0) #define UFFD_FEATURE_EVENT_FORK (1<<1) @@ -196,6 +200,7 @@ struct uffdio_api { #define UFFD_FEATURE_SIGBUS (1<<7) #define UFFD_FEATURE_THREAD_ID (1<<8) #define UFFD_FEATURE_MINOR_HUGETLBFS (1<<9) +#define UFFD_FEATURE_MINOR_SHMEM (1<<10) __u64 features; __u64 ioctls; -- 2.31.1.498.g6c1eba8ee3d-goog