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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF6E2C433F5 for ; Tue, 23 Nov 2021 22:24:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 200686B0072; Tue, 23 Nov 2021 17:23:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B0DD6B0073; Tue, 23 Nov 2021 17:23:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 04F986B0074; Tue, 23 Nov 2021 17:23:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id E7CA56B0072 for ; Tue, 23 Nov 2021 17:23:45 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id ABC1D1829CF44 for ; Tue, 23 Nov 2021 22:23:35 +0000 (UTC) X-FDA: 78841622790.06.70A224B Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by imf25.hostedemail.com (Postfix) with ESMTP id 9BE44B0002B1 for ; Tue, 23 Nov 2021 22:23:32 +0000 (UTC) Received: by mail-io1-f51.google.com with SMTP id 14so651177ioe.2 for ; Tue, 23 Nov 2021 14:23:35 -0800 (PST) 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=mH04q1REZQWYt1Q0v2diML2IPmTCGEO05yrWYNlZUvU=; b=PAxO8mtkJkocmQUq1tHub6eT9LmXcjz/IyTvDHCbh9IzWi4yYlzEOIgtgsrdFFpvnZ O/QyrOTYecCHuQY5xM4PBgsFHrzLK8DeE0QIU0vH3lwtcwj61rdf0NZECADfEkXuLC6J E+6eCXt9mffGOH2HD0zewF5G93AlOSyG8bTz2G3jh2X1XhsTRZqCWS47fB/UYovTGjav DgNZ/Ww+pZnAQs6i7/vswJ5keQuiJPgWAXrxHCNEZIBDs6HKKf0KDJNpt+u+M30eOsiE eJH1UwA4kW9KQYDWDv+YpTbnTfNzD3e4RMdmit+lUoGH7P7PmM5im2RAnov/P9YLffTu HL2A== 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=mH04q1REZQWYt1Q0v2diML2IPmTCGEO05yrWYNlZUvU=; b=A+1NjaEDWO2kyjVrSTDELwJwf+WvzktrqpApWX0V73WjTNn3wbOLwBNtZjw7LKmaEb PHs42PGJxMU+GsaWo2+hibVi7ZrTlnPN+foS27ZChqlyA0G01VUQd2hm71QnvRbdOlOd Eo5ZrY7xx3HlsFXP+NY2fT8xIFgy6TyvWDrsU9Agk9qq/qW640JyFyXZEPiB/8a0ikFh jc5HweXVp6KqoBjd5m6lBOkPQIg3GdenMwxUssiirYZmrlLfoa7wKCLGzT9Ad1eL3O0s KfDHD9IsnVTwj/qn2ozsuWVFTajm0wxD+J/+bNNHndki0izQ15LEm8crhHJGkaO0AF9c cyfQ== X-Gm-Message-State: AOAM533dW3wH4+/2gGDRzlH2sxIHf9MdZqV7GwAH1Ti+INH9WVJJH2pn XMu0RHkWarz2C88W3+XPQ4ia1KPKZ6WoCyG43uXeFg== X-Google-Smtp-Source: ABdhPJwOUy/LIWpKCQbwgpf+7ctYVg3vIeHN4QYchB1iSGuZIxAE2HiUz18rhQQdtEdqw9cG1fFRxo9C+gJu9EpFPAI= X-Received: by 2002:a05:6638:4183:: with SMTP id az3mr10362179jab.56.1637706214522; Tue, 23 Nov 2021 14:23:34 -0800 (PST) MIME-Version: 1.0 References: <20211123000102.4052105-1-almasrymina@google.com> In-Reply-To: From: Mina Almasry Date: Tue, 23 Nov 2021 14:23:23 -0800 Message-ID: Subject: Re: [PATCH v7] mm: Add PM_THP_MAPPED to /proc/pid/pagemap To: Matthew Wilcox Cc: Jonathan Corbet , David Hildenbrand , "Paul E . McKenney" , Yu Zhao , Andrew Morton , Peter Xu , Ivan Teterevkov , Florian Schmidt , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9BE44B0002B1 X-Stat-Signature: 79w8n4ot3o36rtet7uhs1g958wsitgif Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=PAxO8mtk; spf=pass (imf25.hostedemail.com: domain of almasrymina@google.com designates 209.85.166.51 as permitted sender) smtp.mailfrom=almasrymina@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1637706212-664985 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 Tue, Nov 23, 2021 at 2:03 PM Matthew Wilcox wrote: > > On Tue, Nov 23, 2021 at 01:47:33PM -0800, Mina Almasry wrote: > > On Tue, Nov 23, 2021 at 1:30 PM Matthew Wilcox wrote: > > > What I've been trying to communicate over the N reviews of this > > > patch series is that *the same thing is about to happen to THPs*. > > > Only more so. THPs are going to be of arbitrary power-of-two size, not > > > necessarily sizes supported by the hardware. That means that we need to > > > be extremely precise about what we mean by "is this a THP?" Do we just > > > mean "This is a compound page?" Do we mean "this is mapped by a PMD?" > > > Or do we mean something else? And I feel like I haven't been able to > > > get that information out of you. > > > > Yes, I'm very sorry for the trouble, but I'm also confused what the > > disconnect is. To allocate hugepages I can do like so: > > > > mount -t tmpfs -o huge=always tmpfs /mnt/mytmpfs > > > > or > > > > madvise(..., MADV_HUGEPAGE) > > > > Note I don't ask the kernel for a specific size, or a specific mapping > > mechanism (PMD/contig PTE/contig PMD/PUD), I just ask the kernel for > > 'huge' pages. I would like to know whether the kernel was successful > > in allocating a hugepage or not. Today a THP hugepage AFAICT is PMD > > mapped + is_transparent_hugepage(), which is the check I have here. In > > the future, THP may become an arbitrary power of two size, and I think > > I'll need to update this querying interface once/if that gets merged > > to the kernel. I.e, if in the future I allocate pages by using: > > > > mount -t tmpfs -o huge=2MB tmpfs /mnt/mytmpfs > > > > I need the kernel to tell me whether the mapping is 2MB size or not. > > > > If I allocate pages by using: > > > > mount -t tmpfs -o huge=pmd tmpfs /mnt/mytmps, > > > > Then I need the kernel to tell me whether the pages are PMD mapped or > > not, as I'm doing here. > > > > The current implementation is based on what the current THP > > implementation is in the kernel, and depending on future changes to > > THP I may need to update it in the future. Does that make sense? > > Well, no. You're adding (or changing, if you like) a userspace API. > We need to be precise about what that userspace API *means*, so that we > don't break it in the future when the implementation changes. You're > still being fuzzy above. > > I have no intention of adding an API like the ones you suggest above to > allow the user to specify what size pages to use. That seems very strange > to me; how should the user (or sysadmin, or application) know what size is > best for the kernel to use to cache files? Instead, the kernel observes > the usage pattern of the file (through the readahead mechanism) and grows > the allocation size to fit what the kernel thinks will be most effective. > > I do honour some of the existing hints that userspace can provide; eg > VM_HUGEPAGE makes the pagefault path allocate PMD sized pages (if it can). Right, so since VM_HUGEPAGE makes the kernel allocate PMD mapped THP if it can, then I want to know if the page is actually a PMD mapped THP or not. The implementation and documentation that I'm adding seem consistent with that AFAICT, but sorry if I missed something. > But there's intentionally no new way to tell the kernel to use pages > of a particular size. The current implementation will use (at least) > 64kB pages if you do reads in 64kB chunks, but that's not guaranteed.