Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp3056637rdb; Mon, 4 Dec 2023 15:49:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGjl/X2w409t/jhJySgU7M672WM0gChSoKoQwr7Lx9zuBdPb7vX8fdOc3ABUQr36l/Yh6U X-Received: by 2002:a05:6870:f153:b0:1fb:75b:2fb1 with SMTP id l19-20020a056870f15300b001fb075b2fb1mr5733053oac.72.1701733781917; Mon, 04 Dec 2023 15:49:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701733781; cv=none; d=google.com; s=arc-20160816; b=X2IvRrzoQOIwR9tznMR4gfpfL47C5V05nzvVPRGvxaX8wlSEVSMsJeR7V92lZMR4X3 wogwTt7JIkdvYHFY3Qba0JoHjtJmucuBzB1DTRN0NGgSJ4MUPfzxZYqJ97eAlcv9N5PT VWqhL5zs6sYNxX5WOOHjEa58wuunqACgjqNPZBxQFPBww/btWuQ7eTE1bEReocaCGup0 zn5CH+aJE+zuO3C0C38Ki/M23Nqq61+C0ZVwgWKQVUz6ugMUeJHMaRsjLjnWHlwKPmxJ ZjFSrgjLoh/rcPd/4n+P+Etjmmac/4CLsszE0izHZZNcjL5BNJ4DO9SQscKOx2MEjswY /puw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=KrJCHAvMqaPD2ExlYvE6d8JvnMrC8e7u3sjXW8vUDYc=; fh=sS+J4OyOC0EcVLWJpS3mBHGeO+0+dYZJ+ImCUfzsrH4=; b=RsIeg534YwYA/7jLxSD1LKOLgMcGl3fykdeKBtpaGklzl2eMrH1CndiRE1z+ghwYT+ j1ormsRR2KaF6DHq2D9bAvxsMfetRgn1pi+eJtddJSyt8QalydbXwvwP+zbnCJXixhcQ ExE6z9dZ8OUudCpk42FwZ043CzEGTAaXw0gnp+AnarkfAkTuIC8j99y06FlCJ9UPQ/7a 8TskjcWctcHsJj20FOImxdUDW50S1qbrdcA+CKjagF5E7+U/drbBE0rXhaep1fuOdz9R yowvgSOF+rAyUNQ7FH5rFVp1nHDiKR71U4WPUU+9rQDTbBADUdmtPBIXcH17XGscma43 iXdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id r5-20020a632045000000b005c1b303c414si8671941pgm.625.2023.12.04.15.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 15:49:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 9C64D80227DC; Mon, 4 Dec 2023 15:49:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343494AbjLDXtQ (ORCPT + 99 others); Mon, 4 Dec 2023 18:49:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234721AbjLDXtP (ORCPT ); Mon, 4 Dec 2023 18:49:15 -0500 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFA6F101 for ; Mon, 4 Dec 2023 15:49:21 -0800 (PST) Received: by devbig1114.prn1.facebook.com (Postfix, from userid 425415) id EF772105D3A8A; Mon, 4 Dec 2023 15:49:09 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com Cc: shr@devkernel.io, akpm@linux-foundation.org, david@redhat.com, hannes@cmpxchg.org, riel@surriel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v3 3/4] mm/ksm: add tracepoint for ksm advisor Date: Mon, 4 Dec 2023 15:49:05 -0800 Message-Id: <20231204234906.1237478-4-shr@devkernel.io> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231204234906.1237478-1-shr@devkernel.io> References: <20231204234906.1237478-1-shr@devkernel.io> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 04 Dec 2023 15:49:37 -0800 (PST) This adds a new tracepoint for the ksm advisor. It reports the last scan time, the new setting of the pages_to_scan parameter and the average cpu percent usage of the ksmd background thread for the last scan. Signed-off-by: Stefan Roesch --- include/trace/events/ksm.h | 33 +++++++++++++++++++++++++++++++++ mm/ksm.c | 1 + 2 files changed, 34 insertions(+) diff --git a/include/trace/events/ksm.h b/include/trace/events/ksm.h index b5ac35c1d0e88..e728647b5d268 100644 --- a/include/trace/events/ksm.h +++ b/include/trace/events/ksm.h @@ -245,6 +245,39 @@ TRACE_EVENT(ksm_remove_rmap_item, __entry->pfn, __entry->rmap_item, __entry->mm) ); =20 +/** + * ksm_advisor - called after the advisor has run + * + * @scan_time: scan time in seconds + * @pages_to_scan: new pages_to_scan value + * @cpu_percent: cpu usage in percent + * + * Allows to trace the ksm advisor. + */ +TRACE_EVENT(ksm_advisor, + + TP_PROTO(s64 scan_time, unsigned long pages_to_scan, + unsigned int cpu_percent), + + TP_ARGS(scan_time, pages_to_scan, cpu_percent), + + TP_STRUCT__entry( + __field(s64, scan_time) + __field(unsigned long, pages_to_scan) + __field(unsigned int, cpu_percent) + ), + + TP_fast_assign( + __entry->scan_time =3D scan_time; + __entry->pages_to_scan =3D pages_to_scan; + __entry->cpu_percent =3D cpu_percent; + ), + + TP_printk("ksm scan time %lld pages_to_scan %lu cpu percent %u", + __entry->scan_time, __entry->pages_to_scan, + __entry->cpu_percent) +); + #endif /* _TRACE_KSM_H */ =20 /* This part must be outside protection */ diff --git a/mm/ksm.c b/mm/ksm.c index 18b7185bbc65b..b8065c5d5f833 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -455,6 +455,7 @@ static void scan_time_advisor(void) advisor_ctx.cpu_time =3D cpu_time; =20 ksm_thread_pages_to_scan =3D pages; + trace_ksm_advisor(scan_time, pages, cpu_percent); } =20 static void run_advisor(void) --=20 2.39.3