From patchwork Wed Jul 6 23:59:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zach O'Keefe X-Patchwork-Id: 12908937 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 5A7CDC433EF for ; Thu, 7 Jul 2022 00:06:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF0C28E000D; Wed, 6 Jul 2022 20:06:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E79208E0001; Wed, 6 Jul 2022 20:06:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA5268E000D; Wed, 6 Jul 2022 20:06:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B47BF8E0001 for ; Wed, 6 Jul 2022 20:06:28 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8E1D12066D for ; Thu, 7 Jul 2022 00:06:28 +0000 (UTC) X-FDA: 79658362056.07.940F336 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf12.hostedemail.com (Postfix) with ESMTP id 43B3D4002C for ; Thu, 7 Jul 2022 00:06:28 +0000 (UTC) Received: by mail-pg1-f201.google.com with SMTP id u24-20020a63d358000000b004119798494fso6605571pgi.18 for ; Wed, 06 Jul 2022 17:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=H1jTBrV7K1aDNnJld1B/5IbYUIxSMosrS1B/voKPgmk=; b=Ng9+2i4u4cBH4LW2gBnwcajRPYmU/JXDk06tJU6Y3fHhh+DmRE++ip8u/7e4/mlYfu 2sx4aBzCKcZ2CCPcCLhvXSkgO7FDmOgGCzI0DBvlJyZnZxneGgR43UFTcnyn1I5/iQTs 6g/hoVJB/zyvWGlj/NPKzDnsya7uAdaXxOiM4y8zkuFiREwL3NJl2RFJ54aRiQ9id8Lb tBjdv0NB/aBCcfcwK3b/ODBqB3NCA+A7Eme6qSo8AKTeXE5EgqAHZetO4cRmUds1Wj6D fYxQ2HijJ8NjeBaueF2W4M9+KwEcBnhgXctZJbb+wBdMkmWhwnEBCiqt5YmHEz2TWiqx 8vUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=H1jTBrV7K1aDNnJld1B/5IbYUIxSMosrS1B/voKPgmk=; b=tgEH5fdLlhV7Xd6z0bj7qUr1ZVjXHRGmceVk1JZq5XkDkKgMr68x+JwKWgGKjlu90a sC+tRHjR1e9L25UteEoVtDNuhet9ZBaZooD2zWlXMbcvuYSQkwUF/17sBe3y4fXw5dlf NIlBTKJl/t8BxgHsLnTWgt4BJAPHE2jxEX550ivc48sILViJqN/h6DUQkCQfT1WJJ0cE 7XjjEpEHtTX81rT11vYLrvBU6WYE8HKildBvD+Kk0vqs/tD7cm9thxayOTJro4gVWy9F D1c2A6D8iHOOcnimxx+9CcPyXd9029vQ0gBweFfA7Wd2ZOhe7ub/NavVazvN/0tgJuL4 lg1w== X-Gm-Message-State: AJIora/3c/KydO8CviAJeteWFl9jRZvZispuJ3u9USxThUJMSrVB//wE jKkLsOkmJNjcpAiJQDQ4W2R4ZkY5dUko X-Google-Smtp-Source: AGRyM1s6B1F1YtkAop8Y1ZSpsZLOHKn+cXzqPNxYjWvNEbZquiOYdleLDzQ1FBZmwam+TCzc92K8/7jYaROj X-Received: from zokeefe3.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1b6]) (user=zokeefe job=sendgmr) by 2002:a17:902:e80a:b0:16a:311a:a672 with SMTP id u10-20020a170902e80a00b0016a311aa672mr49849362plg.161.1657152387341; Wed, 06 Jul 2022 17:06:27 -0700 (PDT) Date: Wed, 6 Jul 2022 16:59:31 -0700 In-Reply-To: <20220706235936.2197195-1-zokeefe@google.com> Message-Id: <20220706235936.2197195-14-zokeefe@google.com> Mime-Version: 1.0 References: <20220706235936.2197195-1-zokeefe@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [mm-unstable v7 13/18] proc/smaps: add PMDMappable field to smaps From: "Zach O'Keefe" To: Alex Shi , David Hildenbrand , David Rientjes , Matthew Wilcox , Michal Hocko , Pasha Tatashin , Peter Xu , Rongwei Wang , SeongJae Park , Song Liu , Vlastimil Babka , Yang Shi , Zi Yan , linux-mm@kvack.org Cc: Andrea Arcangeli , Andrew Morton , Arnd Bergmann , Axel Rasmussen , Chris Kennelly , Chris Zankel , Helge Deller , Hugh Dickins , Ivan Kokshaysky , "James E.J. Bottomley" , Jens Axboe , "Kirill A. Shutemov" , Matt Turner , Max Filippov , Miaohe Lin , Minchan Kim , Patrick Xia , Pavel Begunkov , Thomas Bogendoerfer , "Zach O'Keefe" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657152388; a=rsa-sha256; cv=none; b=T7WJCHXNguJXIdSLwzA4qpfhpQWYtk0NHyPXSvWAaq+7D+g/FmFJw5N5etg5Ae2SHnGMJ8 sV4kzPLhOuoEh1VHxXtTtGPrm2c2sm96Kc0/0cAyqZjR1u0EJE16a89/2c6GWoiC79crrE oalMDRwI1D9TZm1u6hwIBKRC1N6WiGk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Ng9+2i4u; spf=pass (imf12.hostedemail.com: domain of 3gyPGYgcKCP45uqkklkmuumrk.iusrot03-ssq1giq.uxm@flex--zokeefe.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3gyPGYgcKCP45uqkklkmuumrk.iusrot03-ssq1giq.uxm@flex--zokeefe.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657152388; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=H1jTBrV7K1aDNnJld1B/5IbYUIxSMosrS1B/voKPgmk=; b=Tk442k4pty0CGG8QsLjyedW/8axDC19wzswZrGqlq/iDJH1UIMiDtimoTxxiKLoX9REQH5 4C/cJySCTc3FzC6cBcllLK31SYHpGaXVC+qIeFa9240bn2XDpGFo7sloAwOjf+Ac/3e6CM KjIE+V5A3BIr3bn7OFkR2hYH/82nXw0= Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Ng9+2i4u; spf=pass (imf12.hostedemail.com: domain of 3gyPGYgcKCP45uqkklkmuumrk.iusrot03-ssq1giq.uxm@flex--zokeefe.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3gyPGYgcKCP45uqkklkmuumrk.iusrot03-ssq1giq.uxm@flex--zokeefe.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: yqbmrgan4198mgqsa14mzkghiydmy8mz X-Rspamd-Queue-Id: 43B3D4002C X-HE-Tag: 1657152388-741875 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: Add PMDMappable field to smaps output which informs the user if memory in the VMA can be PMD-mapped by MADV_COLLAPSE. The distinction from THPeligible is needed for two reasons: 1) For THP, MADV_COLLAPSE is not coupled to THP sysfs controls, which THPeligible reports. 2) PMDMappable can also be used in HugeTLB fine-granularity mappings, which are independent from THP. Signed-off-by: Zach O'Keefe --- Documentation/filesystems/proc.rst | 10 ++++++++-- fs/proc/task_mmu.c | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 47e95dbc820d..f207903a57a5 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -466,6 +466,7 @@ Memory Area, or VMA) there is a series of lines such as the following:: MMUPageSize: 4 kB Locked: 0 kB THPeligible: 0 + PMDMappable: 0 VmFlags: rd ex mr mw me dw The first of these lines shows the same information as is displayed for the @@ -518,9 +519,14 @@ replaced by copy-on-write) part of the underlying shmem object out on swap. does not take into account swapped out page of underlying shmem objects. "Locked" indicates whether the mapping is locked in memory or not. +"PMDMappable" indicates if the memory can be mapped by PMDs - 1 if true, 0 +otherwise. It just shows the current status. Note that this is memory +operable on explicitly by MADV_COLLAPSE. + "THPeligible" indicates whether the mapping is eligible for allocating THP -pages as well as the THP is PMD mappable or not - 1 if true, 0 otherwise. -It just shows the current status. +pages by the kernel, as well as the THP is PMD mappable or not - 1 if true, 0 +otherwise. It just shows the current status. Note this is memory the kernel can +transparently provide as THPs. "VmFlags" field deserves a separate description. This member represents the kernel flags associated with the particular virtual memory area in two letter diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index f8cd58846a28..29f2089456ba 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -867,6 +867,8 @@ static int show_smap(struct seq_file *m, void *v) seq_printf(m, "THPeligible: %d\n", hugepage_vma_check(vma, vma->vm_flags, true, false, true)); + seq_printf(m, "PMDMappable: %d\n", + hugepage_vma_check(vma, vma->vm_flags, true, false, false)); if (arch_pkeys_enabled()) seq_printf(m, "ProtectionKey: %8u\n", vma_pkey(vma));