From patchwork Tue Jul 16 22:43:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1961349 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=iZ1o0zxm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNvHs0G15z1ySl for ; Wed, 17 Jul 2024 08:43:53 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA301384A05B for ; Tue, 16 Jul 2024 22:43:50 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by sourceware.org (Postfix) with ESMTPS id 43AD2386102F for ; Tue, 16 Jul 2024 22:43:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 43AD2386102F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 43AD2386102F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721169808; cv=none; b=rIaVuOnHUNcd26IM2bJohPvDVW1wO6TN8wyWH4dS9Bid9yJ8beFuw7lgJp+2UqA7x49Bec34BA8CqNIZIoqYCcG9VPrx1Qisg/ZIOfLx86HlYPZ7SXTA0HRTAuokVJFMKrdxXZTYmeJ5fRTYAUKXlpkkR/9lf/7u2MIaV8QF0BU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721169808; c=relaxed/simple; bh=089WUDnNwGUENRAwEwtYwh7cyUzzIuQlOMEiZT2Ir1I=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=J3H6Qv2UoLVnTkL9BPorHvgm52my1GO2W6HHKKC+dXb43B/Ui8dEfswWaHCqvuCgjXoHUHYIT6OoWTvmVxeo3wEIGF12VHw2PWf9xG0q4Sdee+NulEiecb3fZg1MgptWIvNeX7MbKkX2G1nFiXpfg2P+y0ASvV0LicZHVB4GtRQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-65f8b0df1f0so35250647b3.2 for ; Tue, 16 Jul 2024 15:43:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721169806; x=1721774606; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=MYSTc1vRVmD9HF5t/D7rT07o8wpHENQRFWQ1vT5Le3I=; b=iZ1o0zxmLneyZbjKT4zegk3WeMpMccbRSQUeH/Fyd7SC83xyBHPoIuSD7iXb16RD4B ahyrKi3IuKqik1feLJ1X1dH95OM2U0W8v68HGXY1o493uJhIVVY7BAyrH2bsIxqG+GIm xGyxiHQ9sy0pk3SYg9ejk1gUPBdY5fQzz7UaoKU37eaVUx5Kp01xac/+XXhNxNSZvTcR dMNeoN1oa1vFl/x6gCAU54o4L0otbfHo8zGgN3i8qOiw0wtXv4VARxG+ZBOgz3giUVOj 25HwVyABAFllr7b6d3rg5oGCfacWTiSrnx0Pk1stcCBRsPFC6UHXOy7zUYgXg+9JrhYz 8cBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721169806; x=1721774606; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MYSTc1vRVmD9HF5t/D7rT07o8wpHENQRFWQ1vT5Le3I=; b=c7uIVo3cHklbBlELiLc8l98q1tYdGGj7jGWRnmm9Tu1oGuyRsdXM1pmpE0ZFD84vIa QAw3LHvRKDGrv68+AZ+A2dErDIaioYbdsQtP5vXQ3n6C2aG30/h0Ul83bA+Ky/n6sSww IGOkdJGqVO+8YkiLPWUbREKTjbYgKtsQAX7GGcGQwpOl3/XdlhbVpbA7pZKvSeDOA03P hMoxDUUmJHTJvvBtqtyl67CH0RSKsGb5h4F5z8uK1ktfs2mzkoqNMT2HPJSC68xLXtPM pLhuBnOOkQ98C4WA9++Z+1oBziBmmc8cfrxTKBO6/hxkPyXI3X3JBVy49IE4k3KCCfet 8z4w== X-Gm-Message-State: AOJu0YxCZiRBucWw4qC9jUd8N3mRApdJes6t75pn5KGYZCXKDqXMs1qe rxZ5zVlYEiU7mcTOH9dcuMQ7EkxQQN7Xw8n5P3lU4oUAgG7D74bi8YPVHO1dwWzPIw== X-Google-Smtp-Source: AGHT+IGJRgTFYKcljfC1a6+Gi/5/flYyiwnfGpmzgcWmhlxg8StMg47tEooN1jUK6wwy0FbZvHlEaw== X-Received: by 2002:a05:690c:f15:b0:620:2cfb:7a0e with SMTP id 00721157ae682-663817d8469mr44320917b3.40.1721169806343; Tue, 16 Jul 2024 15:43:26 -0700 (PDT) Received: from gnu-tgl-3.localdomain ([172.58.139.74]) by smtp.gmail.com with ESMTPSA id 00721157ae682-65fc26111ddsm13130977b3.41.2024.07.16.15.43.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 15:43:25 -0700 (PDT) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id B7228C02F4 for ; Tue, 16 Jul 2024 15:43:21 -0700 (PDT) From: "H.J. Lu" To: libc-alpha@sourceware.org Subject: [PATCH v2 2/3] mremap: Update manual entry Date: Tue, 16 Jul 2024 15:43:20 -0700 Message-ID: <20240716224321.2352246-3-hjl.tools@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716224321.2352246-1-hjl.tools@gmail.com> References: <20240716224321.2352246-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3021.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org Update mremap manual entry: 1. Change mremap to variadic. 2. Document MREMAP_FIXED and MREMAP_DONTUNMAP. Signed-off-by: H.J. Lu --- manual/llio.texi | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/manual/llio.texi b/manual/llio.texi index 6f0a48609b..c6f65089ee 100644 --- a/manual/llio.texi +++ b/manual/llio.texi @@ -1892,7 +1892,7 @@ There is no existing mapping in at least part of the given region. @end deftypefun -@deftypefun {void *} mremap (void *@var{address}, size_t @var{length}, size_t @var{new_length}, int @var{flag}) +@deftypefun {void *} mremap (void *@var{address}, size_t @var{length}, size_t @var{new_length}, int @var{flag}, ... /* void *@var{new_address} */) @standards{GNU, sys/mman.h} @safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} @@ -1901,12 +1901,39 @@ area. @var{address} and @var{length} must cover a region entirely mapped in the same @code{mmap} statement. A new mapping with the same characteristics will be returned with the length @var{new_length}. -One option is possible, @code{MREMAP_MAYMOVE}. If it is given in -@var{flags}, the system may remove the existing mapping and create a new -one of the desired length in another location. +Possible flags are -The address of the resulting mapping is returned, or @math{-1}. Possible -error codes include: +@table @code + +@item MREMAP_MAYMOVE +If it is given in @var{flags}, the system may remove the existing mapping +and create a new one of the desired length in another location. + +@item MREMAP_FIXED +If it is given in @var{flags}, @code{mremap} accepts a fifth argument, +@code{void *new_address}, which specifies a page-aligned address to +which the mapping must be moved. Any previous mapping at the address +range specified by @var{new_address} and @var{new_size} is unmapped. + +@code{MREMAP_FIXED} must be used together with @code{MREMAP_MAYMOVE}. + +@item MREMAP_DONTUNMAP +If it is given in @var{flags}, @code{mremap} accepts a fifth argument, +@code{void *new_address}, which specifies a page-aligned address. Any +previous mapping at the address range specified by @var{new_address} and +@var{new_size} is unmapped. If @var{new_address} is @code{NULL}, the +kernel chooses the page-aligned address at which to create the mapping. +Otherwise, the kernel takes it as a hint about where to place the mapping. +The mapping at the address range specified by @var{old_address} and +@var{old_size} isn't unmapped. + +@code{MREMAP_DONTUNMAP} must be used together with @code{MREMAP_MAYMOVE}. +@var{old_size} must be the same as @var{new_size}. + +@end table + +The address of the resulting mapping is returned, or @code{MAP_FAILED}. +Possible error codes include: @table @code @@ -1915,7 +1942,7 @@ There is no existing mapping in at least part of the original region, or the region covers two or more distinct mappings. @item EINVAL -The address given is misaligned or inappropriate. +Any arguments are inappropriate, including unknown @var{flags} values. @item EAGAIN The region has pages locked, and if extended it would exceed the