Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp999719rdf; Wed, 22 Nov 2023 02:58:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbA/W4FWdboT/iMFY04a+HPySU8ADwK7LVXkERR9dmS45BIVSB3mnE7xMyfeJU4ZqCn0C5 X-Received: by 2002:a05:6a20:54a1:b0:18a:f711:7bc1 with SMTP id i33-20020a056a2054a100b0018af7117bc1mr1875836pzk.60.1700650736677; Wed, 22 Nov 2023 02:58:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700650736; cv=none; d=google.com; s=arc-20160816; b=Ty1mRpJaEUl4zf4KjhhBXgOzm+xxeStrLx1UDXIwOuhqF3I3S0c+ndS6pn217giphN yvSbrVY7ROBcda4ED1HMyIMH3zTNcjPQjRKH60tCJEPLaJ2bQ2ztHAMTPnBijgpV/ZOt amfkWf0wrFzASjDV9B8Ri54IzBPOe7RMKbsX2s3DKLzgxxwwMK7amJbCwc0Xv/ul86v+ 1N4pxJn9I7+Jp4LwDXFTrC7leXAZMaQAfE7Ptem2wgTEDp0oNkJ4l6hNP/4mUeux1oiQ PL77tn3W+1qL3hRmevVfN8b+qT2RHmyOqgOjGScjjR56i64+i1wBFdxKRy/fYiZVZ3vI Kjbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=zFx+5dXlR2EQJnObSWY+xM9oMXFlaTN9St5MLae6TwM=; fh=T67tHxwLgIN4zQPbh5hihQ69FP8Tr+riKiecwZK97GE=; b=O/tZiw0MmMo9raFaHnwdFGAFAyuN8CsENuAVrIqsX28qHEPnp57A3tXn/3JIkvbRgj trVWLOWACnvX1UqwVNDX/j8Ps5K3fPrpo3L8oo1G7tXBBqADOZM9E/SOZz3Q1DQwK/7C V7/MAAKURlH3G9+PEOY6OR+n+FvBSHO4CZhVuXnC+GaT7JAeC9lFU5m5PHobGW5t77JW 7rYmZ99fUl6lGLbExJ21+SI6KKoo1Mn2+jB7Y5Iphf4WJTl5Irk+dUf9YrajcwQDkl7X eYbRTq2eDWx0j75xKvYzJ00o4llxPC2ev61nXRk5+7iCMRUbQmvR167IdWJ92zEQ0BCM qpxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=G84a0EFV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id j10-20020a17090276ca00b001bbca0a8393si12108862plt.56.2023.11.22.02.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 02:58:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=G84a0EFV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 1747B80481AB; Wed, 22 Nov 2023 02:58:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230517AbjKVK6p (ORCPT + 99 others); Wed, 22 Nov 2023 05:58:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbjKVK6n (ORCPT ); Wed, 22 Nov 2023 05:58:43 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2170B92; Wed, 22 Nov 2023 02:58:38 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id B645C120069; Wed, 22 Nov 2023 13:58:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru B645C120069 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1700650716; bh=zFx+5dXlR2EQJnObSWY+xM9oMXFlaTN9St5MLae6TwM=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:From; b=G84a0EFVLTgDdOvzlXW6Mebu1TojgZDXRItdf9fVmFZptmL/l4AUVXhCOIcCS6MlY F3AlevIX7gjzhw4tHFR/HPMzOyEWKhNnpdWCqD4bFODqBbEoGdNOZKnrzzdKpdoAnU L7G/cZEMqghNyITCn6zr97jKaLuiz81Xlf3bWFkBQTyZrN0eOju9xmwfXbrASCzCF/ id2MaU/PYACpREAf8Lvad1T8JfY3/Z/SDHdOBupzg2wLKLbfXzbiHVf/wFrHoHhE/I l7irZapLjznCc0Uxpi6nfeX3qRnSjOXyJsRfpbkOvhFOkXwVI4DnJgDbabHMWfPK9o E7iNEXuUIrLpA== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Wed, 22 Nov 2023 13:58:36 +0300 (MSK) Received: from localhost (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 22 Nov 2023 13:58:36 +0300 Date: Wed, 22 Nov 2023 13:58:36 +0300 From: Dmitry Rokosov To: Michal Hocko CC: , , , , , , , , , , , , Subject: Re: [PATCH v2 2/2] mm: memcg: introduce new event to trace shrink_memcg Message-ID: <20231122105836.xhlgbwmwjdwd3g5v@CAB-WSD-L081021> References: <20231122100156.6568-1-ddrokosov@salutedevices.com> <20231122100156.6568-3-ddrokosov@salutedevices.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20220415 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 181528 [Nov 22 2023] X-KSMG-AntiSpam-Version: 6.0.0.2 X-KSMG-AntiSpam-Envelope-From: ddrokosov@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 3 0.3.3 e5c6a18a9a9bff0226d530c5b790210c0bd117c8, {Track_E25351}, {Tracking_from_domain_doesnt_match_to}, d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;p-i-exch-sc-m01.sberdevices.ru:7.1.1,5.0.1;salutedevices.com:7.1.1;100.64.160.123:7.1.2;127.0.0.199:7.1.2, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/11/22 09:18:00 #22500551 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Wed, 22 Nov 2023 02:58:54 -0800 (PST) Hello Michal, Thank you for the quick review! On Wed, Nov 22, 2023 at 11:23:24AM +0100, Michal Hocko wrote: > On Wed 22-11-23 13:01:56, Dmitry Rokosov wrote: > > The shrink_memcg flow plays a crucial role in memcg reclamation. > > Currently, it is not possible to trace this point from non-direct > > reclaim paths. > > Is this really true? AFAICS we have > mm_vmscan_lru_isolate > mm_vmscan_lru_shrink_active > mm_vmscan_lru_shrink_inactive > > which are in the vry core of the memory reclaim. Sure post processing > those is some work. Sure, you are absolutely right. In the usual scenario, the memcg shrinker utilizes two sub-shrinkers: slab and LRU. We can enable the tracepoints you mentioned and analyze them. However, there is one potential issue. Enabling these tracepoints will trigger the reclaim events show for all pages. Although we can filter them per pid, we cannot filter them per cgroup. Nevertheless, there are times when it would be extremely beneficial to comprehend the effectiveness of the reclaim process within the relevant cgroup. For this reason, I am adding the cgroup name to the memcg tracepoints and implementing a cumulative tracepoint for memcg shrink (LRU + slab)." > > [...] > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 45780952f4b5..6d89b39d9a91 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -6461,6 +6461,12 @@ static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc) > > */ > > cond_resched(); > > > > +#ifdef CONFIG_MEMCG > > + trace_mm_vmscan_memcg_shrink_begin(sc->order, > > + sc->gfp_mask, > > + memcg); > > +#endif > > this is a common code path for node and direct reclaim which means that > we will have multiple begin/end tracepoints covering similar operations. > To me that sounds excessive. If you are missing a cumulative kswapd > alternative to > mm_vmscan_direct_reclaim_begin > mm_vmscan_direct_reclaim_end > mm_vmscan_memcg_reclaim_begin > mm_vmscan_memcg_reclaim_end > mm_vmscan_memcg_softlimit_reclaim_begin > mm_vmscan_memcg_softlimit_reclaim_end > mm_vmscan_node_reclaim_begin > mm_vmscan_node_reclaim_end > > then place it into kswapd path. But it would be really great to > elaborate some more why this is really needed. Cannot you simply > aggregate stats for kswapd from existing tracepoints? > > -- > Michal Hocko > SUSE Labs -- Thank you, Dmitry