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 184A3C433F5 for ; Tue, 23 Nov 2021 01:51:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76E686B0071; Mon, 22 Nov 2021 20:50:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 71C436B0072; Mon, 22 Nov 2021 20:50:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E2E86B0073; Mon, 22 Nov 2021 20:50:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id 4BA296B0071 for ; Mon, 22 Nov 2021 20:50:58 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0DA3D184FA896 for ; Tue, 23 Nov 2021 01:50:48 +0000 (UTC) X-FDA: 78838516134.24.9016011 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf28.hostedemail.com (Postfix) with ESMTP id A47AE90000BB for ; Tue, 23 Nov 2021 01:50:47 +0000 (UTC) Received: by mail-pj1-f46.google.com with SMTP id o6-20020a17090a0a0600b001a64b9a11aeso1484621pjo.3 for ; Mon, 22 Nov 2021 17:50:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=HTzCF6jo65htyBDPrBpILeuvBdfXuhBAIKFNppjW8x0=; b=S6zMZEH+VmGFF/xsCr6aCbyNpxx1pxYIOJuVyfkhQNaxEH5T5BMG3mtU+HtkGq0ZNf MX8Fmo5U4MBHtVBCyO2WsuhFQYLk1zI3fbwn2Kn2KDKNHWA5Eifl/6ZRfDkJ1RxeWViV XY/3aPlZMKgcNtF0rISzPQCt1I4M63iRdN4SxFACjhKvXWwIgXK7oKGs91ePkwJ24Pw8 YnKl2pDB16dO9oPqjbvqCgFUA4akW8Q5jpbD12C/Z4cf0matfKmmtSeSqF+wtf+kw8Ex CcTrwDptzTTBK2GdJ/WMckd65hFkOQlnl7i0Nf2EvhRnoe+oJV1qfEwL+pHyGjf62Roj /zlg== 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:in-reply-to:message-id :references:mime-version; bh=HTzCF6jo65htyBDPrBpILeuvBdfXuhBAIKFNppjW8x0=; b=e3ymFoxKSe3YKryw4rtcqMqMCp4+rnzng7h6S5WhtMbbT+TCLUbD12aVjGz7kPkU7Z FZeMCn7LaN7tJOV+toTAWrOQkS3jonVbIiKEN03hMqer5dW0HHbXUksYmDOhsMlvpqKL YDSAGzw/lYoc+IK3ajKld9+wgnbgtR8D7Huf4uHFN9oJU+uRSJ4loR4ovxp8nAlqYQeo UWB3ITwl0oObsY2+Ete7L6aORFZ13B+vPUwzb+aICDzYOx57caPua2oxuUXh8nGE1g8R iMcDjUVYxSY/OE8Yt/wUdjiguU5FAnNUU/+dQWejJj5CjKLGIsduM7RkoxtETGpOmtwO 6w5w== X-Gm-Message-State: AOAM530Wuojz4hUd/d6mX+kMrc9spHCQcYK9/7yEqif83SP4JvfsKmZ0 xx/6zzx2l5Axzpc6l5wMEQTwKw== X-Google-Smtp-Source: ABdhPJxQ/8pqCEDnIj+5QGwd3pdxrE9t/GxEAizWH0isuFT+ppdRZmYdF7x41Z64MCWW5JOlqy1cHw== X-Received: by 2002:a17:90a:17ef:: with SMTP id q102mr1899751pja.116.1637632246379; Mon, 22 Nov 2021 17:50:46 -0800 (PST) Received: from [2620:15c:17:3:c755:32e5:ce22:b7a8] ([2620:15c:17:3:c755:32e5:ce22:b7a8]) by smtp.gmail.com with ESMTPSA id t4sm10307601pfj.13.2021.11.22.17.50.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Nov 2021 17:50:45 -0800 (PST) Date: Mon, 22 Nov 2021 17:50:44 -0800 (PST) From: David Rientjes To: Mina Almasry cc: Jonathan Corbet , David Hildenbrand , Matthew Wilcox , "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 Subject: Re: [PATCH v7] mm: Add PM_THP_MAPPED to /proc/pid/pagemap In-Reply-To: <20211123000102.4052105-1-almasrymina@google.com> Message-ID: References: <20211123000102.4052105-1-almasrymina@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A47AE90000BB X-Stat-Signature: 67e3xy91h4chd6oddhwo944fkkfs5yfw Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=S6zMZEH+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of rientjes@google.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=rientjes@google.com X-HE-Tag: 1637632247-303646 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, 22 Nov 2021, 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: David Rientjes