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 4541FE7716E for ; Wed, 4 Dec 2024 14:47:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B910E6B0083; Wed, 4 Dec 2024 09:47:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B18FC6B0085; Wed, 4 Dec 2024 09:47:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 992C06B0089; Wed, 4 Dec 2024 09:47:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7A49D6B0083 for ; Wed, 4 Dec 2024 09:47:14 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 24C341410B4 for ; Wed, 4 Dec 2024 14:47:14 +0000 (UTC) X-FDA: 82857553716.19.3C16ABF Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf22.hostedemail.com (Postfix) with ESMTP id 5C876C0013 for ; Wed, 4 Dec 2024 14:46:55 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=cWEFNWCP; spf=pass (imf22.hostedemail.com: domain of haowenchao22@gmail.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=haowenchao22@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733323621; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=ZXL3lr2/xb1av06HROoqFP+hEFOheIHsOAZhVg1QF4w=; b=fQnrN2glaa4jYFqFRli1K4IrLvkHlXc/l7V6E3Fa5x8/YTUqVJwHKQ72syatouNUtAijpw cZDs72C5alb1lX7O0jnkteZR3IPBeXGmEr1sSBRFA/6YB38TSONDyNxGvz5UMEGu4NCnb0 FAPXiFQFbO7xTYrNHq8OYdO0cTEuBqs= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=cWEFNWCP; spf=pass (imf22.hostedemail.com: domain of haowenchao22@gmail.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=haowenchao22@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733323621; a=rsa-sha256; cv=none; b=mwYMSzuJqocggCUY2M9WDyt1heZgeeVtSQEGoV22oai4mjVR4l6oCyg3VrN59upMQf2a9y rZsCOiruq/DI6Mt7ybbrHvCI0FJxPGzskiNh6I89Yk0LRhIKU7GCRqoQKyaQp9T5yD6KcS ifQ4I6QCzAU6hozCtDe486ZtZlTwU68= Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-215da73e256so5939225ad.0 for ; Wed, 04 Dec 2024 06:47:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733323630; x=1733928430; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=ZXL3lr2/xb1av06HROoqFP+hEFOheIHsOAZhVg1QF4w=; b=cWEFNWCPJp3T1BZp0MNuS6CyQn4pcB6D6z0QXjz9qnRwvfPasVSH/YPkKlNoZGPJPm Sv0XWQZalY4JMVZqM1J325rDc3EkUlCudfJChg0NqdXYxOHTf1Bqb+jDxG1A73dnHV11 rf7gYS7DPFZSXtgJAda6iip2tJeQXQ0PoruT5D0D4FflUQenRTSg2uSxI5lTdnUaZPdQ 8ilu+LX0+hWxMGEc+2y2X6L0ClRf/imWrN/lGqtiuZUporDWe96s3e2UTldfGt8G+5q7 KXp3fmxWp2EG5nahdYhtgZqc7/GigBt/Zq11mEfrFusp5wsud9nfjcfgwo3zPQas3BBI MRiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733323630; x=1733928430; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZXL3lr2/xb1av06HROoqFP+hEFOheIHsOAZhVg1QF4w=; b=t0cC+BqXYw4BIyQqpP4i2ybz5TzmQ8repi6a/SvuRvaOF4Hfh+hWQRjTmPYLkm53dQ cLyv4FtOv+yo0P9UlTiDRez9ztLWgiKRJJBNmfG/qtATLpPGJcd2wsbxBPv1iMuCYuLh mz9bHkJtlWTrqkRbfbow5U6W0Rcn3GuiAnJaRITfqDNfAF9haXTWrZoEIZATnFaBvtif 6urIuLNI5coXXlwvs3emGRjb+a8SVJeMj8qbP0MuXIdilklkHkwAE9vwP22wZu7xp+pc gmISJxGF89GaKHXP7q8uc68k5ljfktG3UYXPtfvDT+9L5bpLcfNtO1oe3OugodKi/doq kpkw== X-Forwarded-Encrypted: i=1; AJvYcCWyZaggYjd+itQthkOAV/G84wyAsCqGnPrdaZlIcMlAbJ4UYWa5xLwE9pveocFN0syPLV+PYx7yMg==@kvack.org X-Gm-Message-State: AOJu0YyxCSR99SWkyLL2sB6uxrtnjwbSmaM/QELd6tr3vBei9spxnrgd IJWM0dZ/hzfmT4dAluzhor5S4NmX1MwdJuM7cuEmVxjB3HOImD5DEkqXs1Hg X-Gm-Gg: ASbGncvlFwc6G6Q90zZ8xy/unE3KL5MPFiBjyn7ANpknIO4EUkTYqu5OJC8a8p6mOBO yHri7sYIFQmuWA7w103EbFAlSaM4fgwicFGtLKd3XXTldrq1jU6QrlLWeDbVKnp4oMTGtPdXQ+O xBI8QNCqOqNHL1N+ybK9QyqjRIqLStDytDG4Udc/lKDWLMm/nhxP038POdv+d+zDEIUzARu5bCl 0YSLgmy5mUOZD3jqStaabfT0RctoomqT5PEh8LB13qP3ClQi1RRk6sDZbg= X-Google-Smtp-Source: AGHT+IEf8AURcCKrmVMH+suyut8NUqPd6mYZzY8B7a/jkx/LPgrSN1NEodCLukf6DgsTLlCThZ6nsg== X-Received: by 2002:a17:902:f712:b0:215:b9a7:526c with SMTP id d9443c01a7336-215d0050c00mr68142695ad.25.1733323629616; Wed, 04 Dec 2024 06:47:09 -0800 (PST) Received: from [10.239.15.156] ([43.224.245.233]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2152191dcc9sm112802355ad.112.2024.12.04.06.47.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Dec 2024 06:47:09 -0800 (PST) Message-ID: <605e5e98-863f-41fe-9a84-071c1843d684@gmail.com> Date: Wed, 4 Dec 2024 22:47:04 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] smaps: count large pages smaller than PMD size to anonymous_thp To: David Hildenbrand , Andrew Morton , Matthew Wilcox , Oscar Salvador , Muhammad Usama Anjum , Andrii Nakryiko , Ryan Roberts , Peter Xu , Barry Song <21cnbao@gmail.com>, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org References: <20241203134949.2588947-1-haowenchao22@gmail.com> <926c6f86-82c6-41bb-a24d-5418163d5c5e@redhat.com> Content-Language: en-US From: Wenchao Hao In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam05 X-Stat-Signature: mbq14jyemr5ek7ytfpggbsh6b15yurih X-Rspamd-Queue-Id: 5C876C0013 X-Rspam-User: X-HE-Tag: 1733323615-830533 X-H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Wn4Pnr+bogTdRKG0dO1UAyiIE6vRk15jP5SkJJSyoSwjtItPzf+WwxdxSrseqNN5QBHuD7rUnG80xhbWcifu7eRNBYtSudjsg6yKI8BKwMNuBWh1L92AUVve85VwGSIBFpN3eq290EEJkUn9KIcc7BBcTttIKFZq/B5+998fcuqXpGzeEdeLhR7jThzTnNlt4g9fgPGUQ5jyyawK8J95Sowre6CJVprTNIPw7wu8amGBWVmWEmnwHBO+96YRPoqAuj+8H4P8V/4Rn19GLuV8msP3GCcptQ6DdT1VPO+BdAs+waSH0bQyOS5P5YJW98Kl5y/gp2d7cap/vtJ+VdwjAUhH7cGMSeWAs8xDje3zOUIBfqFdlYLNlRCtqWVclvB5a2vIq7+Q9unKxXE6q1miQVftCrnaHnyo1dmOopK4Y+bXtdfEt1jW/o274C6WokWlXi/jMADm1d 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: List-Subscribe: List-Unsubscribe: On 2024/12/4 22:37, David Hildenbrand wrote: > On 04.12.24 15:30, Wenchao Hao wrote: >> On 2024/12/3 22:17, David Hildenbrand wrote: >>> On 03.12.24 14:49, Wenchao Hao wrote: >>>> Currently, /proc/xxx/smaps reports the size of anonymous huge pages for >>>> 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/vim @@ -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 += size; >>>> + >>>> +        /* >>>> +         * Count large pages smaller than PMD size to anonymous_thp >>>> +         */ >>>> +        if (!compound && PageHead(page) && folio_order(folio)) >>>> +            mss->anonymous_thp += 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: >>> >> >> Could you explain why? >> >> When analyzing the impact of mTHP on performance, we need to understand >> how many pages in the process are actually present as large pages. >> By comparing this value with the actual memory usage of the process, >> we can analyze the large page allocation success rate of the process, >> and further investigate the situation of khugepaged. If the actual >> proportion of large pages is low, the performance of the process may >> be affected, which could be directly reflected in the high number of >> TLB misses and page faults. >> >> However, currently, only PMD-sized large pages are being counted, >> which is insufficient. > > As Ryan said, we have scripts to analyze that. We did not come to a conclusion yet how to handle smaps stats differently -- and whether we want to at all. > Hi David, I replied Ryan about few disadvantages of the scripts. The scripts is not helpful for my scenario. >> >>> 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/meminfo``. >>> To identify what applications are using PMD-sized anonymous transparent huge >>> pages, it is necessary to read ``/proc/PID/smaps`` and count the AnonHugePages >>> fields for each mapping. (Note that AnonHugePages only applies to traditional >>> PMD-sized THP for historical reasons and should have been called >>> AnonHugePmdMapped). >>> >> >> Maybe rename this field, then AnonHugePages contains huge page of mTHP? > > It has the potential of breaking existing user space, which is why we didn't look into that yet. > Got it. > AnonHugePmdMapped would be a lot cleaner, and could be added independently. It would be required as a first step. > While, if the meaning of AnonHugePages remains unchanged, simply adding a new field doesn't seem to have any practical significance. Thanks