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 X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 184D9C07E99 for ; Mon, 12 Jul 2021 09:58:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8D73861002 for ; Mon, 12 Jul 2021 09:58:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D73861002 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 558746B008A; Mon, 12 Jul 2021 05:58:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 508566B008C; Mon, 12 Jul 2021 05:58:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 382636B0092; Mon, 12 Jul 2021 05:58:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0247.hostedemail.com [216.40.44.247]) by kanga.kvack.org (Postfix) with ESMTP id 0F7AD6B008A for ; Mon, 12 Jul 2021 05:58:34 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 0037F2201A for ; Mon, 12 Jul 2021 09:58:32 +0000 (UTC) X-FDA: 78353486106.18.7883ECA Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) by imf20.hostedemail.com (Postfix) with ESMTP id 85F60D0000A6 for ; Mon, 12 Jul 2021 09:58:32 +0000 (UTC) Received: by mail-io1-f47.google.com with SMTP id g22so21902675iom.1 for ; Mon, 12 Jul 2021 02:58:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OfXfxBn/LMALhO/QRtXtl1w3RykDKGRYzzYrieSX3bA=; b=iesh2DIAw8sK/vK2UkjHoJXXvvkhgEv/w7Ytg0MGfdN1P2o3rBkqtn30+J0jCLWXOt Ol1IvXzkdbVgU6+u7xwRKBkBkBG8qspdQnGRJcuuk09ziLYdEaYWCDjd045QRyaonDYt YxGtSlOPpquQ7AtDHEv+CfIo9MHh6yR43RUzC8v7nCy43vF6fAP4qBtn5YvN0Xk9ecXA X7u0HLHu16n7rFQWnlkQbp0EEed3sesVNBB1QCYpgiV7EQowvMliXfVXzgWLKUB53Qmq iYQ4yOSgY3nzsJ+n5k2oNVovmt0BZjwmA+SN3l4QqGGm3HkRFaSRNaoVh9rkSr98j8uB y5lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OfXfxBn/LMALhO/QRtXtl1w3RykDKGRYzzYrieSX3bA=; b=O0ohxU6wYltZpO8X3ZRkdP/w0oorVoDq+h3nOAToZ2YaLg5/CWSywtfiyybXBQEA/i PVcD/M0vsKY17d5NQGYivoagj2FtsuADpfZbt+oP3zw+iNj3Y1hJR6Y0Qg/j0UKiVWEc LJRdiNLHUVZj0cJubo22BoLwi01x7wrbMdvDRvl3rzOVJapPvQHg2gxU+ZAYrzbJJg+i IXtZ0CSQzyyzsiAXRFDJV7cDju1qPCiyCGKkduqMFbIMMA7lvyYYOROHrPPDI7pGK/hQ LmhxXutKo8PeGQgIDbFOnGFJ8eTifZTYBNoDYUYAv9YVpEWEroO8G4gq2Uc906Nqpjr6 U/zA== X-Gm-Message-State: AOAM5311EBy0ynBf4l44GjwtWx8lne3z+GQMsFE7CxH8Ull8XJpY5v1I NIVgc7mPhumLj6Q3TZtpmqGH6znGr05xjOXQabw= X-Google-Smtp-Source: ABdhPJwVQ8WpiYF0gs+hCoHtfyZZ6n5cvQGDNVvk6u49AcWUcZqoUwcTk8rZQYFcIMzBe5sQFZWyIwRIMuPzzkykidI= X-Received: by 2002:a02:a98d:: with SMTP id q13mr37044878jam.124.1626083911883; Mon, 12 Jul 2021 02:58:31 -0700 (PDT) MIME-Version: 1.0 References: <20210712083917.16361-1-david@redhat.com> In-Reply-To: <20210712083917.16361-1-david@redhat.com> From: Pankaj Gupta Date: Mon, 12 Jul 2021 11:58:20 +0200 Message-ID: Subject: Re: [PATCH v1] madvise.2: Document MADV_POPULATE_READ and MADV_POPULATE_WRITE To: David Hildenbrand Cc: linux-man@vger.kernel.org, Alejandro Colomar , Michael Kerrisk , Andrew Morton , Michal Hocko , Oscar Salvador , Jann Horn , Mike Rapoport , Linux API , Linux MM Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=iesh2DIA; spf=pass (imf20.hostedemail.com: domain of pankajguptalinux@gmail.com designates 209.85.166.47 as permitted sender) smtp.mailfrom=pankajguptalinux@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam05 X-Stat-Signature: n7gbd7a99yr8swb8cqbh6di8kip41zm5 X-Rspamd-Queue-Id: 85F60D0000A6 X-HE-Tag: 1626083912-669746 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: > MADV_POPULATE_READ and MADV_POPULATE_WRITE have been merged into > upstream Linux via commit 4ca9b3859dac ("mm/madvise: introduce > MADV_POPULATE_(READ|WRITE) to prefault page tables"), part of v5.14-rc1. > > Let's document the behavior and error conditions of these new madvise() > options. > > Cc: Alejandro Colomar > Cc: Michael Kerrisk > Cc: Andrew Morton > Cc: Michal Hocko > Cc: Oscar Salvador > Cc: Jann Horn > Cc: Mike Rapoport > Cc: Linux API > Cc: linux-mm@kvack.org > Signed-off-by: David Hildenbrand > --- > man2/madvise.2 | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 80 insertions(+) > > diff --git a/man2/madvise.2 b/man2/madvise.2 > index f1f384c0c..3ec8c53a7 100644 > --- a/man2/madvise.2 > +++ b/man2/madvise.2 > @@ -469,6 +469,59 @@ If a page is file-backed and dirty, it will be written back to the backing > storage. > The advice might be ignored for some pages in the range when it is not > applicable. > +.TP > +.BR MADV_POPULATE_READ " (since Linux 5.14) > +Populate (prefault) page tables readable for the whole range without actually > +reading. Depending on the underlying mapping, map the shared zeropage, > +preallocate memory or read the underlying file; files with holes might or > +might not preallocate blocks. > +Do not generate > +.B SIGBUS > +when populating fails, return an error instead. > +.IP > +If > +.B MADV_POPULATE_READ > +succeeds, all page tables have been populated (prefaulted) readable once. > +If > +.B MADV_POPULATE_READ > +fails, some page tables might have been populated. > +.IP > +.B MADV_POPULATE_READ > +cannot be applied to mappings without read permissions > +and special mappings marked with the kernel-internal > +.B VM_PFNMAP > +and > +.BR VM_IO . > +.IP > +Note that with > +.BR MADV_POPULATE_READ , > +the process can be killed at any moment when the system runs out of memory. > +.TP > +.BR MADV_POPULATE_WRITE " (since Linux 5.14) > +Populate (prefault) page tables writable for the whole range without actually > +writing. Depending on the underlying mapping, preallocate memory or read the Is this read or write? just reading and trying to understand :) > +underlying file; files with holes will preallocate blocks. > +Do not generate > +.B SIGBUS > +when populating fails, return an error instead. > +.IP > +If > +.B MADV_POPULATE_WRITE > +succeeds, all page tables have been populated (prefaulted) writable once. > +If > +.B MADV_POPULATE_WRITE > +fails, some page tables might have been populated. > +.IP > +.B MADV_POPULATE_WRITE > +cannot be applied to mappings without write permissions > +and special mappings marked with the kernel-internal > +.B VM_PFNMAP > +and > +.BR VM_IO . > +.IP > +Note that > +.BR MADV_POPULATE_WRITE , > +the process can be killed at any moment when the system runs out of memory. > .SH RETURN VALUE > On success, > .BR madvise () > @@ -533,6 +586,17 @@ or > .BR VM_PFNMAP > ranges. > .TP > +.B EINVAL > +.I advice > +is > +.B MADV_POPULATE_READ > +or > +.BR MADV_POPULATE_WRITE , > +but the specified address range includes ranges with insufficient permissions, > +.B VM_IO > +or > +.BR VM_PFNMAP. > +.TP > .B EIO > (for > .BR MADV_WILLNEED ) > @@ -548,6 +612,14 @@ Not enough memory: paging in failed. > Addresses in the specified range are not currently > mapped, or are outside the address space of the process. > .TP > +.B ENOMEM > +.I advice > +is > +.B MADV_POPULATE_READ > +or > +.BR MADV_POPULATE_WRITE , > +but populating (prefaulting) page tables failed. > +.TP > .B EPERM > .I advice > is > @@ -555,6 +627,14 @@ is > but the caller does not have the > .B CAP_SYS_ADMIN > capability. > +.TP > +.B EHWPOISON > +.I advice > +is > +.B MADV_POPULATE_READ > +or > +.BR MADV_POPULATE_WRITE , > +and a HW poisoned page is encountered. > .SH VERSIONS > Since Linux 3.18, > .\" commit d3ac21cacc24790eb45d735769f35753f5b56ceb > -- > 2.31.1 > >