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 D76E8C369DC for ; Thu, 1 May 2025 22:47:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6C2C6B0088; Thu, 1 May 2025 18:47:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E19CE6B0089; Thu, 1 May 2025 18:47:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C94186B008A; Thu, 1 May 2025 18:47:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A5E086B0088 for ; Thu, 1 May 2025 18:47:15 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 96764E0459 for ; Thu, 1 May 2025 22:47:17 +0000 (UTC) X-FDA: 83395826514.08.A2B1A07 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) by imf11.hostedemail.com (Postfix) with ESMTP id B6EFA40003 for ; Thu, 1 May 2025 22:47:15 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=rK0qCnK6; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of surenb@google.com designates 209.85.160.170 as permitted sender) smtp.mailfrom=surenb@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1746139635; a=rsa-sha256; cv=none; b=BMTFoAa0KVq6G7JbghVHj0XcEy2hEp9zO3zlr5oPzMWy/+WG/qvMtJXTIVlKVrFZTFYG7y ebCoSuKERannPwgueqBUtKDXsWGfmfzQ/rLbr14eKgCDKri0FNO6+1kjwyFxhFBzbd80ed J6kefor2bSjIk/WIqQb12v2E4TUuU44= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=rK0qCnK6; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of surenb@google.com designates 209.85.160.170 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=1746139635; 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=O6fwaerzl3Bg0sf5oeWuRn0ChzTq7tOiRIWWTq3nzwY=; b=WJBPUGnMRpstUEH9yQR3RVShPgOHv+YxHWrdm3+AWDWhMKuiWBXmkBiZuv57rGFaxjNg54 //HU1NiBgRwyHtByApJHEA796x1zg6/9UN7UFNsWslLXV6gBWL9dsG7Y2wtVihq2Y6qjbc BQRpqstOA7b0rDu65S6ZcMRsemWvtZs= Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-47e9fea29easo54871cf.1 for ; Thu, 01 May 2025 15:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1746139635; x=1746744435; 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=O6fwaerzl3Bg0sf5oeWuRn0ChzTq7tOiRIWWTq3nzwY=; b=rK0qCnK63RdTRlJwd3IBXkGzbfJWI8QXC1Xg5fP3wHtvojTEKClRWeRe5W1GYqjTR8 ugJgT8P4y/cQ1C4Dli6+useSw8bq+ryy9pVLRmtvTs4XeO1/AaURlH9oqbumvjAR4nlH CPV7pxvXdQUYsEQX/tR60Yf5k3BIJsiqhdqPuTDGRjfr6Nkx+jDB41oO4uMG9x1GD6Xq I84WCAX4KuEs0brEJYtigEwN6cyvMgqn+Oc+W/y42BbXfa1+aCSnYrV/oHt9PT+N4su6 W9p241aNgBaitRBuZlR4XYjewOVwQGufivOIQTbcMcaUm5z4UfF5YNW4HC96zP4+X28U QBmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746139635; x=1746744435; 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=O6fwaerzl3Bg0sf5oeWuRn0ChzTq7tOiRIWWTq3nzwY=; b=RTYz17UUBg0ZUGMgnhCS8lJTVzn+QdR/39/Uk14Af3e6wMoFOqtIe0VkQp9Tct0Tt3 R0cKrieg62kUzexnnWQ8wlhqHwEPe5v6ChfF0HGwEXbykB+46nf4Fg7XQzh1JmkcjZsA PgEbHRUIcJgBAENDtrMc4E0lXfPqzYgxiDy5lbSZRuc00zkGaymhCa88jxiPhromjizV dSqZtmF0yo5HAUC7o9QIiud2qXwLHI8TmKgyz/V1ow6DCZABLZFX6iTDGRt5hKvXXCAJ 3NCQZiKu2QZXohhXamp2dPKJ4uG//9dFSyKPV7hHWVXpLRnAbZoFof2CxPMEsGIW8Qw2 aaRQ== X-Forwarded-Encrypted: i=1; AJvYcCW/ATfrl33tipHWfIGeZ54mlb3QKHjprurYetJE7qQvG0N00XVu0lOKoGWIsqJIC3WzuZ6eF1lNrA==@kvack.org X-Gm-Message-State: AOJu0Yz66Dyfh5deNmgIkqRLZga8iEa2IQ1eGhSBI6ILhIDobuHhj7A6 efuG/Ls6JQZ7DZw6LIroZ5IgDfq0kEpMoEP/eyuQH3LDBKSL8oVxuRgSNfsH1hYrNaJt7qg4iHI 8UkEha5yG9y64gG5I2FkC/aFVQLz4uR6cjsIW X-Gm-Gg: ASbGncshzU9BZ4sqvUjSUdcbtnx22VPO6L3UnZPloygZd/7DqUsuJYdu+iz5AbbSWP9 8mSw6kuxzCH8VyqhZqe22/FVDfb4l7KTYd5DseHbTW5QXvk8gE5KLGVByl8gaJUo/YkDqq8Tluf Xr9yylbRi0uIiCWr3nFKcq X-Google-Smtp-Source: AGHT+IFZI002Sla3uvwR1rluxQsLjbMAG9CGpRQ6CtR5RfgdNfT+dEP/11g/kteOQpKWLbA1/vj6iYeLrkz2QlOUBRA= X-Received: by 2002:ac8:5a0c:0:b0:47b:840:7f5b with SMTP id d75a77b69052e-48b0dfe09a8mr4973961cf.29.1746139634530; Thu, 01 May 2025 15:47:14 -0700 (PDT) MIME-Version: 1.0 References: <20250423195309.2841410-1-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 1 May 2025 15:47:03 -0700 X-Gm-Features: ATxdqUFMVjVkF21Xxk3-g1aoMywqpskLyRu2fbWvlDJpBxC8WUbsWZulycaGZGQ 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: B6EFA40003 X-Stat-Signature: foygwe9wuid4nmy4gcg81gqioszw7qk5 X-Rspam-User: X-HE-Tag: 1746139635-763298 X-HE-Meta: U2FsdGVkX19LJPbRNPlEpwTsS3DGqtG0QtDGlklyqYpPbrWL0rcoc4jugpyJ89v1nj9gF4NrsAtxngrD74H8IyQpbVuvUGnoWEud4b1ezBGZq5XQYZF0RPw1G1brQPH+BLsj0MGevYU5LIggmTZZuBhXdHkhZS279W5O9xzplyUl2GcxDGiFkF69lePTnkIcXv6wfQKKPBgiZIlIL2aLEI3xEx+nW5C+gSHLPwQTr+dvlrV8/xuLKnThhFL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OT6ExxabrC78RQkt/lnfedaKYS8aO7Iw== 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 Thu, May 1, 2025 at 6:12=E2=80=AFAM Alejandro Colomar w= rote: > > Hi Suren, > > On Wed, Apr 23, 2025 at 12:53:09PM -0700, 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 > > I've formatted references to fork(2). I also fixed a few places with > s/BR/B/. Other than that, the patch was fine; I've applied it. Thanks! > > Below is the diff with which I amended the patch. Hi Alex, Your changes look good. Thank you and Lorenzo for helping to sort this out. Cheers, Suren. > > > Have a lovely day! > Alex > > > diff --git i/man/man2const/UFFDIO_MOVE.2const w/man/man2const/UFFDIO_MOVE= .2const > index 77b0ca781..daa122b30 100644 > --- i/man/man2const/UFFDIO_MOVE.2const > +++ w/man/man2const/UFFDIO_MOVE.2const > @@ -108,36 +108,42 @@ .SH ERRORS > .I .mode > field. > .TP > -.BR ENOENT > +.B ENOENT > The source virtual memory range has unmapped holes and > .B UFFDIO_MOVE_MODE_ALLOW_SRC_HOLES > is not set. > .TP > -.BR EEXIST > +.B EEXIST > The destination virtual memory range is fully or partially > mapped. > .TP > -.BR EBUSY > +.B 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, > +or > +.BR fork (2) > +COW-shares pages during > +.BR fork (2) > +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 > +.BR fork (2) > +should be avoided > or > .B MADV_DONTFORK > should be configured > for the source virtual memory area > -before fork(). > +before > +.BR fork (2). > .TP > -.BR ENOMEM > +.B ENOMEM > Allocating memory needed for the operation failed. > .TP > -.BR ESRCH > +.B ESRCH > The target process has exited at the time of a > .B UFFDIO_MOVE > operation. > > > > --- > > 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_MO= VE.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 registere= d range > > +.SH LIBRARY > > +Standard C library > > +.RI ( libc ,\~ \-lc ) > > +.SH SYNOPSIS > > +.nf > > +.BR "#include " " /* Definition of " UFFD* " con= stants */" > > +.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 n= ot, > > +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 > > > > -- >