Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3250181rdb; Wed, 13 Sep 2023 06:48:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG81fVdYx1Kt798Y/NYPGMCSVyb6pF198enXuTcpFctWyNrGPHsBU/q1HN8ibcFJd/eRHee X-Received: by 2002:a17:90a:6c63:b0:268:dd0:3497 with SMTP id x90-20020a17090a6c6300b002680dd03497mr2302676pjj.7.1694612938303; Wed, 13 Sep 2023 06:48:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694612938; cv=none; d=google.com; s=arc-20160816; b=R6h35N6Ad2xa62H9Ot77wF7+IjAzJtcVuSCG/iPLC+rJbL7+m0ZvXsVHOp18gIcAqI dvF8xxlGeaRau1h9hpCit5HkZ6Rhd2TzdH7qDENCkWV8MOJLV/i3zJHTmv/UsJtq+FGb U2czCdbMOfweDWbmbmjkRr1GWmgoNq+Z0ey4IbQk3n/2eMVt1ASBx+iez5QzBCteljwf X98+Hy9O/YT6+7lNfEk1/hxtglk3cRO+JOEZpWYm9LJgM+zGF1T4ZDD1TLSPguto0tPO dgGKbd9+CzXqzj+1vcktv0QJKiGw7km1SX8ymTL2fLkYZcFv5LFd8YvTJAvRZ7KTdHJx jFow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=szu4YjijCmQAPr2TZ3fba/jfaS/4RHUOM3EpMid6LKA=; fh=cqz9ZlKeZBupKmRaYEl9nrFwnawzD0k76zqkhQ8nBQk=; b=GkjZsrX22pfkSv4iPDhBDjwFY1GAadnM1CqcnLG7+B7AOn9XCoY4T3Ip6lUVrN2YR8 Y8TdiYenRWYZfIDHgiOSGhNxKoKtth4VsClbhp2tIu7Ni8XhHErNqQSAiYRSpbL/68YL 3IPRLYeg0jmCSb3z5BDyKl719ZuGPzhwttJTN5kaFeLDKLLaZEWcU6OsbilvUIduoAbJ PMB+9edxA4m2WIaxskxgljgAmFzHClNiAxFI8fDb+hW9ozbvG8ft58aIvqrKKEK0udpw VEF2Jmh/PwZP/79jZAV06ZSGlhs2ssDmCc7waccurIaPMVbHhaSoGXDVzYWaf+9lno1V 2fYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=C2Edk7pa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id kk1-20020a17090b4a0100b0027450695a78si749411pjb.172.2023.09.13.06.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 06:48:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=C2Edk7pa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3C9E784A9007; Mon, 11 Sep 2023 21:43:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240796AbjILCt0 (ORCPT + 99 others); Mon, 11 Sep 2023 22:49:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240748AbjILCtS (ORCPT ); Mon, 11 Sep 2023 22:49:18 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18F6593F8; Mon, 11 Sep 2023 19:17:38 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6bd0a0a6766so3776123a34.2; Mon, 11 Sep 2023 19:17:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694485057; x=1695089857; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=szu4YjijCmQAPr2TZ3fba/jfaS/4RHUOM3EpMid6LKA=; b=C2Edk7pajxHFZ4M2Tpfgpkig8Vx0CSM1bRofaH+AgIogqiOexg8bhzJqp7S4nDEEQC 3Ci7+l6SQfRKGAS5FzZCkoxs/7iVNG5iXbA6mkrFZQ6Bmw6cFrmPncVy4SQNEQRn80Ax A+96fglZyiA9ZhHY9a34ODWZafAAUPkSPse/mBIDRvWK+x4Xd/KUlQTS/IEq3Ez8W8rj EKbtLNu0vnHU+bSSgWIAbc32gbPdY3DwYccK8HjcQOpLE2XDAnGH/CW35U9vSmzJwQ9D OhAwtfcSHu8bNCMuNt2VbjvPe6+v1l9FCYJfx2IxGNKqwkBcpRU+/Kq/jyQDPMAPOuKe gboQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694485057; x=1695089857; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=szu4YjijCmQAPr2TZ3fba/jfaS/4RHUOM3EpMid6LKA=; b=CPd8CPH2u1yVOqqIpRdpvbbKVmSgUoWoZ6uWjkMsfa/KOd2sNocRCyGuTy1Shw92Bq KTMPYU0fL9Ag7Ms8l1FJx/ltK7yTIGwAZy/kSRSTXJUOR6mBho7cIQPoXKayFH8teIPd 5NdYzhht8/o7WBqSg8YMYj7jlBfhv61Jc9d26EXRhBOhG4bmHFewBDCDBxo5xU8eUKWS y9eCQe/BMzEAqn9iUG/XABcMs3frMukO1hRfHNkj3mLvFv3IaI/MJcBpFDMW0kyK/vux VZaQA6I3aRzD0HJmdZAKMDEXD60wmyg5jv1zJWhIpJU6ustZGE+9BaNZwOAEucPzzRqR Ymjw== X-Gm-Message-State: AOJu0Yw1h5DM/Ul0N1VBROAhrczO2Tc+femvoVRnJ2a5E6XYzd6SkHdX wV4h4glbCUmEXOKsIDM0Ufg= X-Received: by 2002:a05:6359:ba4:b0:140:ecf2:4c7e with SMTP id gf36-20020a0563590ba400b00140ecf24c7emr9231225rwb.1.1694485057218; Mon, 11 Sep 2023 19:17:37 -0700 (PDT) Received: from VERNHAO-MC1.tencent.com ([103.7.29.31]) by smtp.gmail.com with ESMTPSA id x47-20020a056a000bef00b0068a538cc7adsm6217108pfu.52.2023.09.11.19.17.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 11 Sep 2023 19:17:36 -0700 (PDT) From: Vern Hao X-Google-Original-From: Vern Hao To: hannes@cmpxchg.org Cc: mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, haoxing990@gmail.com, Xin Hao Subject: [PATCH v2] mm: memcg: add THP swap out info for anonymous reclaim Date: Tue, 12 Sep 2023 10:17:25 +0800 Message-ID: <20230912021727.61601-1-vernhao@tencent.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 11 Sep 2023 21:43:46 -0700 (PDT) From: Xin Hao At present, we support per-memcg reclaim strategy, however we do not know the number of transparent huge pages being reclaimed, as we know the transparent huge pages need to be splited before reclaim them, and they will bring some performance bottleneck effect. for example, when two memcg (A & B) are doing reclaim for anonymous pages at same time, and 'A' memcg is reclaiming a large number of transparent huge pages, we can better analyze that the performance bottleneck will be caused by 'A' memcg. therefore, in order to better analyze such problems, there add THP swap out info for per-memcg. Signed-off-by: Xin Hao --- v1 -> v2 - Do some fix as Johannes Weiner suggestion. v1: https://lore.kernel.org/linux-mm/20230911160824.GB103342@cmpxchg.org/T/ mm/memcontrol.c | 2 ++ mm/page_io.c | 4 +++- mm/vmscan.c | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index ecc07b47e813..32d50db9ea0d 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -752,6 +752,8 @@ static const unsigned int memcg_vm_event_stat[] = { #ifdef CONFIG_TRANSPARENT_HUGEPAGE THP_FAULT_ALLOC, THP_COLLAPSE_ALLOC, + THP_SWPOUT, + THP_SWPOUT_FALLBACK, #endif }; diff --git a/mm/page_io.c b/mm/page_io.c index fe4c21af23f2..73b2f2846bec 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -208,8 +208,10 @@ int swap_writepage(struct page *page, struct writeback_control *wbc) static inline void count_swpout_vm_event(struct folio *folio) { #ifdef CONFIG_TRANSPARENT_HUGEPAGE - if (unlikely(folio_test_pmd_mappable(folio))) + if (unlikely(folio_test_pmd_mappable(folio))) { + count_memcg_folio_events(folio, THP_SWPOUT, 1); count_vm_event(THP_SWPOUT); + } #endif count_vm_events(PSWPOUT, folio_nr_pages(folio)); } diff --git a/mm/vmscan.c b/mm/vmscan.c index ea57a43ebd6b..39beb0d30156 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1928,6 +1928,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, folio_list)) goto activate_locked; #ifdef CONFIG_TRANSPARENT_HUGEPAGE + count_memcg_folio_events(folio, THP_SWPOUT_FALLBACK, 1); count_vm_event(THP_SWPOUT_FALLBACK); #endif if (!add_to_swap(folio)) -- 2.42.0