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 728C9C369D9 for ; Wed, 30 Apr 2025 22:59:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 539AE6B00AB; Wed, 30 Apr 2025 18:59:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C0A06B00AC; Wed, 30 Apr 2025 18:59:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 339A66B00AD; Wed, 30 Apr 2025 18:59:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 088446B00AB for ; Wed, 30 Apr 2025 18:59:56 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2ECD3C1040 for ; Wed, 30 Apr 2025 22:59:56 +0000 (UTC) X-FDA: 83392229592.19.506380F Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by imf01.hostedemail.com (Postfix) with ESMTP id 71C1E4000E for ; Wed, 30 Apr 2025 22:59:54 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=UQmzgzd5; spf=pass (imf01.hostedemail.com: domain of surenb@google.com designates 209.85.160.176 as permitted sender) smtp.mailfrom=surenb@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=1746053994; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=crlMHHWmbRilD8SwD7XtvOvFQMbdx3BLtc3vb+HPWkg=; b=xTCaKT9zr8BL3vTPHedFhlej+G3qSzPHUuZgIb32ID/wQHL6de5iM8Nfvsjs60BLgA06rd Vlm/d7pmrzk1UJ+hD65gKKK2y7WPQrC+ei7oKzdtIe5IoRNXkr9yWqcZrp1z/n0ryApJZK lwJmaZPM3P94UzHBQFXgLEW28gV2CXk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=UQmzgzd5; spf=pass (imf01.hostedemail.com: domain of surenb@google.com designates 209.85.160.176 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1746053994; a=rsa-sha256; cv=none; b=O5SkEuLG4cpMJqoFEicsItpjsf4HE7lnbVHW5YZFDI+9zoYP8NCEDacOcCkAtGm/qET8Dj r1QfVForSAD7uY0deV8zdjfIsk+wwZugTUD9NCXtseFAvI38F6hcJG3WCs1oNTitGGgMi1 WJnLuDpJv78CZzQzopjJOpEVQOEQ5hQ= Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-4774611d40bso57181cf.0 for ; Wed, 30 Apr 2025 15:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1746053993; x=1746658793; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=crlMHHWmbRilD8SwD7XtvOvFQMbdx3BLtc3vb+HPWkg=; b=UQmzgzd5Uf65tygSCkZnr+4pvQfRf2imU5Odpjv/a4Pn4rieR80HNk40JwDQne2IR/ HA/DpowZeLEdmhck7J9RFMlJRthxOx14OGkrQPK52kzSw+tS6YZO01FpOD2dp8TVf4kI XtqSZRZV+V4MTcA93RmuNjn2KYFLn+EWQpkaojGvrQmywL/sB9egqW+beTzBX+lbyhti GMeNA4YayNNKWeaEEZWxgRAZAVepVH6teUxZHPuU2+NR6aV2aGW0Cr/FI2T2ucHdNpXa jnU28c9+wwosM6ooIByXuwunv3xu/S7AUCfqJkSJrYwk9PNQSSge62qHH3zCp37uzmzi 2SoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746053993; x=1746658793; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=crlMHHWmbRilD8SwD7XtvOvFQMbdx3BLtc3vb+HPWkg=; b=cNB4R8GcF68FBsacAaOTstjbok4VGzSOUKS9f/xAC+Rb7sT4bCQSoG4/M4SKp5XxFG fMLwK1bQXX4hFlG5JcLxdgHdHRZ3XPnYhXMRqZcYJy/ZtDALU+sZCQWwXdznq+U9USyt TtYE4+ZACU1Nk4QP6Sk2VFLR/OzJzfb2EgvqZ4CNDD1HZTA2QO/LW3j4G0HaBGr7bA4b ++T+Bagl/3YM8/gN6ALcMkagD7NZHs7P4SIVTPMybFOHD+glkNUygcfQE/wF5k4Akv1r fQZ3GTeDN9fSacbckPqkeyUyuggKcdPx0lpkx72gtFxYO1KXOwndaPQZqaHjZM36XKcI y4sg== X-Forwarded-Encrypted: i=1; AJvYcCVvMrPBlMk0Ep2pOfaoBHdcB+Auw6cqm4CxQJP1LDZ7iggnIXcpe2+NN/CQDkD8g92xAL7kL05MJA==@kvack.org X-Gm-Message-State: AOJu0YwXD9UbxB+DbXvJ8m0KAaHzFYo/xvJ5WlG828yhE4lqBeGqnfOw lE8VYuzcf9TV0IlS3W2GQ/3pK2fBQrvv9vJAOvLrp7/FtO8iJQC1Tt5bVbvzvyTZYQD1POnpweC qF/TsbO/zuN2qPeJpQkPFPXFkBmL+wUFShJzf X-Gm-Gg: ASbGncvPbjomM+XnC4TreKYmN+YcUuH8VODsq2WV0Nddv8sD3b+zqQGPjUhB7gtJ1+S F0aUCZK9a67TQnc8PtrtLlzDMUawWG1Vq8D82CK0sdpenAHfjSN8DtwufvzFMrihgtQsCwCnxLC TqyTUeYulfx2TzY1lQF8Go X-Google-Smtp-Source: AGHT+IHnkIzbUtvzvQqWg7bu0k+SVz5Y9Ns42I8dbVa9BdYTq/Xi666lcridvYhSfSvv25UdkxAIkbLQINQ57s4IVmk= X-Received: by 2002:a05:622a:11:b0:486:8711:19af with SMTP id d75a77b69052e-48ae773409emr1791871cf.0.1746053993306; Wed, 30 Apr 2025 15:59:53 -0700 (PDT) MIME-Version: 1.0 References: <20250423195309.2841410-1-surenb@google.com> In-Reply-To: <20250423195309.2841410-1-surenb@google.com> From: Suren Baghdasaryan Date: Wed, 30 Apr 2025 15:59:42 -0700 X-Gm-Features: ATxdqUFzALW3hlb2DvU0zqyTxnzGB0jHFlv1eVtYaoc4UMi_VGSdoE370JP9W3o Message-ID: Subject: Re: [PATCH v2 1/1] man/man2/ioctl_userfaultfd.2, UFFDIO_MOVE.2const: Add UFFDIO_MOVE page 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: weg6ty8s3qjpqk4hsfwrz9ztdgpsu4ma X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 71C1E4000E X-Rspam-User: X-HE-Tag: 1746053994-184333 X-HE-Meta: U2FsdGVkX1+ZwBfG9HBd97RFanGaUXYimRpgH/zYQFIDRrAtML0iCAbbSRR0/JeGeWU22rvBy9EoOQLuKG2xsTVnJhQx0HVHZInSAkPbReW6CwmQOhJuZahJhXxHFFvDzPYqEUnv4LlUE9UbAImWyCo2MaHdVgQijYkPx1LAtpJIyDEUehirU4gU3Oma4Ud2+ETZYhlHcZr16ljj425lbIICX5qI9l0UkjZIK09zyMICIGUZ+bXwjLykiTR3wLpqXdHxCJWO1rsRQJkIpScPVhyETRXORIrZSfRNEnOo3xrP8KPcMBMYWzYzlASYtugzCTEub2bQmveHzjZ+iZL7MCEl0yNRpR9PAgC0WA6HCjxKiCHFISczZDWZOI7DiaUgyearTYKXrXj1SepalG3084M+ouZ05ch/q3/RjedkAsG7woeY7B6KyuYGuFm62Q0BpeuvUnih2h+WqARF64qnEDz7crXn1EzyBck4UVgkUVaCrXCkgV9xsfZYu7Y3NAzNUTgDPTc/IjdvDtsrcDxWD8+pcsnazoH/6fhAa0MozuXCCPTJjAyAUBn3Ysb/kKzCuTq+JeFrmp8KK3+IDyyTPQXpEHEn95dYQV6NEQfsnjxSkUbupZF6HR5nv7ZWcdRJZhPv9Tg76EpHzW+ADHFRZ+AXxOTkBd+788Xm5x+yK8V2EMZn8YORj/pJINZPGAQLe9pl+7GJZy2oGkSPAuOrfnwlo7QkhxM7w2HCLYmYSsKqeANGt4U3jcN4Sw7iPVja1xsqiriTMBdQ15yxgkAA0JJZm0fkeZ2N7GzdVVDhg3m1nujx3/pfzPZ5H7P3W6pDxmBE+ix7IDS3bgT7Tt1mdFvlx702IOSPxHQHWVihZAWZ2esPo4aB8VyiRX/d/XHuIZ2OqsHgNM9YrHvaEnVPT8zboJXSEsnVeygJgpy+WSL8fPQRTS3yILHTPqirQZO8uV3HOMNlgKM= 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: On Wed, Apr 23, 2025 at 12:53=E2=80=AFPM Suren Baghdasaryan wrote: > > 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 Hi Alex, Haven't seen any feedback on this version so far. Is it ok to be accepted or should I change anything else? Thanks, Suren. > > [1] https://lore.kernel.org/all/20250423011203.2559210-1-surenb@google.co= m/ > > 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* " const= ants */" > +.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 >