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 27C0EE77173 for ; Sun, 8 Dec 2024 06:07:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 89FA56B0372; Sun, 8 Dec 2024 01:07:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 84F896B0373; Sun, 8 Dec 2024 01:07:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 717586B0374; Sun, 8 Dec 2024 01:07:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5306C6B0372 for ; Sun, 8 Dec 2024 01:07:11 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EE91A16057A for ; Sun, 8 Dec 2024 06:07:10 +0000 (UTC) X-FDA: 82870758852.14.B7A3B17 Received: from mail-vk1-f179.google.com (mail-vk1-f179.google.com [209.85.221.179]) by imf26.hostedemail.com (Postfix) with ESMTP id ACDE7140002 for ; Sun, 8 Dec 2024 06:06:54 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Y+Qq3V8Y; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.221.179 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733638020; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nSPTXbUKfNMinNGM5rUhYOdHvCQ+TR4BofaMXjdRcsM=; b=3UWlntlxc/aZTJB9R3HuXegK41YM+H1FdGHkP7z46ctYB5nSc/h5SHB3/bMAJIN0g3WWgz ooR6m10OpEUo7R4iH9krrFK2DgRTxozXiwv64LLK8TvWhCXs1IMrukcesftcb8N/rvj0Np ioO3xWx1WG7BYjN5/5scgaTj4lRqUYM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733638020; a=rsa-sha256; cv=none; b=tbl7HteTkjz7BqhZWFXnu56pS9PR79u26oerKgMAlFLHEs8+wns1ONAHQrqEBUZnR1mIEz YIpWy7IrXn7r/d6YqNpm05qXQ36UeB/u6qRnf8kwOKX3fjnLyUVe2oaKsZIcvSj935k+0M edsAFFu/Ih3vM5pREc96XptFH7vaDpM= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Y+Qq3V8Y; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.221.179 as permitted sender) smtp.mailfrom=21cnbao@gmail.com Received: by mail-vk1-f179.google.com with SMTP id 71dfb90a1353d-5174f9c0e63so36591e0c.1 for ; Sat, 07 Dec 2024 22:07:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733638028; x=1734242828; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nSPTXbUKfNMinNGM5rUhYOdHvCQ+TR4BofaMXjdRcsM=; b=Y+Qq3V8Y0ZOHXLyLQKTjKZg6oRR9KkAvxgvukj1gxyT3WwY2vDywbYAQgO9AyIq64g QXpX7QdL6dwFvXLwJysBMVKbQxGqpLRiMFIL4a2gj5oTIzE2jEcuEueKrOwlgiTG3C8R /+8XoT/A38JpZzhqqDGUj4dF/D1PbXwHxuJih8dbiY5T5fpZCHF/GkaRIm42HjJ8MT6X oYSfdsFbhe/DAx2Mezq+SqqQaky6VKFjGly5WVvijIR46FGdQT1lLTLIL7+yehNw5JAI F08qkevucFVXBLKW/RImqyEK7RQA/2+W/5xC/8FlZaMaz3fFBcbPY1JuU92Vg61D35iu kwWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733638028; x=1734242828; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nSPTXbUKfNMinNGM5rUhYOdHvCQ+TR4BofaMXjdRcsM=; b=Wy2LXSVR5uJabw1XBi+M01SDFA4IZ+0BuzWmnK65OhS1ip/ZaK971f+OG23A58tVxQ 0Qtn9R338wz1arOVOriaRmLSVnASpiYi1NI9QK9i4MlfEIUP36q8d6a5hF0sxZyOcwXU lH7UvQV1mfh0VBbFcp/UoXPxz2pODfkhJE/Q2JnzLqDXE9tpG5g+mNvmwLGg9XIkzdJr /1feUvcyxIOGiBP7G10iWlK+VRCntP0gHDJYlGNgylX/wdsbDqtWFCuFaJByVcZ4t85X joKIQFOoiw5p3GWaZ+YvoCfj9owm0FePc7TTfl6mCIvMygEdEhxJMKj0QWW1PALqadTr brGw== X-Forwarded-Encrypted: i=1; AJvYcCWoCQr4d9YL3FxPzA1a0Ivdu63OMGdLgy3SyEKD/zU7ISamsbyZMQOuYvj77B59nNn0SpdwnaTn0w==@kvack.org X-Gm-Message-State: AOJu0YzG0KHnwJVQmBeQtE6M+ei5JYQ86fdLFn8yMw9rTDrMbgInuxnJ YVGU34JNg0dKL3NNn2yh0vADwmQjxgHZV5yzK3sWLX9SqKmeJGnYqpLCykYfftdU7kxl8YX+Cxe mD4yOunTp5xy5mgn6SHrc61NTSyI= X-Gm-Gg: ASbGncuyUsSuLSubQQYPESAnpjrdiFBrtzpVFZGxJNoOcAiw45KqOfdq+ztlMZ3xaW3 8OSZlz1VpdzJ7rdMhUQxe17Gh2+iT6OlxO2vO7jwCrQmkQBcb0268nJZfVhhNRZULig== X-Google-Smtp-Source: AGHT+IFaPx1ArJ8bw8oS0nlBiWKl9Rx/s/UMqsFt9vtSHnk58MZH85TiZg9/plcZYTWgcXJcRIVj0qn+rK9ooAje8HM= X-Received: by 2002:a05:6122:829d:b0:516:1582:f72e with SMTP id 71dfb90a1353d-5161582f8e1mr3615505e0c.2.1733638028187; Sat, 07 Dec 2024 22:07:08 -0800 (PST) MIME-Version: 1.0 References: <20241203134949.2588947-1-haowenchao22@gmail.com> <926c6f86-82c6-41bb-a24d-5418163d5c5e@redhat.com> In-Reply-To: From: Barry Song <21cnbao@gmail.com> Date: Sun, 8 Dec 2024 14:06:57 +0800 Message-ID: Subject: Re: [PATCH] smaps: count large pages smaller than PMD size to anonymous_thp To: Lance Yang Cc: David Hildenbrand , Wenchao Hao , Andrew Morton , Matthew Wilcox , Oscar Salvador , Muhammad Usama Anjum , Andrii Nakryiko , Ryan Roberts , Peter Xu , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: q96ji6nmpe3r5ubou64gez8qejchrukb X-Rspamd-Queue-Id: ACDE7140002 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1733638014-609719 X-HE-Meta: U2FsdGVkX1+JNFPr9CAydicAV17IyPIhg8t9ul6tAeZmXHbkoB0pqRJC2oUJbsnHsbfbTaOkf2onpcJtGCdzt1gWr//inGtIpZpcvKGz14LKkM0VxuqT3B8mObKCXAac6ZdK3o8EZF1WVwgp6fEsnjyZDj7LKJTTYYFyi6ckSP6t+x7kLfRIlYWxQW8SSTuv2dFn+dn6W58HqWwF7oTVxXPysks3D0SH5ZHW9fpXxqW3PlTjKwb8TkgFn1O3XEaiT+tpq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tg4rLpMLlp5KwZRWEoHR463ACINpSxQ3pS1remwrd7wb//Tu0b95 X-Bogosity: Ham, tests=bogofilter, spamicity=0.025440, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Dec 6, 2024 at 7:16=E2=80=AFPM Lance Yang wro= te: > > On Tue, Dec 3, 2024 at 10:17=E2=80=AFPM David Hildenbrand wrote: > > > > On 03.12.24 14:49, Wenchao Hao wrote: > > > Currently, /proc/xxx/smaps reports the size of anonymous huge pages f= or > > > each VMA, but it does not include large pages smaller than PMD size. > > > > > > This patch adds the statistics of anonymous huge pages allocated by > > > mTHP which is smaller than PMD size to AnonHugePages field in smaps. > > > > > > Signed-off-by: Wenchao Hao > > > --- > > > fs/proc/task_mmu.c | 6 ++++++ > > > 1 file changed, 6 insertions(+) > > > > > > diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c > > > index 38a5a3e9cba2..b655011627d8 100644 > > > --- a/fs/proc/task_mmu.c > > > +++ b/fs/proc/task_mmu.c > > > @@ -717,6 +717,12 @@ static void smaps_account(struct mem_size_stats = *mss, struct page *page, > > > if (!folio_test_swapbacked(folio) && !dirty && > > > !folio_test_dirty(folio)) > > > mss->lazyfree +=3D size; > > > + > > > + /* > > > + * Count large pages smaller than PMD size to anonymous= _thp > > > + */ > > > + if (!compound && PageHead(page) && folio_order(folio)) > > > + mss->anonymous_thp +=3D folio_size(folio); > > > } > > > > > > if (folio_test_ksm(folio)) > > > > > > I think we decided to leave this (and /proc/meminfo) be one of the last > > interfaces where this is only concerned with PMD-sized ones: > > > > Documentation/admin-guide/mm/transhuge.rst: > > > > The number of PMD-sized anonymous transparent huge pages currently used= by the > > system is available by reading the AnonHugePages field in ``/proc/memin= fo``. > > To identify what applications are using PMD-sized anonymous transparent= huge > > pages, it is necessary to read ``/proc/PID/smaps`` and count the AnonHu= gePages > > fields for each mapping. (Note that AnonHugePages only applies to tradi= tional > > PMD-sized THP for historical reasons and should have been called > > AnonHugePmdMapped). > > Yeah, I think we need to keep AnonHugePages unchanged within these interf= aces > due to historical reasons ;) > > Perhaps, there might be another way to count all THP allocated for each p= rocess. My point is that counting the THP allocations per process doesn't seem as important when compared to the overall system's status. We already have interfaces to track the following: * The number of mTHPs allocated or fallback events; * The total number of anonymous mTHP folios in the system. * The total number of partially unmapped mTHP folios in the system. To me, knowing the details for each process doesn=E2=80=99t seem particular= ly critical for profiling. To be honest, I don't see a need for this at all, except perhap= s for debugging to verify if mTHP is present. If feasible, we could explore converting Ryan's Python script into a native C program. I believe this would be more than sufficient for embedded system= s and Android. > > Thanks, > Lance > > > > > > > > > > -- > > Cheers, > > > > David / dhildenb Thanks Barry