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 3F15EC433F5 for ; Tue, 23 Nov 2021 01:11:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96D6C6B0071; Mon, 22 Nov 2021 20:11:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 91CF66B0072; Mon, 22 Nov 2021 20:11:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BDA46B0073; Mon, 22 Nov 2021 20:11:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0128.hostedemail.com [216.40.44.128]) by kanga.kvack.org (Postfix) with ESMTP id 6AB1B6B0071 for ; Mon, 22 Nov 2021 20:11:02 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2C7D41802799F for ; Tue, 23 Nov 2021 01:10:52 +0000 (UTC) X-FDA: 78838415586.10.0167DFF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 316CE5092EFE for ; Tue, 23 Nov 2021 01:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637629851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=jSNsXUxZeHRu0Q3CAyM4RATVnGjbqHemvgQDThYQQv4=; b=MNaq5YQ26iZCCSh5LAtShkvSKot1HrUkqMHoxzS+v+o92qNaOrIfpuR3VXRBI9/GfRVBUE j0BW8BTtRF1FFMTZQ6b/yAWh3uGqlTRz9xe2fpoc4eKEq1CrFwAJVNH8S3rSQfMIF7bjYY osXEUiYBI3YZ4fRV+eug44qb1vIVEVA= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-311-DoJVSRBJObq1GeP5bvD5ow-1; Mon, 22 Nov 2021 20:10:50 -0500 X-MC-Unique: DoJVSRBJObq1GeP5bvD5ow-1 Received: by mail-pf1-f198.google.com with SMTP id l7-20020a622507000000b00494608c84a4so10780674pfl.6 for ; Mon, 22 Nov 2021 17:10:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jSNsXUxZeHRu0Q3CAyM4RATVnGjbqHemvgQDThYQQv4=; b=OJHukMt/YW8ct4F0RtiCMXGirzIWEDwXH5zt7jMhE2AofBL8fAcpJN1aE55znbXsa6 0tQUNlrjpijPLyEi0hhwxcqSFfZqvx2GUSJT4yQs8eHcnBN4y2qIM2c1yPAZP105VCby OEklTLwqlrAqTOQ1Qz81Rl8LEmb5jGLDZOczsirsabeGQyjYMMogRF5P3OjUAzt1anmW wZi09trV8hYeUxqnlsa6bOgxEHCT/Ws3WKWg/c/hzFoWjnfxWpRPhKdYgQ2EWCeYC2zq PFR58m5Y/vn14CF9YnLoDCt7SUZkF1oL2xFeRKDVRB3xc9GWrFurOM7EbDBm4JDr9Rvn AZ3A== X-Gm-Message-State: AOAM531ZjDR5pX4uagdnSVRQQtPTxd1YABehDzAIt+f5/YOFV+Y/FwAj sTD/CXeL231SHqNxO7YRbh6X8Gowp60jygaOAs//jIYARP5wGU4SwfPnwjxpqSpXkm0uVWEFfQm 7gj3DSbyhpGo= X-Received: by 2002:a05:6a00:24cd:b0:49f:bf3f:c42c with SMTP id d13-20020a056a0024cd00b0049fbf3fc42cmr1258161pfv.54.1637629848932; Mon, 22 Nov 2021 17:10:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJyr+K6p+Ta9LDXXKzVi141QLJFFFwRJJs9XYA9zCFJq4acwgirIvACPF1I3gsGqa7J5/Al6vg== X-Received: by 2002:a05:6a00:24cd:b0:49f:bf3f:c42c with SMTP id d13-20020a056a0024cd00b0049fbf3fc42cmr1258124pfv.54.1637629848607; Mon, 22 Nov 2021 17:10:48 -0800 (PST) Received: from xz-m1.local ([191.101.132.71]) by smtp.gmail.com with ESMTPSA id n1sm9671176pfj.193.2021.11.22.17.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Nov 2021 17:10:48 -0800 (PST) Date: Tue, 23 Nov 2021 09:10:40 +0800 From: Peter Xu To: Mina Almasry Cc: Jonathan Corbet , David Hildenbrand , Matthew Wilcox , "Paul E . McKenney" , Yu Zhao , Andrew Morton , Ivan Teterevkov , Florian Schmidt , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org Subject: Re: [PATCH v7] mm: Add PM_THP_MAPPED to /proc/pid/pagemap Message-ID: References: <20211123000102.4052105-1-almasrymina@google.com> MIME-Version: 1.0 In-Reply-To: <20211123000102.4052105-1-almasrymina@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Stat-Signature: 3cfpq1smge6trnyhioxatrfxx3h9tfmr Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MNaq5YQ2; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf01.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=peterx@redhat.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 316CE5092EFE X-HE-Tag: 1637629848-874470 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 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. > > PM_THP_MAPPED bit is set if the virt address is mapped at the PMD > level and the underlying page is a transparent huge page. > > A few options were considered: > 1. Add /proc/pid/pageflags that exports the same info as > /proc/kpageflags. This is not appropriate because many kpageflags are > inappropriate to expose to userspace processes. > 2. Simply get this info from the existing /proc/pid/smaps interface. > There are a couple of issues with that: > 1. /proc/pid/smaps output is human readable and unfriendly to > programatically parse. > 2. /proc/pid/smaps is slow because it must read the whole memory range > rather than a small range we care about. The cost of reading > /proc/pid/smaps into userspace buffers is about ~800us per call, > and this doesn't include parsing the output to get the information > you need. The cost of querying 1 virt address in /proc/pid/pagemaps > however is around 5-7us. > > Tested manually by adding logging into transhuge-stress, and by > allocating THP and querying the PM_THP_MAPPED flag at those > virtual addresses. > > Signed-off-by: Mina Almasry Acked-by: Peter Xu -- Peter Xu