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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC313C433EF for ; Fri, 24 Jun 2022 17:39:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232456AbiFXRjQ (ORCPT ); Fri, 24 Jun 2022 13:39:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232204AbiFXRh4 (ORCPT ); Fri, 24 Jun 2022 13:37:56 -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 D60436DB28 for ; Fri, 24 Jun 2022 10:37:42 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id e85-20020a25e758000000b00668ad2fcfdcso2776845ybh.8 for ; Fri, 24 Jun 2022 10:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=fAGdwktIt8KMFEeY6rcBub88vVCunW5aTmCo6YUaLic=; b=Vv9tNv7i10/uP/TErfNMavUn+CONiybyM+rrVRU58xqDyKcuGlAEDDrYb4H8klnBqK 6JRS9rF1Ax96bUDo9E8Q4msDjYxTQRaGDpgp0PfneuVYFjBRZnNER/PyTbYsKCHGqcfZ wZWHRDAniodz7pO51uXdkiH13sfi6Axk4M+P3ph2OFO2iVkw+faALWo+6f5rgiVVvomg DpY1Vfkw9K59AUl480vwthENZtLgRMWXBf+ShceS/WJ9l4dL6v1IQjWdqA0Jh9uJzr7B 6UZ1PTjJenNdIGVZeRP15MnVvJZeuiEXKSxtsNuQDFnn+yupWoF7oiY8vsG+FIoUiDIP Hx5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=fAGdwktIt8KMFEeY6rcBub88vVCunW5aTmCo6YUaLic=; b=29DP/W2ZUO6j5FvloLuOzmHuL+hT6QPOn3T/ewUJbwqNUithCSw67Z1XhPI3pw5mbB bBOizCSeuoPP3OIbvLGULkNazts3wMvnxwYU4TYeNU0LX4Uf1DNvDlKfRKHE4+xsQuwf QWTeYM9jeRWBnXRGfWWzlkcf1fsHsuFTClVGZQeFXGuktwWXnSHKZzygqnHvF/26bFfZ UDt5wyJV3Hy53WI7+/99qeIuJ1cKSEd4hplj2vtT35fRnuOTUTxRwzW+Kxo8If/0m+2d rFKvi3WQyqcQ4kxbd6kouYShO5OW5+Oi06Eb/EHcW8S8FbfS1cQq167w5vngimvGnfdY bhQQ== X-Gm-Message-State: AJIora+61CntuQgoeBrWGUTJRe1dLmSEZNSzluujcxR5STHj+iM9OKqP OokfuV7sw4lRillueQf6kjRnYo1tKEEAmW6w X-Google-Smtp-Source: AGRyM1s9InsMUuonAQPM2rPsoKgLt0oAO15w8QDXDBNTwbyi4uqbeJxT6CBZesWu39P67C1HtW9QkiD1Grt/J/X2 X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a81:64f:0:b0:318:8841:b44e with SMTP id 76-20020a81064f000000b003188841b44emr29471ywg.216.1656092262019; Fri, 24 Jun 2022 10:37:42 -0700 (PDT) Date: Fri, 24 Jun 2022 17:36:53 +0000 In-Reply-To: <20220624173656.2033256-1-jthoughton@google.com> Message-Id: <20220624173656.2033256-24-jthoughton@google.com> Mime-Version: 1.0 References: <20220624173656.2033256-1-jthoughton@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [RFC PATCH 23/26] userfaultfd: add UFFD_FEATURE_MINOR_HUGETLBFS_HGM From: James Houghton To: Mike Kravetz , Muchun Song , Peter Xu Cc: David Hildenbrand , David Rientjes , Axel Rasmussen , Mina Almasry , Jue Wang , Manish Mishra , "Dr . David Alan Gilbert" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is so that userspace is aware that their kernel was compiled with HugeTLB high-granularity mapping and that UFFDIO_CONTINUE down to PAGE_SIZE-aligned chunks are valid. Signed-off-by: James Houghton --- fs/userfaultfd.c | 7 ++++++- include/uapi/linux/userfaultfd.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 77c1b8a7d0b9..59bfdb7a67e0 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -1935,10 +1935,15 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx, goto err_out; /* 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 | UFFD_FEATURE_MINOR_SHMEM); -#endif +#ifndef CONFIG_HUGETLB_HIGH_GRANULARITY_MAPPING + uffdio_api.features &= ~UFFD_FEATURE_MINOR_HUGETLBFS_HGM; +#endif /* CONFIG_HUGETLB_HIGH_GRANULARITY_MAPPING */ +#endif /* CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */ + #ifndef CONFIG_HAVE_ARCH_USERFAULTFD_WP uffdio_api.features &= ~UFFD_FEATURE_PAGEFAULT_FLAG_WP; #endif diff --git a/include/uapi/linux/userfaultfd.h b/include/uapi/linux/userfaultfd.h index 7d32b1e797fb..50fbcb0bcba0 100644 --- a/include/uapi/linux/userfaultfd.h +++ b/include/uapi/linux/userfaultfd.h @@ -32,6 +32,7 @@ UFFD_FEATURE_SIGBUS | \ UFFD_FEATURE_THREAD_ID | \ UFFD_FEATURE_MINOR_HUGETLBFS | \ + UFFD_FEATURE_MINOR_HUGETLBFS_HGM | \ UFFD_FEATURE_MINOR_SHMEM | \ UFFD_FEATURE_EXACT_ADDRESS | \ UFFD_FEATURE_WP_HUGETLBFS_SHMEM) @@ -213,6 +214,7 @@ struct uffdio_api { #define UFFD_FEATURE_MINOR_SHMEM (1<<10) #define UFFD_FEATURE_EXACT_ADDRESS (1<<11) #define UFFD_FEATURE_WP_HUGETLBFS_SHMEM (1<<12) +#define UFFD_FEATURE_MINOR_HUGETLBFS_HGM (1<<13) __u64 features; __u64 ioctls; -- 2.37.0.rc0.161.g10f37bed90-goog