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 75CFBC369D9 for ; Wed, 30 Apr 2025 23:23:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D8C0D6B00A5; Wed, 30 Apr 2025 19:23:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D35E66B00A6; Wed, 30 Apr 2025 19:23:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD8D26B00A7; Wed, 30 Apr 2025 19:23:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 950E06B00A5 for ; Wed, 30 Apr 2025 19:23:18 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5A2A65E14D for ; Wed, 30 Apr 2025 23:23:19 +0000 (UTC) X-FDA: 83392288518.14.89CF031 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by imf09.hostedemail.com (Postfix) with ESMTP id 693F4140004 for ; Wed, 30 Apr 2025 23:23:17 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="1r9/qpFY"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of surenb@google.com designates 209.85.160.172 as permitted sender) smtp.mailfrom=surenb@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1746055397; a=rsa-sha256; cv=none; b=vUIbwWI9uBpj/hnk1hYGPaDMxg1Ea2CwJreLA0pDS5ifO3Fbxn0qJuGDqxZgCvM1c/Jk24 cKtOUYS8QhurkYB2y7Rc6iIVjQIPCL0f8laYIXxRwNBRc5wh1SxQn9Qj1PV0tvfSOR56aL 8/pwN7rH7MpkdDoWK7ZWoko/z19Bw60= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="1r9/qpFY"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of surenb@google.com designates 209.85.160.172 as permitted sender) smtp.mailfrom=surenb@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1746055397; 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=VdVBwgwW5oktAa2ftegT4moTl73OKXeflA2LjVwuEQU=; b=Lp0iq5SahQ9JGQZFGVkgm5u4/5fBLL0PGZVQS/XhIh5WwcJyZcRfTXuWyI4KKdXbjz0kuL mCKzebS+CQBeHitPTXjpcIwF9z8mCTpYC2DijyjtzAQAQmUiFlUqUMxRxtBDcicNGU/Cra eJimupGOUl6O/V5gYefCNzDBke0MF6o= Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-4774611d40bso62071cf.0 for ; Wed, 30 Apr 2025 16:23:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1746055396; x=1746660196; 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=VdVBwgwW5oktAa2ftegT4moTl73OKXeflA2LjVwuEQU=; b=1r9/qpFYLU84wJv6LcnsL2wxLb/svBXeAioluJGz/+VcMC1h54OiGHVVEemRbTddlf hlGYTa53XoR2QdJmsq65udgsMKBQmsE3nVxvkDkAB3rFl9Iib2Al24KBc5+ZGT0deOUH iUnrOofvXSUEyJKUqYBD9QgFrGjvv3SWFBI9QnZz49/KSfinmU8cHRUx/KGNe130Q0ar DT2JKQZ5Yk+h7vd/7W0pFVJ2TuoPFiQ1xoty81lwOzWn++Y60oWpSCJig6SqNjzybkku vsAJId6i6DaNHCW0nmUx6SdomDJBNYQqoh3IUBd4GQruqeVcuSsdozDuG+wVN0iJxFuD uhwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746055396; x=1746660196; 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=VdVBwgwW5oktAa2ftegT4moTl73OKXeflA2LjVwuEQU=; b=cEv1GR/6VU9o9stimBJbRSyx8OusOtAqvolKCBeybtChGfADvrorhE1SuVNDAP2CDB IwwCBcaYaIweC80RcGGjwAlSpsJjHCkrBKBCB1ZNKjxG75xqQ/Ag7IOfamu5Om/++SRB PzMWWUnKGbqDcagmNzFlyFExU7PLDC/TdwH6FEy5mPEVbf2o4u+r+XXdeHwS0x4isyIF +pJ3Ca+gGwzkbZvPur9FA3OaPx8KtTGhAQUhFcQGo7cPku9k34MPpBYVXoL3lAI4gEf+ 0FhD4Pmj/j5TNR4Tv9PcmESqoSAMUirgJQlm9XMiSCYZd4MJaMzq0hinbj8iyt2lrXIz f9gQ== X-Forwarded-Encrypted: i=1; AJvYcCXEhJI1hYzWtgvoJMg5bDvzWKZi3PwoBFFgFZ+hM1TT3p7FcZRT4Tpyc0Hy12CTU5GvnLjJL2B2kw==@kvack.org X-Gm-Message-State: AOJu0YzMkDic/qYuWx3tef9DtZrugN/Hn++WWfB+he45uMf6oVlfuciI FqB8mCONSXslG2e78Mn7OuQOPFq6M6ff/ttZ+UYLRiAo6sgK2rI9h1a+YrHXr7ntTt/nzVJdLtp /CkBlwF1i2pkf8STkCubOJyq3TQpMfrsl19PT X-Gm-Gg: ASbGncuAC5Rzh0g05GgK8EnJhsH+tqCXHsApWJ7BoPeItyrB1m25rjUApUv45iEXRx5 I6ZjyB0fHpFufPRk+a+WGM8HbEF64u0fZFTmldQSyGAYQUBXUDgJX8FdVedSsbCVP1mNpfIr+vF mSfotEMwLl9ND+nnnn0Yduz3Q4dSzYsoM= X-Google-Smtp-Source: AGHT+IFjY3N+1YwWIIZOCvAgrW4alUjmZDYRgOhxiD8v6HqkUZc1GP7gdbLeofm4FNtvmt4ZB8BIbj4qAlxnLHLh3t8= X-Received: by 2002:ac8:5d4f:0:b0:467:84a1:df08 with SMTP id d75a77b69052e-48b0dfdc48bmr697091cf.23.1746055396056; Wed, 30 Apr 2025 16:23:16 -0700 (PDT) MIME-Version: 1.0 References: <20250423195309.2841410-1-surenb@google.com> <6kaeipedoa6vo4apmz7hb7cgozpl66w4f3z7sexunhqhsu3oda@von5awqj35if> In-Reply-To: <6kaeipedoa6vo4apmz7hb7cgozpl66w4f3z7sexunhqhsu3oda@von5awqj35if> From: Suren Baghdasaryan Date: Wed, 30 Apr 2025 16:23:05 -0700 X-Gm-Features: ATxdqUE5JKSTcFOL1sgGLJGQ5I25C4U8KveGvMiTHbxBMJtoUz_L_xegFBTOZJo Message-ID: Subject: Re: [PATCH v2 1/1] man/man2/ioctl_userfaultfd.2, UFFDIO_MOVE.2const: Add UFFDIO_MOVE page To: Alejandro Colomar 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-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 693F4140004 X-Stat-Signature: jb4459biem7nzxotn33qby3ftdu9fwa9 X-Rspam-User: X-HE-Tag: 1746055397-326592 X-HE-Meta: U2FsdGVkX1+LjWywcDuYdKso/rPIMCTcQv4k3imx1llPai/SPimSC1SFZfaNZYTsvKqsEfH2jclvsph11GuACHzwZ5u6y7kExLFYwHjwloX2BIz4/HOl6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WHHzcO2YD5PQam/EdotgiZoqtXhC70xsfqVULDCbWyj13G0P8b234gD3PFJO76vqDtuouzukldkR71bK1/28iXAs9OyurUHBTHHJ3PPXDofuIKji00TIIrNOfREdhaIRsag5Ndeht5kc6yOQke9lZGMqb41DYdg== 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 30, 2025 at 4:10=E2=80=AFPM Alejandro Colomar = wrote: > > Hi Suren, > > On Wed, Apr 30, 2025 at 03:59:42PM -0700, Suren Baghdasaryan wrote: > > 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 Coloma= r > > > - 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. > > Sorry; I was traveling back to Spain the last few days. I'll have a > look at it tomorrow. I had a quick look these days, and it looked good, > but I'll confirm. Thanks! Sure, no rush. Thanks! > > > Have a lovely night! > Alex > > > > > > > > > [1] https://lore.kernel.org/all/20250423011203.2559210-1-surenb@googl= e.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_userfaultf= d.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 registe= red range > > > +.SH LIBRARY > > > +Standard C library > > > +.RI ( libc ,\~ \-lc ) > > > +.SH SYNOPSIS > > > +.nf > > > +.BR "#include " " /* Definition of " UFFD* " c= onstants */" > > > +.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 b= y > > > +.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 > > > > > > > -- >