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 X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2681DC55179 for ; Thu, 22 Oct 2020 15:20:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4AE7A223BF for ; Thu, 22 Oct 2020 15:20:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="K/nRNa8p" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4AE7A223BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 63DE66B0070; Thu, 22 Oct 2020 11:20:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C69E6B0074; Thu, 22 Oct 2020 11:20:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48DB46B0075; Thu, 22 Oct 2020 11:20:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0083.hostedemail.com [216.40.44.83]) by kanga.kvack.org (Postfix) with ESMTP id 16B826B0070 for ; Thu, 22 Oct 2020 11:20:26 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 899A2180AD81A for ; Thu, 22 Oct 2020 15:20:25 +0000 (UTC) X-FDA: 77399922810.14.truck90_5c0ceef27252 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 64A0418229818 for ; Thu, 22 Oct 2020 15:20:25 +0000 (UTC) X-HE-Tag: truck90_5c0ceef27252 X-Filterd-Recvd-Size: 6594 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Thu, 22 Oct 2020 15:20:24 +0000 (UTC) Received: by mail-qk1-f176.google.com with SMTP id f21so1793763qko.5 for ; Thu, 22 Oct 2020 08:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zBBH901rQGlVlFoCnkqyIlpkXIRSFljWv35x5+cQPf8=; b=K/nRNa8p7sw9/iAQNZ79hyIJivwYVZRf9LPGMBQJkU3so+Aa7InLCzFOogauJpEnUP THh4W4D8SUTdDnI5IyBtA0yfxnQ0kuRyqfRhiq2J97w7M2MWvUUioMHQwgfJX4QOgXQk SfSOCGVauKWRDy5nuCZHUE4cCfiDJBcAHQC5pu7tKkWKoFq14twvjIZnpRK2qCSBxlfa TwFORMEq4o4rW1W89fq/xydP/6xWg7usvTaAPeykPNGDW1gC5h0ryJ5ZmwEhKHIoXxNJ SjW0v0m2NniwZpyuWU0FABhxibu13QkVx8a8rntRLjU1CbQZG5U5UMQF9lMvpsQ1vLmB EExQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zBBH901rQGlVlFoCnkqyIlpkXIRSFljWv35x5+cQPf8=; b=nILSVPpO7tZNqqYaWmceN0Zex68ux5IZTy3HbmYvp+VcMHEB89NcaUs2VlQbj6MqRT xNkZ30IOwFKSq54ZpHxr0IojOtEjE7pu96r8b3ZdQV3v5emu9xT85AsfDM/SpbQGzieD 6V3QLEyDcTURgwsBhOiL3lU6t0lTiAkcUVl4kv4SWfm5f2qnITXTtEiFVkCS6ttHOVLt uBWDRK9zCur73aySQyJbGkVvkwH4gGZ4MpWBKVIbI2juwQ8R0OgsButlufw7HOLKDflA wPs6l1JK0HlbY5HtlvhRkYZBB2CLbyN7gpDvo6DJYq2ARR0LHfgj7bFBU7zzmc5b2zVL eAbA== X-Gm-Message-State: AOAM532s1p5Vbn/UsmmoU7v5Adp5FR4v4YdY3oNCo2r6AM3aszD/hJGc pMXK+LaH2cj8ktwYxfp6jewJHg== X-Google-Smtp-Source: ABdhPJxlIHTHGOHGzLPZANXxHyN9jvKBN1ZfwQSQac4ihaDF7kJXLbxeD8vSdBsG3o5AQUe4eSgmOQ== X-Received: by 2002:a37:664f:: with SMTP id a76mr3041550qkc.370.1603380023909; Thu, 22 Oct 2020 08:20:23 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:c400]) by smtp.gmail.com with ESMTPSA id 11sm1163614qkc.91.2020.10.22.08.20.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2020 08:20:22 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Michal Hocko , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH] mm: memcontrol: add file_thp, shmem_thp to memory.stat Date: Thu, 22 Oct 2020 11:18:44 -0400 Message-Id: <20201022151844.489337-1-hannes@cmpxchg.org> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: As huge page usage in the page cache and for shmem files proliferates in our production environment, the performance monitoring team has asked for per-cgroup stats on those pages. We already track and export anon_thp per cgroup. We already track file THP and shmem THP per node, so making them per-cgroup is only a matter of switching from node to lruvec counters. All callsites are in places where the pages are charged and locked, so page->memcg is stable. Signed-off-by: Johannes Weiner --- mm/filemap.c | 4 ++-- mm/huge_memory.c | 4 ++-- mm/khugepaged.c | 4 ++-- mm/memcontrol.c | 6 +++++- mm/shmem.c | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index e80aa9d2db68..334ce608735c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -204,9 +204,9 @@ static void unaccount_page_cache_page(struct address_= space *mapping, if (PageSwapBacked(page)) { __mod_lruvec_page_state(page, NR_SHMEM, -nr); if (PageTransHuge(page)) - __dec_node_page_state(page, NR_SHMEM_THPS); + __dec_lruvec_page_state(page, NR_SHMEM_THPS); } else if (PageTransHuge(page)) { - __dec_node_page_state(page, NR_FILE_THPS); + __dec_lruvec_page_state(page, NR_FILE_THPS); filemap_nr_thps_dec(mapping); } =20 diff --git a/mm/huge_memory.c b/mm/huge_memory.c index cba3812a5c3e..5fe044e5dad5 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2707,9 +2707,9 @@ int split_huge_page_to_list(struct page *page, stru= ct list_head *list) spin_unlock(&ds_queue->split_queue_lock); if (mapping) { if (PageSwapBacked(head)) - __dec_node_page_state(head, NR_SHMEM_THPS); + __dec_lruvec_page_state(head, NR_SHMEM_THPS); else - __dec_node_page_state(head, NR_FILE_THPS); + __dec_lruvec_page_state(head, NR_FILE_THPS); } =20 __split_huge_page(page, list, end, flags); diff --git a/mm/khugepaged.c b/mm/khugepaged.c index f1d5f6dde47c..04828e21f434 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1833,9 +1833,9 @@ static void collapse_file(struct mm_struct *mm, } =20 if (is_shmem) - __inc_node_page_state(new_page, NR_SHMEM_THPS); + __inc_lruvec_page_state(new_page, NR_SHMEM_THPS); else { - __inc_node_page_state(new_page, NR_FILE_THPS); + __inc_lruvec_page_state(new_page, NR_FILE_THPS); filemap_nr_thps_inc(mapping); } =20 diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2636f8bad908..98177d5e8e03 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1507,6 +1507,8 @@ static struct memory_stat memory_stats[] =3D { * constant(e.g. powerpc). */ { "anon_thp", 0, NR_ANON_THPS }, + { "file_thp", 0, NR_FILE_THPS }, + { "shmem_thp", 0, NR_SHMEM_THPS }, #endif { "inactive_anon", PAGE_SIZE, NR_INACTIVE_ANON }, { "active_anon", PAGE_SIZE, NR_ACTIVE_ANON }, @@ -1537,7 +1539,9 @@ static int __init memory_stats_init(void) =20 for (i =3D 0; i < ARRAY_SIZE(memory_stats); i++) { #ifdef CONFIG_TRANSPARENT_HUGEPAGE - if (memory_stats[i].idx =3D=3D NR_ANON_THPS) + if (memory_stats[i].idx =3D=3D NR_ANON_THPS || + memory_stats[i].idx =3D=3D NR_FILE_THPS || + memory_stats[i].idx =3D=3D NR_SHMEM_THPS) memory_stats[i].ratio =3D HPAGE_PMD_SIZE; #endif VM_BUG_ON(!memory_stats[i].ratio); diff --git a/mm/shmem.c b/mm/shmem.c index 537c137698f8..5009d783d954 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -713,7 +713,7 @@ static int shmem_add_to_page_cache(struct page *page, } if (PageTransHuge(page)) { count_vm_event(THP_FILE_ALLOC); - __inc_node_page_state(page, NR_SHMEM_THPS); + __inc_lruvec_page_state(page, NR_SHMEM_THPS); } mapping->nrpages +=3D nr; __mod_lruvec_page_state(page, NR_FILE_PAGES, nr); --=20 2.29.0