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 A9586C369D5 for ; Wed, 23 Apr 2025 19:53:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94D206B0005; Wed, 23 Apr 2025 15:53:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FC2F6B0007; Wed, 23 Apr 2025 15:53:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C2BC6B0008; Wed, 23 Apr 2025 15:53:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5E54E6B0005 for ; Wed, 23 Apr 2025 15:53:14 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EC3381206C8 for ; Wed, 23 Apr 2025 19:53:15 +0000 (UTC) X-FDA: 83366357550.01.FC3BAD1 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf26.hostedemail.com (Postfix) with ESMTP id 39E74140003 for ; Wed, 23 Apr 2025 19:53:14 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=pUFOv4KP; spf=pass (imf26.hostedemail.com: domain of 3KUUJaAYKCCAOQNAJ7CKKCHA.8KIHEJQT-IIGR68G.KNC@flex--surenb.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3KUUJaAYKCCAOQNAJ7CKKCHA.8KIHEJQT-IIGR68G.KNC@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1745437994; 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=9ZM3RQEpIYwnUPDE3f5zc14DNB4WiWuq3xNj3WWAwPw=; b=2EJ1ikcAl9z/neR1iKqosQ0oUtO8ky4WhinyMuiLOY2041Y64tE+tuf+qq2N8w4x76QGUP cmJKrlQezEsU3fu+Z+sAFjHhY8ECgTt6d+n+MtXiMpapz3PLf3CapqNVbKSNr428AMePng FBMjr3h/XFTscQqtkAiznPCQB0CEQKI= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=pUFOv4KP; spf=pass (imf26.hostedemail.com: domain of 3KUUJaAYKCCAOQNAJ7CKKCHA.8KIHEJQT-IIGR68G.KNC@flex--surenb.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3KUUJaAYKCCAOQNAJ7CKKCHA.8KIHEJQT-IIGR68G.KNC@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1745437994; a=rsa-sha256; cv=none; b=zll8DMq6b9/01Lg8ncr4edvC6OWtyi7KnqFSfcdnOWE2I7+NOwkKofhmbWn3mt6gxqyD7p 59XDzuGwexyucgdA7zcvr3evyhT4I8j4PbKUX2WMv4+9rGtVMA1E7H1jXJtlmBfF9QkfQd Ao++gxvsS3lsPOBxUYfrD6p5RM6SBR4= Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-225429696a9so2731375ad.1 for ; Wed, 23 Apr 2025 12:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1745437993; x=1746042793; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=9ZM3RQEpIYwnUPDE3f5zc14DNB4WiWuq3xNj3WWAwPw=; b=pUFOv4KPeFZKoWGEllegzEyAd0eU0ayL/W/3+Kw+BdVUuy98/2WizvUZ3a3le2ZvMG +sTUOnSWpty0d9rJF7ZZv/RzcFNeh2CX0WXUgmjTYNPr2dsN4Iiw+niAl1u5y39/Mttx SNlXdcA5kUE+1NC1rfMRvVtur+AfSxZlSIuWMORShzWnTjFz5oh3qpOaLwFUihKwbl/1 x/nnB0BBaASaU5quZSpJsQNZ3NSkHVj8aXFLOsgDPfte4D37oiC+XdvO37M2y8iaOkLB HeyRueBle840iCP6iHsfUHp8A8iD/ueyCnxPfrX32TzpzTfeBLzS3CbhTBN+WnXxFjtG HEhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745437993; x=1746042793; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=9ZM3RQEpIYwnUPDE3f5zc14DNB4WiWuq3xNj3WWAwPw=; b=OM8U+xUzYGnlwPHuZayog3zG8UP4W6ZjrAVTXoyYwrpnvwkSdXj76pkcYWxc1u0A6j of1SGNVadlDbTWMA22FMsJInaDWE5t2VCupBhhn1VWxGL7Pd7NENqNysqLpIvZN/ylVA Ci9ZjW3otGFRMKy/q/WbjUAAhN98phdWM/9whlcUsTXKvwGh/2znIpZYj/jIJ06m9/ik LA0y/KxxhvNeUk8z9uz2s6pSoNx1GsLGUQietbA894o3eSEsw0ng60/KrSxS/3calNCE X2URTim0H2SKLta0WBtmNXsg3WfcIlgCuTeXVjky8ktiwbhvvhSLi0Rh9bWvy5xImSBm dkHA== X-Forwarded-Encrypted: i=1; AJvYcCUwtGwr1axIVx1547f8PLw50mCch26ixBu8aH2QBb3VlA2KSzBfZ+6tOFXiAjdYX64gwD4qW9ZtNg==@kvack.org X-Gm-Message-State: AOJu0Yyh8KPGENegDoFEQkQn6VScXmnk71QhxTRyu/nRUvd1XCt0G53l 31Fkb+FoaCfR8yHjlEx3M7HFPA4PCYF91uXDs7oUeQfi1tieHWuUEgffQTCaWqddbKAbOfX7UMj Nng== X-Google-Smtp-Source: AGHT+IEmlOi678Vh1nwns2dGjWRwYZXObKJV25OfJdrUZKA4073GA1mUugAvu5B0egUh1d7WmERw5x9TURQ= X-Received: from plfh4.prod.google.com ([2002:a17:902:f544:b0:220:e8a0:ec20]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:11c5:b0:224:1609:a74a with SMTP id d9443c01a7336-22c536043a6mr311710055ad.34.1745437993125; Wed, 23 Apr 2025 12:53:13 -0700 (PDT) Date: Wed, 23 Apr 2025 12:53:09 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.49.0.805.g082f7c87e0-goog Message-ID: <20250423195309.2841410-1-surenb@google.com> Subject: [PATCH v2 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-Stat-Signature: zrmmkmq9e4odm511b4spff3zmnoqnz57 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 39E74140003 X-Rspam-User: X-HE-Tag: 1745437994-853883 X-HE-Meta: U2FsdGVkX1/hUoAnwpbDzTcrWg6n0watbvCDZZthhyEO/8lEuXPeKrPv9Nsa7OoVr8j48ypA0Hx+Cv4zqV8GO62kxN3BUd+YCAXgwo+drdM+Dtc9drSf6m8cOfhsKBA/L3KHoK2Z+uMxGsolvrguQjr1FttOMkZoSZrqGOwTipISvD8CaOjPOTqZfp9PysgCLm4Ij7oN3yrzr2Nl7orlRuKADiJgEP1AuuQPnMJlG7sbK34blzVhAIt5JCi6QZIsNNgh6fWvkobZ135z363pZkElaE0t4xTz3UTjvsYURm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C5mF1KXypo8ncWhVAiPKVEgTSYxxWj2nKoHHMOWBl3aVnzwGHfYSomalIg0RzS32H5nz6qmwZQKl86b2O7iy0LjOFYjkmGfb2RtSC8/yCRqNIwIVx/Et4+j5TlFcLJvS9KIf7QtuQLd8ibYSZwvrWcqPULQ9cJiF+SHB2LY6KV6OQVa9K0EmHu3OVeGp5xqAyX8ozhMxEUzcgfIdKmwmzvVeUzi32t5348MZb65TR43hlrMTZqXMKQgMha73owYklCNF 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 --- Changes since v1[1] - removed '\" t, per Alejandro Colomar - reformated sentences to use semantic newlines, per Alejandro Colomar - changed field names to use '.' prefix, per Alejandro Colomar - changed EBUSY, UFFDIO_MOVE and MADV_DONTFORK to be bold, per Alejandro Colomar - folded duplicate information into EBUSY error description, per Alejandro Colomar [1] https://lore.kernel.org/all/20250423011203.2559210-1-surenb@google.com/ man/man2/ioctl_userfaultfd.2 | 2 + man/man2const/UFFDIO_MOVE.2const | 153 +++++++++++++++++++++++++++++++ 2 files changed, 155 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..77b0ca781 --- /dev/null +++ b/man/man2const/UFFDIO_MOVE.2const @@ -0,0 +1,153 @@ +.\" 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. +.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. +Once KSM deduplicates pages +or fork() COW-shares pages during fork() with child processes, +they are no longer exclusive. +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 +.B 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 +.B 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