From patchwork Fri Jun 24 17:36:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 12894948 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB3F1C433EF for ; Fri, 24 Jun 2022 17:37:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 714698E0255; Fri, 24 Jun 2022 13:37:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6262F8E0244; Fri, 24 Jun 2022 13:37:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 452158E0255; Fri, 24 Jun 2022 13:37:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2905F8E0244 for ; Fri, 24 Jun 2022 13:37:43 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0F135B82 for ; Fri, 24 Jun 2022 17:37:43 +0000 (UTC) X-FDA: 79613836806.29.6B4FC17 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf22.hostedemail.com (Postfix) with ESMTP id 9D719C001B for ; Fri, 24 Jun 2022 17:37:42 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id j11-20020a05690212cb00b006454988d225so2747957ybu.10 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=zRB0XzcxwD7VilMIezMsXb9nrm2p38wHErSJ3OhEOBuHAwGPE/pKciUn703DXF6/X/ 7ACy3dUQuD7pE5duRsLS2nQE1F0E1mzHGe//0dPcr5M/MdN7UQtCMNmfuGEJA+gy9B4P n1jF0Itt4ddTEfttVWSC6BGRxRJ6FqtVMK6M5w2RHqbU9/3GZW3fCakZnl4nkeiyYxSl uub6pQwIPtqOv8vMZ4291rKDwQrlpqXCN+TqwGTcFcd23AaPrPCC4R6cPufRMsWtqaBk Eagc3t8Ci8mzwglahJPAPAviBL4jlfpiqRb1ApkxN1Yy+1D55pHlriqMQ+8l8K8dVDQl hhVg== X-Gm-Message-State: AJIora97SwRowjCb6NJ+F9QYkqaKdt950u/T81tdMNHnhhKPaXUB8P4q cANFi6s+gwiQCsGenCcYOIkhPEfK2i3lG0SH 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656092262; a=rsa-sha256; cv=none; b=7OAC45d09VreWnlXIi7itqptSn75NxUE2mdOIAgQkEwF1T38OoghUdkA4aBaMii2kDWxf+ AT76JvSqQ2XDhlKu7QEW67tWiN8koK8fL1PJ4CGSeq2VpWkNfHIczpIOGLZ5ryTPMxgiPC NmuRRSCq8bWHp/xOLNEZD3000ivIMKU= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Vv9tNv7i; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of 3Zva1YgoKCEcs2qx3pq2xwpxxpun.lxvurw36-vvt4jlt.x0p@flex--jthoughton.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3Zva1YgoKCEcs2qx3pq2xwpxxpun.lxvurw36-vvt4jlt.x0p@flex--jthoughton.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656092262; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fAGdwktIt8KMFEeY6rcBub88vVCunW5aTmCo6YUaLic=; b=KwCij3egO0UUqRi4+h21LGPAHwnCGbV+HukPf23wRfgjUb/TOBWmiwwd9V9eQGXSd8H0oP 9EKcDo+B//ZyWCE//K+pithnRsWdwts4RpTnXaE29Jsd40NGVx8/S/ChkA6AVmcNULnIGs fYyMCPAZWqruj72QQr0sA1syB/+ymb4= X-Rspam-User: X-Stat-Signature: kfcc1euct4xo4wwnpo98ys4sd71fk9yt X-Rspamd-Queue-Id: 9D719C001B Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Vv9tNv7i; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of 3Zva1YgoKCEcs2qx3pq2xwpxxpun.lxvurw36-vvt4jlt.x0p@flex--jthoughton.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3Zva1YgoKCEcs2qx3pq2xwpxxpun.lxvurw36-vvt4jlt.x0p@flex--jthoughton.bounces.google.com X-Rspamd-Server: rspam03 X-HE-Tag: 1656092262-882068 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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;