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 CF534C433EF for ; Mon, 11 Jul 2022 21:38:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1775A6B00B7; Mon, 11 Jul 2022 17:38:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 102506B00BA; Mon, 11 Jul 2022 17:38:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F0C996B00BC; Mon, 11 Jul 2022 17:38:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id DAE926B00B7 for ; Mon, 11 Jul 2022 17:38:12 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id A040F1208C4 for ; Mon, 11 Jul 2022 21:38:12 +0000 (UTC) X-FDA: 79676132424.11.2414E50 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf15.hostedemail.com (Postfix) with ESMTP id 55651A0059 for ; Mon, 11 Jul 2022 21:38:12 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id 89-20020a17090a09e200b001ef7638e536so9578506pjo.3 for ; Mon, 11 Jul 2022 14:38:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZSF/Ti5tmKtXRJAfy10enY8TN01JjlNjBe9aOE359U8=; b=OGeANeUkyJDlWvdsyahC8Fc2S4LkCI/dJjv/RzNNFFGkRjwmzVohKdQCLuQOVDfOD9 U6E8xVId3xwKVhgkVh8pAFP4LiJBVHpRoNs6ewvvvj9y2Jkzl+AjV4z7OvPnxs3HBeP5 BB6SP2+MMAUUCmqEhXtQ1DhsoKVlzaSrz5hY4A4G6UTag9hDtTyYiJyNdZyDQDwNDbr8 RL089WVsW9FXDHGRhYOCATSCSL/y0lo0vhDLFB7knoPf3l+4ot2Ms1F78/Z9/vCp8p2S 7rPXXJK4XM9oJOZQQ9rG9mJ8ORTnmGQFED987agjamMIKX9qds3IeZuwg4A+0FTS2ntt tLPA== 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=ZSF/Ti5tmKtXRJAfy10enY8TN01JjlNjBe9aOE359U8=; b=6N8kWtazXF37iieDlIJP0JPDlIRB752rXnFGacP9NavHwPfzZ67UeBmQROBqBESKii x7VqRZKIW5WG+txpwk/EP/OpRJ9CLtYncX6n+2Lowi8cWrss5slv9gZfdCiP7HyyAPaX CFynODJu0RD1Icjfy5Xg3Gd/odMxPGZdaNz3rH+9LpOpQwYo4hXw0qbaVLvgPCLC2qDN ZK1UxqPoRFlwBg5wWjEI9ZhXftqxOrbMUJGEJf+bX35uapeTZ3v0JEatH+IyTOfK2iHF pjuVFYZ+jZX+4b5mOgrxNnwt/hyuViN1xD9CFITR4gurYOVW35vgAvg6KhaslJ9CrR/j Ks+w== X-Gm-Message-State: AJIora8NhUcBQwnhvJ/9JMtZrWudZ+uVUub5SsrLmkPnRc/tBUsG/Kz8 Ubys2UEdLyTGHB5M+W1WGUChYhY3LdHHN2HGVys= X-Google-Smtp-Source: AGRyM1vZ/iLH73bpr982tv8c/8/b3k6Ni4ImCxeN4rlfMEqVaNA21djj4xY3K7KyKrnpxnnQnJ5/zEWW3M/BGLJ1BYc= X-Received: by 2002:a17:903:32c3:b0:16b:fbc3:3269 with SMTP id i3-20020a17090332c300b0016bfbc33269mr21436960plr.117.1657575491384; Mon, 11 Jul 2022 14:38:11 -0700 (PDT) MIME-Version: 1.0 References: <20220706235936.2197195-1-zokeefe@google.com> <20220706235936.2197195-14-zokeefe@google.com> In-Reply-To: <20220706235936.2197195-14-zokeefe@google.com> From: Yang Shi Date: Mon, 11 Jul 2022 14:37:58 -0700 Message-ID: Subject: Re: [mm-unstable v7 13/18] proc/smaps: add PMDMappable field to smaps To: "Zach O'Keefe" Cc: Alex Shi , David Hildenbrand , David Rientjes , Matthew Wilcox , Michal Hocko , Pasha Tatashin , Peter Xu , Rongwei Wang , SeongJae Park , Song Liu , Vlastimil Babka , Zi Yan , Linux MM , 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 Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657575492; a=rsa-sha256; cv=none; b=BsE41Sh+uDwq9gq8Wg/SojlLB0nFJqRV7u9bxcHNS7UwDVNe9ZKq7E/WaxW6S3oUiKyMx6 CRn8mxcFRnFTbx+mCJdGe26ADqLl174pkJ+nQTwXDuikIKMhtPyjWp77zLMKAygSLtj2IK veZnH6h8U2OEjZgUCNGHJmuxb0hzP5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657575492; 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=ZSF/Ti5tmKtXRJAfy10enY8TN01JjlNjBe9aOE359U8=; b=Bqa7Gzsl2RzO1tr7xV2Xm1OZ95qwXr9W45m3C80WMbvn3YI2R1fLN0JA43Gf1wG5CC+pV/ iWDyHlBIbnCO6ILwx59BHsiYv7vtCzblBWJhvp2ezoQkJRGbfX5G7vXv9qJSUnrOhHNBFI /1PKvrUqOf0cazFPMQiseOk2NelWEiM= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OGeANeUk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=shy828301@gmail.com Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OGeANeUk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: piq4kbic79x4sfmzfwt3kj6zkaotkywk X-Rspamd-Queue-Id: 55651A0059 X-Rspam-User: X-HE-Tag: 1657575492-526017 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 Wed, Jul 6, 2022 at 5:06 PM Zach O'Keefe wrote: > > 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. Could you please elaborate the usecase? The user checks this hint before calling MADV_COLLAPSE? Is it really necessary? And, TBH it sounds confusing and we don't have to maintain both THPeligible and PMDMappable. We could just relax THPeligible to make it return 1 even though THP is disabled by sysfs but MADV_COLLAPSE could collapse it if such hint is useful. > > 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)); > -- > 2.37.0.rc0.161.g10f37bed90-goog >