From patchwork Fri Jun 7 12:23:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13689818 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 CE810C27C53 for ; Fri, 7 Jun 2024 12:24:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 758F36B009D; Fri, 7 Jun 2024 08:24:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E7776B009F; Fri, 7 Jun 2024 08:24:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50F066B00A0; Fri, 7 Jun 2024 08:24:20 -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 306756B009D for ; Fri, 7 Jun 2024 08:24:20 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A7DB5403C4 for ; Fri, 7 Jun 2024 12:24:19 +0000 (UTC) X-FDA: 82204010238.21.E565A48 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id F05921C0009 for ; Fri, 7 Jun 2024 12:24:17 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hyWG9H0g; spf=pass (imf18.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717763058; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IlZ3OfYfLTtJDLF62yb3XVghB10LN2zpLPX8h3wsziU=; b=U9n+Ma0Z5rtRuVKyBg4Buz4HbaF6z40F5BUW6pz+NVOjuz2HQdGrusKSvVxPceJyyWnsw9 5IosmMb4qwCN7wofg1yaW/3aklohGK3OALRoiW9aWdAPsn08F8AdUqw1gMLEGZS89dywi3 kUaUcsIaBsOaW0QLTYZ/t4ophMVpsro= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hyWG9H0g; spf=pass (imf18.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717763058; a=rsa-sha256; cv=none; b=7krIG+1xErSXvR70PUvMBAr022GAevQLQHnn4dyWfu0hjudDaJC6jsb5M8m6N85oAjQ1NQ 5sA85S+tealloVzXFAA6kJo5nZU0809lf8X55XGX162ZG3A9gJrLbVt/MjUWFY1zpQMeZF h1VMUxUkvEIrnS1LweqsEoUdGovdOuA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717763057; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IlZ3OfYfLTtJDLF62yb3XVghB10LN2zpLPX8h3wsziU=; b=hyWG9H0gxdYi8hYdhy46CwIbZoYiGvu8BryTROQHr+ngKc0MLna7lkoYKpPZJyLu66e+GE z0zGD4Rn65LdF4SotmM5hh3aTO+0Klnkm/LOLYHJRf70i7Kqx8i+nc/cpB0ubd5f11GUkN QVJfTXCgGvSbBers+4zj9fe6JYi3Emk= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-637-Ohcn_-66MiOtK0ykrtlcjQ-1; Fri, 07 Jun 2024 08:24:14 -0400 X-MC-Unique: Ohcn_-66MiOtK0ykrtlcjQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8FE221C05129; Fri, 7 Jun 2024 12:24:13 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A45F492BCD; Fri, 7 Jun 2024 12:24:11 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet Subject: [PATCH v1 6/6] Documentation/admin-guide/mm/pagemap.rst: drop "Using pagemap to do something useful" Date: Fri, 7 Jun 2024 14:23:57 +0200 Message-ID: <20240607122357.115423-7-david@redhat.com> In-Reply-To: <20240607122357.115423-1-david@redhat.com> References: <20240607122357.115423-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Stat-Signature: niyysuajbnpgjr1q7ytkp1ya8x5cfszc X-Rspamd-Queue-Id: F05921C0009 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1717763057-355104 X-HE-Meta: U2FsdGVkX1+0ceLrFfU/PyUPsYBuZPIn3kdGSYivrExMlCFuSiuOEGTwcEizSvLS2G6szIFA5IfsFNl4vfp8/41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spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: That example was added in 2008. In 2015, we restricted access to the PFNs in the pagemap to CAP_SYS_ADMIN, making that approach quite less usable. It's 2024 now, and using that racy and low-lewel mechanism to calculate the USS should not be considered a good example anymore. /proc/$pid/smaps and /proc/$pid/smaps_rollup can do a much better job without any of that low-level handling. Let's just drop that example. Signed-off-by: David Hildenbrand --- Documentation/admin-guide/mm/pagemap.rst | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/Documentation/admin-guide/mm/pagemap.rst b/Documentation/admin-guide/mm/pagemap.rst index f5f065c67615d..f2817a8015962 100644 --- a/Documentation/admin-guide/mm/pagemap.rst +++ b/Documentation/admin-guide/mm/pagemap.rst @@ -173,27 +173,6 @@ LRU related page flags The page-types tool in the tools/mm directory can be used to query the above flags. -Using pagemap to do something useful -==================================== - -The general procedure for using pagemap to find out about a process' memory -usage goes like this: - - 1. Read ``/proc/pid/maps`` to determine which parts of the memory space are - mapped to what. - 2. Select the maps you are interested in -- all of them, or a particular - library, or the stack or the heap, etc. - 3. Open ``/proc/pid/pagemap`` and seek to the pages you would like to examine. - 4. Read a u64 for each page from pagemap. - 5. Open ``/proc/kpagecount`` and/or ``/proc/kpageflags``. For each PFN you - just read, seek to that entry in the file, and read the data you want. - -For example, to find the "unique set size" (USS), which is the amount of -memory that a process is using that is not shared with any other process, -you can go through every map in the process, find the PFNs, look those up -in kpagecount, and tally up the number of pages that are only referenced -once. - Exceptions for Shared Memory ============================