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 21F75E7718B for ; Mon, 23 Dec 2024 20:38:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E7A16B007B; Mon, 23 Dec 2024 15:38:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9972E6B0082; Mon, 23 Dec 2024 15:38:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85FEF6B0083; Mon, 23 Dec 2024 15:38:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 67C126B007B for ; Mon, 23 Dec 2024 15:38:07 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id ED83FB1282 for ; Mon, 23 Dec 2024 20:38:06 +0000 (UTC) X-FDA: 82927383924.03.2CC428C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id 885C0C000A for ; Mon, 23 Dec 2024 20:37:48 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iB++Y5cb; spf=pass (imf10.hostedemail.com: domain of alx@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alx@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734986245; 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:in-reply-to:references:references:dkim-signature; bh=267hLLJTmTMFJXevJ2p4nqXpiJafMQeIPFzhV9NOmlA=; b=yBnvEqbz2iL3TzSju7ezW90mRoQdARdclyRl1J8yxjxAfv3cdoKMKpuZAEGlNbl0UgtSGq louPwnPYV1XvGFeSjL1EDO+d2SueZakTmdH7cyZ5CtIqd0Se8l7Tqmv2tdkZ3CiN76SXNJ Lr5pvhyF4flcGJJJgo13BuKZn8QUzuk= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iB++Y5cb; spf=pass (imf10.hostedemail.com: domain of alx@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alx@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734986245; a=rsa-sha256; cv=none; b=rld1Xbki/32c4o1L6o50utkDimZZMLTmoOwCBVFzE/eOgDbgTFvna3ZdJICkfh9+wuMuQu /VU3ee/Ua3eZMlu3BySjYnpX0QLnCExYhfwGcwgHyVg93r/yAugTR9cFsnM0tBlyZl/8UP 5FbAOefMZGVeLZTAMH3YJBoSzpyi12M= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 836425C47C1; Mon, 23 Dec 2024 20:37:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62A56C4CED3; Mon, 23 Dec 2024 20:38:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734986284; bh=orjMZ9FWSr3bZVu8cL98b0JVbJdxXLv8JBThb29V/Hk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iB++Y5cbQ1A8GJT87B9OkoJn603bniaOfpAt2hencJbPKNxcpVElwZe46cVx+nS0B Z1LZeqZyhcIk+uZm+h7mrcFl+tgaNlOhG4hE+6SQuOvXvw1m7h0pIjGHusV4z5su6C JqYu2wqenlGfvv5WQrkDmFuKZCXHGQM1TMUPdoaMPiluiGRedQAS1s/pugsjJkWFKf mg+VmrnEl5YRVAbxYJUbQfMyPoX7kLLFrreN2s2KUejWi3s8JBgKCu9cwvA6VQubfm YpHzj+Lhru3yYt7Yey2hZrr4Zku5Cs86JzWPfHQrlJoHZ2v8B85Dkb4py9TjMHfHri HXfewTAlWlClA== Date: Mon, 23 Dec 2024 21:38:00 +0100 From: Alejandro Colomar To: Lorenzo Stoakes Cc: linux-man@vger.kernel.org, Suren Baghdasaryan , "Liam R . Howlett" , Matthew Wilcox , Vlastimil Babka , Jann Horn , linux-mm@kvack.org Subject: Re: [PATCH man-pages v5] madvise.2: add MADV_GUARD_INSTALL, MADV_GUARD_REMOVE description Message-ID: References: <20241206113418.14327-1-lorenzo.stoakes@oracle.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="dosriwtkowp7omk4" Content-Disposition: inline In-Reply-To: <20241206113418.14327-1-lorenzo.stoakes@oracle.com> X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 885C0C000A X-Rspam-User: X-Stat-Signature: jtw3w3k6csyp9znm8ywqgqenp1doxbkq X-HE-Tag: 1734986268-392126 X-HE-Meta: U2FsdGVkX19PjjWfaprOBkZPTCvy9Ljb095r9+sHMY30QQ8/No9uu3KYZjJR5C+vcZahzslizI9bY5hlUQZpE/0BO+mre0Q35/KJvOdCYzF36SSuLp3Iq9kOEqdwWkzSrqwRKZAEGnhdKqDAhZloQ5F7z+6w6Ku873ESxbgk1x9TWIHkr8MSEcukfFL/9m6gngM5GqBB0zKRwypy3v1ybZ1caq2zLzxlAyY0eOF5H16gRkBIyE6+6jcSTH47D+BAw/KjhNcZIot4P5W29HOOo0k+21KimjNm6zaPdQ5x/hBVaQ4OIoZ/SYENvTs4vAGsnfrlqRZh6Hrt86jT/nZ/qNSD3mxPcPRyeQ1JVLM7ov5S5Tqlqm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1gI78xyxMYEnKgpyVwnrkidcixyWIW1ds2W88tUL0OpkxVYytYN7Bjj1BWuExSSbRc16TT101w== 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: --dosriwtkowp7omk4 Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable From: Alejandro Colomar To: Lorenzo Stoakes Cc: linux-man@vger.kernel.org, Suren Baghdasaryan , "Liam R . Howlett" , Matthew Wilcox , Vlastimil Babka , Jann Horn , linux-mm@kvack.org Subject: Re: [PATCH man-pages v5] madvise.2: add MADV_GUARD_INSTALL, MADV_GUARD_REMOVE description References: <20241206113418.14327-1-lorenzo.stoakes@oracle.com> MIME-Version: 1.0 In-Reply-To: <20241206113418.14327-1-lorenzo.stoakes@oracle.com> Hi Lorenzo, On Fri, Dec 06, 2024 at 11:34:18AM GMT, Lorenzo Stoakes wrote: > Lightweight guard region support has been added to Linux 6.13, which adds > MADV_GUARD_INSTALL and MADV_GUARD_REMOVE flags to the madvise() system > call. Therefore, update the manpage for madvise() and describe these > operations. >=20 > Reviewed-by: Jann Horn > Reviewed-by: Vlastimil Babka > Signed-off-by: Lorenzo Stoakes Thanks for the updated patch. I had already applied v4: > --- > v5: > * Prefer 'replaced' to 'cleared' when discussing existing mappings that h= ave > MADV_GUARD_INSTALL applied to them, as suggested by Vlastimil. > * Included small changes Alejandro applied to patch. So I have now rebased v5 on top of the current tip of the branch, which results in a small patch containing just the wording fix: Have a lovely night! Alex >=20 > v4: > * Reference function chapters as per Alejandro. > * Minor rewording as per Alejandro. > https://lore.kernel.org/all/20241205104125.67518-1-lorenzo.stoakes@oracle= =2Ecom >=20 > v3: > * Don't describe SIGSEGV as a fatal signal as per Jann. > https://lore.kernel.org/all/20241202165829.72121-1-lorenzo.stoakes@oracle= =2Ecom >=20 > v2: > * Updated to use semantic newlines as suggested by Alejandro. > * Avoided emboldening parens as suggested by Alejandro. > * One very minor grammatical fix. > https://lore.kernel.org/all/20241129155943.85215-1-lorenzo.stoakes@oracle= =2Ecom >=20 > v1: > https://lore.kernel.org/all/20241129093205.8664-1-lorenzo.stoakes@oracle.= com >=20 > man/man2/madvise.2 | 103 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 103 insertions(+) >=20 > diff --git a/man/man2/madvise.2 b/man/man2/madvise.2 > index 0dd481d21..c9b4722db 100644 > --- a/man/man2/madvise.2 > +++ b/man/man2/madvise.2 > @@ -676,6 +676,101 @@ or secret memory regions created using > Note that with > .BR MADV_POPULATE_WRITE , > the process can be killed at any moment when the system runs out of memo= ry. > +.TP > +.BR MADV_GUARD_INSTALL " (since Linux 6.13)" > +Install a lightweight guard region > +into the range specified by > +.I addr > +and > +.IR size , > +causing any read or write in the range to result in a > +.B SIGSEGV > +signal being raised. > +.IP > +If the region maps memory pages > +those mappings will be replaced > +as part of the operation, > +though if > +.B MADV_GUARD_INSTALL > +is applied to regions > +containing pre-existing lightweight guard regions, > +they are left in place. > +.IP > +This operation is supported > +only for writable anonymous private mappings > +which have not been mlock'd. > +An > +.B EINVAL > +error is returned if it is attempted on any other kind of mapping. > +.IP > +This operation is more efficient than mapping a new region of memory > +.BR PROT_NONE , > +as it does not require the establishment of new mappings. > +Instead, > +regions of an existing mapping > +simply have their page tables > +manipulated to establish the desired behavior. > +No additional memory is used. > +.IP > +Lightweight guard regions remain on fork > +(except for any parts which have had > +.B MADV_WIPEONFORK > +applied to them), > +and are not removed by > +.BR MADV_DONTNEED , > +.BR MADV_FREE , > +.BR MADV_PAGEOUT , > +or > +.BR MADV_COLD . > +.IP > +Attempting to > +.BR mlock (2) > +lightweight guard regions will fail, > +as will > +.B MADV_POPULATE_READ > +or > +.BR MADV_POPULATE_WRITE . > +.IP > +If the mapping has its attributes changed, > +or is split or partially unmapped, > +any existing guard regions remain in place > +(except if they are unmapped). > +.IP > +If a mapping is moved using > +.BR mremap (2), > +lightweight guard regions are moved with it. > +.IP > +Lightweight guard regions are removed when unmapped, > +on process teardown, > +or when the > +.B MADV_GUARD_REMOVE > +operation is applied to them. > +.TP > +.BR MADV_GUARD_REMOVE " (since Linux 6.13)" > +Remove any lightweight guard regions > +which exist in the range specified by > +.I addr > +and > +.IR size . > +.IP > +All mappings in the range > +other than lightweight guard regions > +are left in place > +(including mlock'd mappings). > +The operation is, > +however, > +valid only for writable anonymous private mappings, > +returning an > +.B EINVAL > +error otherwise. > +.IP > +When lightweight guard regions are removed, > +they act as empty regions of the containing mapping. > +Since only writable anonymous private mappings are supported, > +they therefore become zero-fill-on-demand pages. > +.IP > +If any transparent huge pages are encountered in the operation, > +they are left in place. > .SH RETURN VALUE > On success, > .BR madvise () > @@ -794,6 +889,14 @@ or > or secret memory regions created using > .BR memfd_secret(2) . > .TP > +.B EINVAL > +.I advice > +is > +.B MADV_GUARD_INSTALL > +or > +.BR MADV_GUARD_REMOVE , > +but the specified address range contains an unsupported mapping. > +.TP > .B EIO > (for > .BR MADV_WILLNEED ) > -- > 2.47.1 --=20 --dosriwtkowp7omk4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmdpyigACgkQnowa+77/ 2zLLrw/6A3ku+cLYHfP8Jeqb8QeHlAZPu6/p40sluCGJE9/TtZLTFzash5wP7WTx QEu3Z/tuvxOIPdz6dRSMRB2K1eW99pDfrSxDcKzuaZN9W7MD0DZh0wl8pbCp7HWA l/+3zrVzbUjEW5VZXNrxXISFX5mp01qZlNyu7CU+92SgMn3V1nL4JNz/QiA1xk5j 1hHoSQV35i2WHO0KyhGpy6zT3VWozSCYAag82eNzDyD3r83kLzLNHSmb0b5+9f8R iOBdgi4JWcBQIG340ZCEjFIcY1NnbAt5xOMo+5S0W8jS93cAcs+QJrYjyE2PkVPd 1PyvNmWNjAYfTcnwAuLRfHjMVp/M1HgHonZPCEVggUQj8EO2P7c3hcZUVCnRGIWB eCdLrWqtjXnR3jt8nZfTWkiE8/y9N/GW1W8QLyXqEUWVHb8zuEFyw63BshC0ZEWO tX7WEmGLO50FwPYapuZGS9kQuZXsr6lyNDDlu/4c9xHFGApJ9yuo3Uc1ZiQXlG1H 0SmIZozcnmH+mlUJL5nNzJf5LujGDT3+Ben1xYrbVkY208iXDoL6Juj5sxLPxqin XAap4oPenVXZNLbZhpJJV0NFCf/tmEME6QN8ZK8hmxg5lI8VtAaEDAX96bQwb+DL t1q7KbldHNV8iDijgfdCN66MEcobINefSVRbi1Z960fZ0+jsq/8= =QC3M -----END PGP SIGNATURE----- --dosriwtkowp7omk4--