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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72888C369C2 for ; Wed, 23 Apr 2025 01:12:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04D866B0007; Tue, 22 Apr 2025 21:12:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F14A36B000A; Tue, 22 Apr 2025 21:12:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDD606B000C; Tue, 22 Apr 2025 21:12:09 -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 C29946B0008 for ; Tue, 22 Apr 2025 21:12:09 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2462482717 for ; Wed, 23 Apr 2025 01:12:10 +0000 (UTC) X-FDA: 83363532420.21.49D20EA Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by imf24.hostedemail.com (Postfix) with ESMTP id 4F97C180008 for ; Wed, 23 Apr 2025 01:12:08 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=qAR20BRP; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of 3Zj4IaAYKCEs574r0ot11tyr.p1zyv07A-zzx8npx.14t@flex--surenb.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3Zj4IaAYKCEs574r0ot11tyr.p1zyv07A-zzx8npx.14t@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1745370728; a=rsa-sha256; cv=none; b=G/myWsfFAWLwlGviBvvcmUGWePG7LzPc1+lX481uxfBYMjoLWY2MaJjCyYXrduJB+SE8M8 QClfA0vmJ5BIiR37J9CmPHnT5zTf/wwGXEabw2c5wytEZlrKXHJEMF8e2T/Bfdmha+zUsL ap9Rzzkk2ElOOHFqllWx3PKg8ierxjs= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=qAR20BRP; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of 3Zj4IaAYKCEs574r0ot11tyr.p1zyv07A-zzx8npx.14t@flex--surenb.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3Zj4IaAYKCEs574r0ot11tyr.p1zyv07A-zzx8npx.14t@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1745370728; 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: references:dkim-signature; bh=N6X0yJ+1tr6nd8cb5b2Uw7pevJu1KMurLqJaaGadHK8=; b=n5fMrMZLs9vY4Nwz19OFk9JAeErBwO1UxE5jwDGXwMTZY8yRZ3e+4aWyBRuHIO+522RXfa /3IAWAcWuPbLnCKeOOZLdWFCS4FTVdy0alET7aDB1vHyRibKmNZf5yGe6YV21RpX0QqrR9 6o2m6gLwvAMB+foRobgrNMmxA7rAyao= Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-22c35bafdbdso86166015ad.1 for ; Tue, 22 Apr 2025 18:12:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1745370727; x=1745975527; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=N6X0yJ+1tr6nd8cb5b2Uw7pevJu1KMurLqJaaGadHK8=; b=qAR20BRPi4IDPZeQDlBH4BkTGNn+C7o93iET0dD5ogRQVO+LsVLbPPkaKWViKMV9Yx aHwhVVE+GmATfb8ji+Di9qa+Bjxy8qauUIe15o4L4ctjfqgBLwd8ToeSostLzBKKJZP3 3kFQRnzjeapThXgNZO4JTDNYk/uElGGWAxu8Js0zIgW+CIfCV68kMD+uNEuhXc08EASN E7Jl/vypUqDlRcIXWXaBx4mtZ2YUSjU8mvttA2c7uLDOUT6tFAeeuAYY5J4ph1h5b61s H4z/sI5/XPgnrOSVavuDsgDhi1VQIfr72oyICpCaANnLHe7cvrx5KPbYOZVvVYz93cQ0 lMKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745370727; x=1745975527; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=N6X0yJ+1tr6nd8cb5b2Uw7pevJu1KMurLqJaaGadHK8=; b=bRMKKK0lr+KuxrI1Fv+PMrVz1V3jbeafOLCQUhuVRbCXhKvb83B8k4EAGF3gQ0zFXg Oi7qGLdMEyB923YdlnCOIwPBpQ4BBsX5Xvf6fTKxuNYCySP7R+cBcOw4Br5athFb9nvK W+WUg7UlMwGhzXIkbnupxmw+WoIlZIVMIgmMiMxrCv85L+NQpzio/7/IonU95LY2qAgG U42X7cMOfU+rmDCK3o0UcnZNju/cXT/RGOYShW14GXBZlFCToB415tYYwQ8MRBJbk6Zv 0M8qXZ19Kw50MZEqdPmhf0OBnQFeXZ0TumoR8WnGL9bd//ZteBgHFGjT9/cNjeTFQ2Hy 8kYA== X-Forwarded-Encrypted: i=1; AJvYcCXSMSJAdbEfr9R5W1UsWZHmCREqSxfMEXdm5sLbD0qubW90upUgnCRf18yAh/b//pnXXgxN+81U3w==@kvack.org X-Gm-Message-State: AOJu0YwM8j8rNWlfOgjIXziaMXfoPq9J0rekx9MINGqN3Zw/yF18ZdJ0 W5GpxMcmBt5rIZk0QuFn2VnbOtM+Mh2xHlK2wwKfZtjDalhYmlwaOLMsM6ooS2kmkeyn/M1nPqq zmw== X-Google-Smtp-Source: AGHT+IE3S5KFo8W44ihe4PFjjqIFHz8A0TSTdhT73+ZhDIZfFQ7PKfnO2n3LutJxCeUewf7ii6C4W6VcApI= X-Received: from plbkx3.prod.google.com ([2002:a17:902:f943:b0:220:da6b:5d08]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:98c:b0:224:76f:9e45 with SMTP id d9443c01a7336-22c535838abmr264440465ad.21.1745370726990; Tue, 22 Apr 2025 18:12:06 -0700 (PDT) Date: Tue, 22 Apr 2025 18:12:03 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.49.0.805.g082f7c87e0-goog Message-ID: <20250423011203.2559210-1-surenb@google.com> Subject: [PATCH 1/1] man/man2/ioctl_userfaultfd.2, UFFDIO_MOVE.2const: Add UFFDIO_MOVE page From: Suren Baghdasaryan To: alx@kernel.org Cc: aarcange@redhat.com, lorenzo.stoakes@oracle.com, david@redhat.com, peterx@redhat.com, lokeshgidra@google.com, linux-man@vger.kernel.org, linux-mm@kvack.org, Suren Baghdasaryan Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4F97C180008 X-Stat-Signature: iytbc7xyhdedf6fjhhbm6qq53i4aassz X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1745370728-479364 X-HE-Meta: U2FsdGVkX1+EcllsKoGvRjV7nH4s3UVv+VkS7RMI6zU0CY7L3p8oU83+MoKjdLwpYaLipSkECbd9ywiT7v54mrsdsZqOOPZkmR5cPT/k/HxjpRxWFXZqbu4eGuk8Nd+MI6INlKJkpoalkRZM9zE9aLOTgv7Jf/OCK+XjBFzNOyeYlbn5A9grSe3TkMN39BiJPXP765B4X5j3UE1z8aEimLfo3VxLLMNGhPyGAEs5bUIFUg27jK27ABFPEbqoR/MjSxmh1WVsQZuhr654f43dCRvhnRU2X/iwwgZFuq83MAG7Z+KS/Lj5jS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ot90gPDDdGUFKr16pBBQUqBZZRJvQLgp7UvGxYrVDl4niPQf7BdAJeiVP1ol4fk3MvdjdPoDdnSQFBW90m9omlU+5+QNEXSKuuTJ3OcD7wekHU6GdlQejIDu2p4nuXRPii+4Y9PO12t8U0K0+d2KARTH6eirCejGn7PfN1jcZZJFD33e2aZqgpKy7qzKWvxf0C1DygSE/oEPNNTwz/C8Blh8e92gCXB2pY4PaEsTaRERhblF7r5VrCBMSNLfb 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: List-Subscribe: List-Unsubscribe: Documentation was extracted from the original patch written by Andrea Arcangeli and upstreamed in [1]. Minor edits were made to maintain the same documentation style as other userfaultfd ioctl commands. [1] Signed-off-by: Suren Baghdasaryan --- man/man2/ioctl_userfaultfd.2 | 2 + man/man2const/UFFDIO_MOVE.2const | 149 +++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 man/man2const/UFFDIO_MOVE.2const diff --git a/man/man2/ioctl_userfaultfd.2 b/man/man2/ioctl_userfaultfd.2 index 3cb1b8305..5ec08ca55 100644 --- a/man/man2/ioctl_userfaultfd.2 +++ b/man/man2/ioctl_userfaultfd.2 @@ -69,6 +69,8 @@ events. .TQ .BR UFFDIO_COPY (2const) .TQ +.BR UFFDIO_MOVE (2const) +.TQ .BR UFFDIO_ZEROPAGE (2const) .TQ .BR UFFDIO_WAKE (2const) diff --git a/man/man2const/UFFDIO_MOVE.2const b/man/man2const/UFFDIO_MOVE.2const new file mode 100644 index 000000000..ebeefde22 --- /dev/null +++ b/man/man2const/UFFDIO_MOVE.2const @@ -0,0 +1,149 @@ +'\" t +.\" Written by Andrea Arcangeli +.\" +.\" SPDX-License-Identifier: Linux-man-pages-copyleft +.\" +.TH UFFDIO_MOVE 2const (date) "Linux man-pages (unreleased)" +.SH NAME +UFFDIO_MOVE +\- +atomically move a continuous memory chunk into the userfault registered range +.SH LIBRARY +Standard C library +.RI ( libc ,\~ \-lc ) +.SH SYNOPSIS +.nf +.BR "#include " " /* Definition of " UFFD* " constants */" +.B #include +.P +.BI "int ioctl(int " fd ", UFFDIO_MOVE, struct uffdio_move *" argp ); +.P +.B #include +.P +.fi +.EX +.B struct uffdio_move { +.BR " __u64 dst;" " /* Destination of move */" +.BR " __u64 src;" " /* Source of move */" +.BR " __u64 len;" " /* Number of bytes to move */" +.BR " __u64 mode;" " /* Flags controlling behavior of move */" +.BR " __s64 move;" " /* Number of bytes moved, or negated error */" +.B }; +.EE +.SH DESCRIPTION +Atomically move a continuous memory chunk into the userfault registered +range and optionally wake up the blocked thread. +.P +The following value may be bitwise ORed in +.I mode +to change the behavior of the +.B UFFDIO_MOVE +operation: +.TP +.B UFFDIO_MOVE_MODE_DONTWAKE +Do not wake up the thread that waits for page-fault resolution +.TP +.B UFFDIO_MOVE_MODE_ALLOW_SRC_HOLES +Allow holes in the source virtual range that is being moved. +When not specified, the holes will result in +.B ENOENT +error. +When specified, the holes will be accounted as successfully +moved memory. This is mostly useful to move hugepage aligned +virtual regions without knowing if there are transparent +hugepages in the regions or not, but preventing the risk of +having to split the hugepage during the operation. +.P +The +.I move +field is used by the kernel to return the number of bytes +that was actually moved, or an error (a negated +.IR errno -style +value). The +.I move +field is output-only; +it is not read by the +.B UFFDIO_MOVE +operation. +.P +The operation may fail for various reasons. Usually, remapping of +pages that are not exclusive to the given process fail; once KSM +might deduplicate pages or fork() COW-shares pages during fork() +with child processes, they are no longer exclusive. Further, the +kernel might only perform lightweight checks for detecting whether +the pages are exclusive, and return -EBUSY in case that check fails. +To make the operation more likely to succeed, KSM should be +disabled, fork() should be avoided or MADV_DONTFORK should be +configured for the source VMA before fork(). +.SH RETURN VALUE +On success, +0 is returned. +In this case, the entire area was moved. +.P +On error, \-1 is returned and +.I errno +is set to indicate the error. +.SH ERRORS +.TP +.B EAGAIN +The number of bytes moved (i.e., the value returned in the +.I move +field) +does not equal the value that was specified in the +.I len +field. +.TP +.B EINVAL +Either +.I dst +or +.I len +was not a multiple of the system page size, or the range specified by +.I src +and +.I len +or +.I dst +and +.I len +was invalid. +.TP +.B EINVAL +An invalid bit was specified in the +.I mode +field. +.TP +.BR ENOENT +The source virtual memory range has unmapped holes and +.B UFFDIO_MOVE_MODE_ALLOW_SRC_HOLES +is not set. +.TP +.BR EEXIST +The destination virtual memory range is fully or partially +mapped. +.TP +.BR EBUSY +The pages in the source virtual memory range are either +pinned or not exclusive to the process. The kernel might +only perform lightweight checks for detecting whether the +pages are exclusive. To make the operation more likely to +succeed, KSM should be disabled, fork() should be avoided +or MADV_DONTFORK should be configured for the source virtual +memory area before fork(). +.TP +.BR ENOMEM +Allocating memory needed for the operation failed. +.TP +.BR ESRCH +The target process has exited at the time of a UFFDIO_MOVE +operation. +.SH STANDARDS +Linux. +.SH HISTORY +Linux 6.8. +.SH SEE ALSO +.BR ioctl (2), +.BR ioctl_userfaultfd (2), +.BR userfaultfd (2) +.P +.I linux.git/\:Documentation/\:admin\-guide/\:mm/\:userfaultfd.rst base-commit: 80e2715270fc05d5627c26f88e4c1ba8b093f510 -- 2.49.0.805.g082f7c87e0-goog