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=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 B6D88C07E9A for ; Mon, 12 Jul 2021 10:04:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3CB40610E6 for ; Mon, 12 Jul 2021 10:04:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CB40610E6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4180D6B008A; Mon, 12 Jul 2021 06:04:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C8E56B008C; Mon, 12 Jul 2021 06:04:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 242776B0092; Mon, 12 Jul 2021 06:04:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id F0D626B008A for ; Mon, 12 Jul 2021 06:04:05 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8449E1829771C for ; Mon, 12 Jul 2021 10:04:03 +0000 (UTC) X-FDA: 78353499966.39.AC02C4C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf02.hostedemail.com (Postfix) with ESMTP id D97AE700177B for ; Mon, 12 Jul 2021 10:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626084242; h=from:from: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; bh=6gVdXMnmbrFdhM3Ud9GG9Z0Ypa4CVzqPjHQh66H2MuM=; b=BLwy4pbPzO04db0bC7UxozAyc6dIhz1bCTkYY8e40/E2cx8+bxEJdD6tGM1HZv985f+7U6 FdZbbdMmSYhg9SDTpzE7pBafX2o1QABpB570wmGZ4dPwTDdBK6eMFulv9UDrNP95cFRjb9 ZTs39e63t8yqHMnrL2ElY9cP2YZjUS0= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-269-bavvR_vMM2yZNtzfLAeDJA-1; Mon, 12 Jul 2021 06:04:01 -0400 X-MC-Unique: bavvR_vMM2yZNtzfLAeDJA-1 Received: by mail-wr1-f72.google.com with SMTP id t8-20020a05600001c8b029013e2027cf9aso2885931wrx.9 for ; Mon, 12 Jul 2021 03:04:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=6gVdXMnmbrFdhM3Ud9GG9Z0Ypa4CVzqPjHQh66H2MuM=; b=OLI2R3cGVyKo220M/g2iGnzX3D6YPb8LPBMZP7xmaiU3U9KxgFK4Jeuczrw4u9icZo a8aFiroHUhVlb1CBWfWl49lb6TQGGna+tGNRKb6Q7tbdnpu/vKOHJgxvQb/2BGC94u81 LANLPo1e1FehnFHJMujeofyEL2M80DMwGIzKQzbYgqdkIYjz+kG7OdMxGHdM4DwMi1iK a/jZ6Cskre/RI/OBgff30qQWIseTBkICgZiH+YrU8SSCTL81gVkvFd3tM0w5QbQk9KzK Dn4fA9B4zzuNlXcNTxBqB/XGJ2kJTH7DUbvzw9opEzpusS13PODgSyDArPrSPhFmIrf8 simA== X-Gm-Message-State: AOAM530L9MxQ/JSWNjauQwHVLjRU6LRs54zOpRE4HR2Vwo1q2SbZALEg wlUNVEU/3XK1/P/oDcWlEQn5Z6FtwZKJ1qPNgUxezgo7OBKOj+Y1HIeOLEXmdwuOopRWHkAdy1q NwDvNB8aj9Wo+x6lg3USDJeRGOLal+z/5KOsIOaoSjSl2tWalrpL6lwQR+ww= X-Received: by 2002:a05:600c:4f4d:: with SMTP id m13mr13758035wmq.61.1626084240114; Mon, 12 Jul 2021 03:04:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKEF6ted5NcVN/5/r4AT7QL5ZIwe94KuOdH10hCJY0gom2i8OUE8aoV5ElG977KnUEiYiouw== X-Received: by 2002:a05:600c:4f4d:: with SMTP id m13mr13757997wmq.61.1626084239863; Mon, 12 Jul 2021 03:03:59 -0700 (PDT) Received: from ?IPv6:2003:d8:2f0a:7f00:fad7:3bc9:69d:31f? (p200300d82f0a7f00fad73bc9069d031f.dip0.t-ipconnect.de. [2003:d8:2f0a:7f00:fad7:3bc9:69d:31f]) by smtp.gmail.com with ESMTPSA id m7sm17849348wms.0.2021.07.12.03.03.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jul 2021 03:03:58 -0700 (PDT) Subject: Re: [PATCH v1] madvise.2: Document MADV_POPULATE_READ and MADV_POPULATE_WRITE To: Pankaj Gupta Cc: linux-man@vger.kernel.org, Alejandro Colomar , Michael Kerrisk , Andrew Morton , Michal Hocko , Oscar Salvador , Jann Horn , Mike Rapoport , Linux API , Linux MM References: <20210712083917.16361-1-david@redhat.com> From: David Hildenbrand Organization: Red Hat Message-ID: <406695f0-13c8-a052-92d4-44e884eb44af@redhat.com> Date: Mon, 12 Jul 2021 12:03:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D97AE700177B X-Stat-Signature: q1d65b5eyusaaa45userc5rtgjyj98yu Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BLwy4pbP; spf=none (imf02.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1626084242-428059 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: On 12.07.21 11:58, Pankaj Gupta wrote: >> 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 :) It's reading. Assume you have a file with existing content mapped into a process. Once you touch a page (read/write/execute) that maps to blocks with existing content, you'll have to load these blocks from disk first. Thanks! :) -- Thanks, David / dhildenb