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=-18.7 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,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 0B10EC433F5 for ; Mon, 20 Sep 2021 17:36:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9DAE96154B for ; Mon, 20 Sep 2021 17:36:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9DAE96154B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 34F0D6B0071; Mon, 20 Sep 2021 13:36:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FC976B0072; Mon, 20 Sep 2021 13:36:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 175C0900002; Mon, 20 Sep 2021 13:36:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0220.hostedemail.com [216.40.44.220]) by kanga.kvack.org (Postfix) with ESMTP id 090586B0071 for ; Mon, 20 Sep 2021 13:36:14 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B679E180AD82F for ; Mon, 20 Sep 2021 17:36:13 +0000 (UTC) X-FDA: 78608655426.15.9C6D5D9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 519B290000B8 for ; Mon, 20 Sep 2021 17:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632159372; 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=joEmUTI4ZZjQtcXVOCrz/b3U1ugGJV5MEzLo31LXFyM=; b=i8TIiM/jE1lK36soC22bYhDiPafqZ4uFV1q81ITefXT+LtWEFPSkDomZa3sD9ZjrVkukEy WK0d2B4FwRejE49yYkcqinj0VobxMUt2ddTfghpNwtRrtx0r+PiNkfZWgK36YEsCzcnGdX CNI70ZFEiMTkEZK9nzFC7peXMRQi1Zg= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-411-mQsRbi_VPJSNEBYEIIi4eg-1; Mon, 20 Sep 2021 13:36:11 -0400 X-MC-Unique: mQsRbi_VPJSNEBYEIIi4eg-1 Received: by mail-wr1-f69.google.com with SMTP id s13-20020a5d69cd000000b00159d49442cbso6702355wrw.13 for ; Mon, 20 Sep 2021 10:36:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=joEmUTI4ZZjQtcXVOCrz/b3U1ugGJV5MEzLo31LXFyM=; b=nwoi2FLXFufJMdwUjC2St5v6oeVzouwIRaIqlKlsEZSdDcIcEWwp0QqNi4Hz94b3Q4 rt0DMQrz07U9hp4AkKCVb72z8TVK+ooTNtfYrY2zeLzJ0veAWjSKb3/p2AM3o7PucJGU nU//fDh7+72UWhyxxequAPy8FWSnpOWojrpOe/Xc83oXlMqnqtGOD4HGF2SVi9elsm15 aCwPX4wra0UWINVpoI++jvNv51vdNdTZGrVXZVp/QUY3oYfeSbJUmksuyyM/SR+drfkl FWCcZkS7lnQhZvu2BOKPBErP95cjYStDooOdj7w/ao4JDGB/upIw9OhVBHFrDaUsf+OO jDBQ== X-Gm-Message-State: AOAM533+/pGm41uHhCTEjbPnEKjic54ZeD4D4rh727xiSl1eobkMUFvJ WYVfftOKB2/fFNqyHGjmpm5TZxhYwdeLo4yM/GgRLa08G0qEov5f2lc+bAFlh/q4TZdhw07Jrvf /nHTtjhTM9zk= X-Received: by 2002:a5d:4a4e:: with SMTP id v14mr29694378wrs.271.1632159370304; Mon, 20 Sep 2021 10:36:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxd+Ecc/ldnyJDRLp7Hdo6uHjNnF8F4pT5VdfoRiLEQAWtep8SAoFkzsot/bUJ/fdK5Sue1gw== X-Received: by 2002:a5d:4a4e:: with SMTP id v14mr29694338wrs.271.1632159369854; Mon, 20 Sep 2021 10:36:09 -0700 (PDT) Received: from [192.168.3.132] (p4ff23e48.dip0.t-ipconnect.de. [79.242.62.72]) by smtp.gmail.com with ESMTPSA id w1sm171783wmc.19.2021.09.20.10.36.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Sep 2021 10:36:09 -0700 (PDT) Subject: Re: [PATCH v2 1/1] Documentation: update pagemap with shmem exceptions To: Tiberiu A Georgescu , akpm@linux-foundation.org, corbet@lwn.net, peterx@redhat.com, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: ivan.teterevkov@nutanix.com, florian.schmidt@nutanix.com, carl.waldspurger@nutanix.com, jonathan.davies@nutanix.com References: <20210920164931.175411-1-tiberiu.georgescu@nutanix.com> <20210920164931.175411-2-tiberiu.georgescu@nutanix.com> From: David Hildenbrand Organization: Red Hat Message-ID: Date: Mon, 20 Sep 2021 19:36:08 +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: <20210920164931.175411-2-tiberiu.georgescu@nutanix.com> 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: rspam01 X-Rspamd-Queue-Id: 519B290000B8 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="i8TIiM/j"; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf28.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com X-Stat-Signature: rreisn9qnk1cba3c3jcirxr5fzhg7i3e X-HE-Tag: 1632159373-782886 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 20.09.21 18:49, Tiberiu A Georgescu wrote: > Mentioning the current missing information in the pagemap and alternatives > on how to retrieve it, in case someone stumbles upon unexpected behaviour. > > Signed-off-by: Tiberiu A Georgescu > Reviewed-by: Ivan Teterevkov > Reviewed-by: Florian Schmidt > Reviewed-by: Carl Waldspurger > Reviewed-by: Jonathan Davies > --- > Documentation/admin-guide/mm/pagemap.rst | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/Documentation/admin-guide/mm/pagemap.rst b/Documentation/admin-guide/mm/pagemap.rst > index fb578fbbb76c..ea3f88f3c18d 100644 > --- a/Documentation/admin-guide/mm/pagemap.rst > +++ b/Documentation/admin-guide/mm/pagemap.rst > @@ -196,6 +196,28 @@ you can go through every map in the process, find the PFNs, look those up > in kpagecount, and tally up the number of pages that are only referenced > once. > > +Exceptions for Shared Memory > +============================ > + > +Page table entries for shared pages are cleared when the pages are zapped or > +swapped out. This makes swapped out pages indistinguishable from never-allocated > +ones. > + > +In kernel space, the swap location can still be retrieved from the page cache. > +However, values stored only on the normal PTE get lost irretrievably when the > +page is swapped out (i.e. SOFT_DIRTY). > + > +In user space, whether the page is swapped or none can be deduced with the > +lseek system call. For a single page, the algorithm is: > + > +0. If the pagemap entry of the page has bit 63 (page present) set, the page > + is present. > +1. Otherwise, get an fd to the file where the page is backed. For anonymous > + shared pages, the file can be found in ``/proc/pid/map_files/``. > +2. Call lseek with LSEEK_DATA flag and seek to the virtual address of the page > + you wish to inspect. If it overshoots the PAGE_SIZE, the page is NONE. > +3. Otherwise, the page is in swap. > + > Other notes > =========== > > Thanks! Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb