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=-7.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 82E90C433FE for ; Mon, 20 Sep 2021 19:07:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2705860F93 for ; Mon, 20 Sep 2021 19:07:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2705860F93 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 9027C900002; Mon, 20 Sep 2021 15:07:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88AE26B0072; Mon, 20 Sep 2021 15:07:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70394900002; Mon, 20 Sep 2021 15:07:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0209.hostedemail.com [216.40.44.209]) by kanga.kvack.org (Postfix) with ESMTP id 5B5646B0071 for ; Mon, 20 Sep 2021 15:07:42 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 125561814BA24 for ; Mon, 20 Sep 2021 19:07:42 +0000 (UTC) X-FDA: 78608885964.10.3976D4B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id A9A4EF00039F for ; Mon, 20 Sep 2021 19:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632164861; 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: in-reply-to:in-reply-to:references:references; bh=L5eNIsZ6KwBeoWOsBqwSADzC++5/odqrtaTxVloBqSU=; b=K2MHHcgpn6Mbnz6ibmG2BskuyeP+T2gGBVN05AxgsOHuUbVSzDz15fk+jZ8yLoR7G8MMBn VPNbstL3QZkqZwA8D0XGZFynYRXoCNKuzwL58W0AX2eO+qYdp0rtbsLl5aZd3OmwpDzWSx OSU76jYF7cLcvYcybCHUPHXh0gNRk/k= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-DZXArR7dMY2IqAA9GT_QpA-1; Mon, 20 Sep 2021 15:07:40 -0400 X-MC-Unique: DZXArR7dMY2IqAA9GT_QpA-1 Received: by mail-qv1-f72.google.com with SMTP id ci14-20020a056214054e00b0037a75ff56f9so189140464qvb.23 for ; Mon, 20 Sep 2021 12:07:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=L5eNIsZ6KwBeoWOsBqwSADzC++5/odqrtaTxVloBqSU=; b=b8Bsz+4Fpq6rUO9w7Xf9306jrIasCUyC/2JifA9JBQPQaLORznLlKYI1teqri4wP8B I4z94VyMcRiQj51hb4gPvW/bcbhNc72vh24Ag1gpJzOxlLm7CTHIzsbPRgi+eEEcJkqB jG2A8zqMVMyzErHDEDlZEaBRYcgom6OQyvkz+peZFcxcxXc04Wej404gjCbA2EYN2mS8 GM90RSZ5w62jsprA7qKMO2bAFjbykg/1DY3Jbz39wBwyEhwIoB+XASEdyrsntPJvpnmR L1v7sG7axPPSYZfU9iUAasUNFMvE9wg8HgngjNg/TleAx254ongqPbomYXveejwxUTub RsZw== X-Gm-Message-State: AOAM533DAVyd1qR4Cn51PjIMCWHC2U1JoviuRsedN50fifp5O4XEUCdE dd+s+BqXD6mz1ccc/b0920exepUSh2l7lJR7WfMHb61gMil0Qafnxh7ZmTv1AKloKjfwK2Pgaig UkT0AHaSrCYw= X-Received: by 2002:a0c:8e05:: with SMTP id v5mr26551519qvb.4.1632164858624; Mon, 20 Sep 2021 12:07:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUlhdb4yrs33oVaLc7KkLYEJohXWSRUXFQ1m3xANX2pAOEfK2wxqguR0SBw9ODXLL6u6zTSA== X-Received: by 2002:a0c:8e05:: with SMTP id v5mr26551482qvb.4.1632164858305; Mon, 20 Sep 2021 12:07:38 -0700 (PDT) Received: from t490s ([2607:fea8:56a2:9100::d3ec]) by smtp.gmail.com with ESMTPSA id s10sm11731979qko.134.2021.09.20.12.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Sep 2021 12:07:37 -0700 (PDT) Date: Mon, 20 Sep 2021 15:07:35 -0400 From: Peter Xu To: Tiberiu A Georgescu Cc: akpm@linux-foundation.org, corbet@lwn.net, david@redhat.com, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, ivan.teterevkov@nutanix.com, florian.schmidt@nutanix.com, carl.waldspurger@nutanix.com, jonathan.davies@nutanix.com Subject: Re: [PATCH v2 1/1] Documentation: update pagemap with shmem exceptions Message-ID: References: <20210920164931.175411-1-tiberiu.georgescu@nutanix.com> <20210920164931.175411-2-tiberiu.georgescu@nutanix.com> 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 Content-Disposition: inline X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A9A4EF00039F X-Stat-Signature: kinjgfeypgx1p14c67g4cbagjyh8ub15 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=K2MHHcgp; spf=none (imf17.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1632164861-343186 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: Hi, Tiberiu, Thanks for the patch! Yes it would still be nice to comment on this behavior, some trivial nitpicks below. On Mon, Sep 20, 2021 at 04:49:31PM +0000, Tiberiu A Georgescu wrote: > +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 s/LSEEK_DATA/SEEK_DATA/ > + you wish to inspect. If it overshoots the PAGE_SIZE, the page is NONE. > +3. Otherwise, the page is in swap. It could also not be in swap, right? Example 1: this process mmap()ed an existing shmem file with data filled in, but without accessing it yet. Then the page cache exists, not in swap, but pgtables will be empty. Example 2: this process has mapped this shmem with 2M thp, all data filled in, then due to some reason thp splits, then the pgtable can also be none but lseek will succeed, I think. So to further identify whether that's in swap, we need a step 5 with mincore() system call, perhaps? -- Peter Xu