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 B42C0C433F5 for ; Tue, 23 Nov 2021 21:11:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 252476B0072; Tue, 23 Nov 2021 16:11:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 202356B0074; Tue, 23 Nov 2021 16:11:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CA7C6B0075; Tue, 23 Nov 2021 16:11:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0236.hostedemail.com [216.40.44.236]) by kanga.kvack.org (Postfix) with ESMTP id EFB896B0072 for ; Tue, 23 Nov 2021 16:10:59 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B16EF827663E for ; Tue, 23 Nov 2021 21:10:49 +0000 (UTC) X-FDA: 78841439502.10.84E274E Received: from mail-il1-f178.google.com (mail-il1-f178.google.com [209.85.166.178]) by imf23.hostedemail.com (Postfix) with ESMTP id F16879000388 for ; Tue, 23 Nov 2021 21:10:44 +0000 (UTC) Received: by mail-il1-f178.google.com with SMTP id l8so429585ilv.3 for ; Tue, 23 Nov 2021 13:10:49 -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=FLDl0AcNYTJVo90T0ikRPoOCcN+nFjw2fk9E2jlxHm0=; b=ee1y/8pWQqFIlU2moAaj0G8MwXibMQ6JD/r9AjXTqXwO5LlMnDM0X7pPgZnoO/NACK uJwc0NegcEpLzeX22d5NEqty/klXVqmtw3K677vBycR6tJYbmVqa1awY5lO/tKfDeXDk ULZpu714imlEZzPTgFvqTqbN7DgTpjN4y6IpL6fWdBLkuxFpMzXCLZjQyl/BVcFoVssf iukmWDVuuEok+5zDV68mEKEAHOgUC6psjAcpfgKAlUubzhXP7tAGi2l81DnkhgZxcwda ri6YPKXUPY+nUVhuHFmLk2QR5heWl3QGGKVRWLF+7d0DMCin3WHQ64sHiWBrSu/QEeRy +4MA== 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=FLDl0AcNYTJVo90T0ikRPoOCcN+nFjw2fk9E2jlxHm0=; b=Un84EA5WDhR96Hdg2hYv18A4A9iRK3RAfeDJJdVG+3K4u+z8DVxrbsWlBsX2eL1W7d wR69/mqcUMdBRcBhDS1DjaZ6nWpiSw1WtpagR4v5skgwV2eWp1Tx85QkWqOuMtJ9lek/ ejnsGfo69CcUJQHKKoOu/70W8oeaArSKY4zifFgxP+OjbwI3kndDlqM12aTR5DQf58eM B3ZH3cI8ewo8JkdsO6oniwfdtDJX05oJpCNYE2Su3Cwd9iim9rQnrS++um5GS3qqKFe2 PIgG6mGVj7nKdpIsOndvyxTA1Ct01MMD1H/HXjX0zgnPgKiwTnM0xGAn05EJf1xuJdSL dp2Q== X-Gm-Message-State: AOAM533xWlTyXGM13wcNzhTB9MLO+Tpoq+k2vvSi3DA8AIabixv8xFu8 VZziW2toVNGxGYbUcNgdxlN9+gDbabyFL0uLfU1D8g== X-Google-Smtp-Source: ABdhPJwflQAlAlhXlis1geqZoQrYzfqnD13b3VHES42zh8wYx0T2LaXbrlPZHRtoI3mfBEAYceSNyc2pQNjfZr85F6E= X-Received: by 2002:a05:6e02:1bc3:: with SMTP id x3mr7808639ilv.39.1637701848501; Tue, 23 Nov 2021 13:10:48 -0800 (PST) MIME-Version: 1.0 References: <20211123000102.4052105-1-almasrymina@google.com> In-Reply-To: From: Mina Almasry Date: Tue, 23 Nov 2021 13:10:37 -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-Stat-Signature: 7nz5z4okiqddme39zqa8o8xn8ndqcfi4 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="ee1y/8pW"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of almasrymina@google.com designates 209.85.166.178 as permitted sender) smtp.mailfrom=almasrymina@google.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: F16879000388 X-HE-Tag: 1637701844-288892 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 12:51 PM Matthew Wilcox wrote: > > On Mon, Nov 22, 2021 at 04:01:02PM -0800, Mina Almasry wrote: > > Add PM_THP_MAPPED MAPPING to allow userspace to detect whether a given virt > > address is currently mapped by a transparent huge page or not. Example > > use case is a process requesting THPs from the kernel (via a huge tmpfs > > mount for example), for a performance critical region of memory. The > > userspace may want to query whether the kernel is actually backing this > > memory by hugepages or not. > > So you want this bit to be clear if the memory is backed by a hugetlb > page? > Yes I believe so. I do not see value in telling the userspace that the virt address is backed by a hugetlb page, since if the memory is mapped by MAP_HUGETLB or is backed by a hugetlb file then the memory is backed by hugetlb pages and there is no vagueness from the kernel here. Additionally hugetlb interfaces are more size based rather than PMD or not. arm64 for example supports 64K, 2MB, 32MB and 1G 'huge' pages and it's an implementation detail that those sizes are mapped CONTIG PTE, PMD, CONITG PMD, and PUD respectively, and the specific mapping mechanism is typically not exposed to the userspace and might not be stable. Assuming pagemap_hugetlb_range() == PMD_MAPPED would not technically be correct. > > if (page && page_mapcount(page) == 1) > > flags |= PM_MMAP_EXCLUSIVE; > > + if (page && is_transparent_hugepage(page)) > > + flags |= PM_THP_MAPPED; > > because honestly i'd expect it to be more useful to mean "This memory > is mapped by a PMD entry" and then the code would look like: > > if (page) > flags |= PM_PMD_MAPPED; > > (and put a corresponding change in pagemap_hugetlb_range)