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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 715FAC433F5 for ; Thu, 4 Nov 2021 22:45:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0DE4461220 for ; Thu, 4 Nov 2021 22:45:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0DE4461220 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 715366B0071; Thu, 4 Nov 2021 18:45:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 69D656B0072; Thu, 4 Nov 2021 18:45:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53D4A940007; Thu, 4 Nov 2021 18:45:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0188.hostedemail.com [216.40.44.188]) by kanga.kvack.org (Postfix) with ESMTP id 403386B0071 for ; Thu, 4 Nov 2021 18:45:21 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E4A9775332 for ; Thu, 4 Nov 2021 22:45:20 +0000 (UTC) X-FDA: 78772730400.06.A948B5A Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by imf27.hostedemail.com (Postfix) with ESMTP id 8D097700009B for ; Thu, 4 Nov 2021 22:45:20 +0000 (UTC) Received: by mail-pg1-f179.google.com with SMTP id n23so6681900pgh.8 for ; Thu, 04 Nov 2021 15:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ez2Kc0qXfdZyVoueN+pRzSOTizwvVrWSdL7MhI68c/Y=; b=Nc5Ztqd9MT0ZUdLObZFAeRL2+SQYPyGlV4Sarkhyd9wRLOOShAuNS1GkpBUPRmdOOd RoESPqO/cJ9pKhy4ylZ6iQ6OPwTbZ59cKJPiceR2v/IjjCoEK/qHC6YuIgQHW/646zvB pTVMgjhR61eVK/HSdy/hDG07731O6d4qkxk87l31AN3nEHU0nYr8y0RoG5P9moF3KQZP 216NP565fi5Fxy+ffK3IjZr/furTG0zHEtzabwmGV9VeTwvsRJQ6fN9CHXgv42XpPUSJ b+X5cHlQEKE9qvf6xVJqm8Vw47LAaYS0E6zaLZZBX5hhvc59cs6AJfoKBh92BvtsuDNB WrFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ez2Kc0qXfdZyVoueN+pRzSOTizwvVrWSdL7MhI68c/Y=; b=UWKuHZOY+ZiqxmKuH4KTDt3MV1zj2/OFCbYV6cf9TAAUkixzKW+SLINJzpz/835aNz aEAiZoFR58Bm8h5+uZv2xn2r8xBuaUuZZ81Ejd3D/j88I83Ly37ZqQWDHFDHtxP0wf1E pLjAVmPsepiirPpQieneMuHn3USb566rsdFMlhn4zyOois4EGupcxu+Q8Mz0cX/WbxbD ngKSvWlCmzE7TZ2Q5VYxfJX2cE8Y/hCXo25mpNZkW1xKoEE5PxQFmrSAz1pMlkdTXU47 wB7CXW30Tm+C3F31g3CunWPOwT/2ZAiFNr9aj4kgwb7Ml4m8WNh+u233x0K4SkxJdTkV DMXg== X-Gm-Message-State: AOAM532qNRr40kxnaF7AACzpeCIFynlVhX+wY9d/leYeLAz5AQrmybaV Cm1VgtUvLtCyJpr1PyG1lB6wL1gi9xh4AryzYzL77Q== X-Google-Smtp-Source: ABdhPJyyaBvoljTK7Xrm6XhzgfUQ/jdbwXvs/7ewAf+ELaJzbp6FekSKyfbkoStxKxUZyf/31byNV+ks+CYodyeVKYM= X-Received: by 2002:a05:6a00:1484:b0:48c:2e58:8d39 with SMTP id v4-20020a056a00148400b0048c2e588d39mr18010577pfu.13.1636065919224; Thu, 04 Nov 2021 15:45:19 -0700 (PDT) MIME-Version: 1.0 References: <20211104214636.450782-1-almasrymina@google.com> In-Reply-To: From: Mina Almasry Date: Thu, 4 Nov 2021 15:45:07 -0700 Message-ID: Subject: Re: [PATCH v2] mm: Add PM_THP to /proc/pid/pagemap To: Matthew Wilcox Cc: "Paul E . McKenney" , Yu Zhao , Jonathan Corbet , Andrew Morton , Peter Xu , Ivan Teterevkov , David Hildenbrand , Florian Schmidt , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 8D097700009B X-Stat-Signature: yzh8m7bj4nfc6rym3bogqf76hmmx9jru Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Nc5Ztqd9; spf=pass (imf27.hostedemail.com: domain of almasrymina@google.com designates 209.85.215.179 as permitted sender) smtp.mailfrom=almasrymina@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1636065920-494619 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 Thu, Nov 4, 2021 at 3:08 PM Matthew Wilcox wrote: > > On Thu, Nov 04, 2021 at 02:46:35PM -0700, Mina Almasry wrote: > > Add PM_THP to allow userspace to detect whether a given virt address is > > currently mapped by a hugepage or not. > > Well, no, that's not what that means. > Sorry, that was the intention, but I didn't implement the intention correctly. > > @@ -1396,6 +1397,8 @@ static pagemap_entry_t pte_to_pagemap_entry(struct pagemapread *pm, > > flags |= PM_FILE; > > if (page && page_mapcount(page) == 1) > > flags |= PM_MMAP_EXCLUSIVE; > > + if (page && PageTransCompound(page)) > > + flags |= PM_THP; > > All that PageTransCompound() does is call PageCompound(). It doesn't > tell you if the underlying allocation is PMD sized, nor properly aligned. > > And you didn't answer my question about whether you want information about > whether a large page is being used that's not quite as large as a PMD. > Sorry, I thought the implementation would make it clear but I didn't do that correctly. Right now and for the foreseeable future what I want to know is whether the page is mapped by a PMD. All the below work for me: 1. Flag is set if the page is either a PMD size THP page. 2. Flag is set if the page is either a PMD size THP page or PMD size hugetlbfs page. 3. Flag is set if the page is either a PMD size THP page or PMD size hugetlbfs page or contig PTE size hugetlbfs page. I prefer #2 and I think it's maybe most extensible for future use cases that 1 flag tells whether the page is PMD hugepage and another flag is a large cont PTE page.