Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2106298rdb; Tue, 20 Feb 2024 18:20:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX2BqWBkhoT7XbuYTdyvcwTskSwUzhNpYQi2i8E8xFKgzC6cNvbYftvN+4ShTLp3txFp/Y83AVOiMpiWUSEMESCjKr5BKrbDK06sk2WXg== X-Google-Smtp-Source: AGHT+IF0IbMhcislPUfVEOa0UCxHGvYGis/4+GXFaGP59UncGYYyI9H98fUsijvMoSSFEeW1DNHF X-Received: by 2002:a17:906:7c4a:b0:a3e:72ca:700d with SMTP id g10-20020a1709067c4a00b00a3e72ca700dmr7410450ejp.45.1708482024768; Tue, 20 Feb 2024 18:20:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708482024; cv=pass; d=google.com; s=arc-20160816; b=mSW+F5uxp68RRALPzOIs3iyunP6aIt7dHzApPSr77FuXPOJLSvA7M+9wri/rQFgOc9 XkenA0WDDwP0804pdNIkCFsOjklSEvhlzLizFwqgTNSbJsS6G4Aohj1B88QMON9fr5j5 hF4UY7ccqM4GQW0t+qPip1d7cwmhBkZU2lnmNJT6lP1l0Z0+zXBNAY2jTS5bBKI8UCTe DMIZ3BGCgQfmxDWKzr4/wxoB0YD9qlvML81RZWy4yWpiad0C4oO1/QWbF5mtLPVyQsnR Gpco0/ADbxIQ+jR5C52r28PhovzV/qvjO+sWlDfMxZdo50+0qsuPLEPTOsd4vVGs2wKM Hh6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=YylLy8FTDwB7ORVbYiliH4Na3C7Qh6Bsy9IjDlImSmk=; fh=Nu3HRt9TmzVO0eDPriWv+8BpnNASrOsr6SRlP1S/kSE=; b=CqKW+6EZNPx+RyMGSDQTWfEN++LDGclvsWX7ZCPyTVMEAED+15ozKn8pXL7bQcZTHS bCSPw0w+pHOHFlZAbREpoL0GFyORh2zYRSivQq/eufuwvUPBxR0SoLnmGzbYuD3RDW6e nQecDSuG1otc+413K1Q9VRKcfrjxz4BjZWm+YNuK4Lzxur8HPxYMcj7ew89TCE3Bf6xl j9JI1zBffRkWVHv6ik5u5urjjmyLq74FZPJ+/E8YAAc+Nk3EN1vNofDxSEIAkuIKPyn+ lEwMFRkw7gWQb7k6kEpRXen7kX264Iksq8Sn2GT43Soy/+rjd8J463wI196EqpQq1A7N XkhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-73946-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73946-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kj17-20020a170907765100b00a3e4ceb38b9si3178533ejc.985.2024.02.20.18.20.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 18:20:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73946-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-73946-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73946-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6A3961F2598C for ; Wed, 21 Feb 2024 02:20:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5140F9FF; Wed, 21 Feb 2024 02:20:18 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A74279C6; Wed, 21 Feb 2024 02:20:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708482018; cv=none; b=ZvRMS/2Ld1xvs9jvwphQethgSHKRbs7Ev0kodsU33RfNZLNhSMy3ZIQa2B3Q3tvXlTqHB2Dp9EL6tVUGSzKDVwQk/zjY/8pUDkiM1YyyEWPJqIt9vmSDIBnO1yZCPGj4zFHEV5fM6cY5dZsyisLRsjfrkFLCpRcjqmuSgJdkVOQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708482018; c=relaxed/simple; bh=EyOscyrB9L+KcSmf262hDy8n/KnQJ8E+Ww/wGwrHIxQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=d2nC9EIOvmbbBXAVJpgJbAUWltHf4alkpLkzzwMxTqdqRFqiUppm6HVCiUKky1Bq35e24ZUri2nNnpTFhxXg+dJG15SYXnh5CFGTZ+yJyI7cNsYUC6tW8UgvXAwo7SqiBqaUWLWWD1yBoc4Vep+gu+ENYsYnPYhE7viUk2CxXBw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3A91C433F1; Wed, 21 Feb 2024 02:20:16 +0000 (UTC) Date: Tue, 20 Feb 2024 21:22:02 -0500 From: Steven Rostedt To: Bixuan Cui Cc: akpm@linux-foundation.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, opensource.kernel@vivo.com Subject: Re: [PATCH -next v6 0/2] Make memory reclamation measurable Message-ID: <20240220212202.59ddc123@gandalf.local.home> In-Reply-To: References: <20240105013607.2868-1-cuibixuan@vivo.com> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, 21 Feb 2024 09:44:32 +0800 Bixuan Cui wrote: > ping~ >=20 It's up to the memory management folks to decide on this. -- Steve > =E5=9C=A8 2024/1/5 9:36, Bixuan Cui =E5=86=99=E9=81=93: > > When the system memory is low, kswapd reclaims the memory. The key steps > > of memory reclamation include > > 1.shrink_lruvec > > * shrink_active_list, moves folios from the active LRU to the inacti= ve LRU > > * shrink_inactive_list, shrink lru from inactive LRU list > > 2.shrink_slab > > * shrinker->count_objects(), calculates the freeable memory > > * shrinker->scan_objects(), reclaims the slab memory > >=20 > > The existing tracers in the vmscan are as follows: > >=20 > > --do_try_to_free_pages > > --shrink_zones > > --trace_mm_vmscan_node_reclaim_begin (tracer) > > --shrink_node > > --shrink_node_memcgs > > --trace_mm_vmscan_memcg_shrink_begin (tracer) > > --shrink_lruvec > > --shrink_list > > --shrink_active_list > > --trace_mm_vmscan_lru_shrink_active (tracer) > > --shrink_inactive_list > > --trace_mm_vmscan_lru_shrink_inactive (tracer) > > --shrink_active_list > > --shrink_slab > > --do_shrink_slab > > --shrinker->count_objects() > > --trace_mm_shrink_slab_start (tracer) > > --shrinker->scan_objects() > > --trace_mm_shrink_slab_end (tracer) > > --trace_mm_vmscan_memcg_shrink_end (tracer) > > --trace_mm_vmscan_node_reclaim_end (tracer) > >=20 > > If we get the duration and quantity of shrink lru and slab, > > then we can measure the memory recycling, as follows > >=20 > > Measuring memory reclamation with bpf: > > LRU FILE: > > CPU COMM ShrinkActive(us) ShrinkInactive(us) Reclaim(page) > > 7 kswapd0 26 51 32 > > 7 kswapd0 52 47 13 > > SLAB: > > CPU COMM OBJ_NAME Count_Dur(us) Freeable(page) Scan_Dur(us) Reclaim= (page) > > 1 kswapd0 super_cache_scan.cfi_jt 2 341 3225 128 > > 7 kswapd0 super_cache_scan.cfi_jt 0 2247 8524 1024 > > 7 kswapd0 super_cache_scan.cfi_jt 2367 0 0 0 > >=20 > > For this, add the new tracer to shrink_active_list/shrink_inactive_list > > and shrinker->count_objects(). > >=20 > > Changes: > > v6: * Add Reviewed-by from Steven Rostedt. > > v5: * Use 'DECLARE_EVENT_CLASS(mm_vmscan_lru_shrink_start_template' to > > replace 'RACE_EVENT(mm_vmscan_lru_shrink_inactive/active_start' > > * Add the explanation for adding new shrink lru events into 'mm: v= mscan: add new event to trace shrink lru' > > v4: Add Reviewed-by and Changlog to every patch. > > v3: Swap the positions of 'nid' and 'freeable' to prevent the hole in t= he trace event. > > v2: Modify trace_mm_vmscan_lru_shrink_inactive() in evict_folios() at t= he same time to fix build error. > >=20 > > cuibixuan (2): > > mm: shrinker: add new event to trace shrink count > > mm: vmscan: add new event to trace shrink lru > >=20 > > include/trace/events/vmscan.h | 80 ++++++++++++++++++++++++++++++++++- > > mm/shrinker.c | 4 ++ > > mm/vmscan.c | 11 +++-- > > 3 files changed, 90 insertions(+), 5 deletions(-) > > =20