Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5505520rdb; Wed, 13 Dec 2023 10:28:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1jmlYF/40yqdXnyQ10qdC6aVxnQstqmITVrjczqN1aWqaEF5ekuvX2Tgt46ECKGIJgPFo X-Received: by 2002:a05:6a21:78a4:b0:18f:97c:4f4d with SMTP id bf36-20020a056a2178a400b0018f097c4f4dmr5078784pzc.89.1702492096012; Wed, 13 Dec 2023 10:28:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702492095; cv=none; d=google.com; s=arc-20160816; b=VRMBS3HPYx4dL+SCRDDZ/TbRkPU8Oa8B2edY+ZRj9lLYXjpfnkCIwLma+tQh2lZMyc Vi0VKQS6Uk/mIckRuQ7ps0sIiX1a86HmK2wxUmor/RmTJUsY7zwljWsNOmC6CDYJR/yj 19aWv02r4vBVnRk4ROQVsRdmRc+St6u6yIul7RlrjBnGIcN3lVt2HmVF31wx/HOrVycf WfNOaCOymaqQWUYWbsPV0uomJWUWtNS7Mne1uAq+G1t6jCvygjIyG/vDlKuUOQ8o0qXP r24ADrGZyfdv+vzhM/Vk5z2nazhRaG6ToEAxxVeXM5GxDGoyApn1M8cuoPaHivXa60Ol sTXg== 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=Ju2E2+1OfMe8Vr4nHnwCyl1I0bs/30hKeMFq9hcWi4w=; fh=sS+J4OyOC0EcVLWJpS3mBHGeO+0+dYZJ+ImCUfzsrH4=; b=IrSTMBx/0ORUrfQ69Ww1PMdpaQaUl+TslMW+ypK2H29Qd8vKI91HPDQEBF5oPHBdV/ QROWYP18E+Enp44kxGTD5qMqRPvbshGjY2T663a35NaCeU6YHc8uh2k8m5iaisEcGbGE 0l6bXVLwiz/rV9edGyi/2hu1xSRVeRIWvnloJTV5Rb2Fasx/02krSV9bEvryotXKi4AS qbZOXAk8rVt3C8xWooWvLAFVjJaM3jMvbk3tjTpSiubZEmDbuDY/TuhvNmtrZZ9psT05 xQZacE/JRjEwngXe9CoxVIbN6uGZCcUHSpkXzOTQ7o3/yw95Q47W4EpPd0qBthcPg46f htYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k16-20020a63d850000000b005740b4723f9si9887691pgj.811.2023.12.13.10.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:28:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 4058C8030A6A; Wed, 13 Dec 2023 10:28:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235563AbjLMS1r (ORCPT + 99 others); Wed, 13 Dec 2023 13:27:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235592AbjLMS1j (ORCPT ); Wed, 13 Dec 2023 13:27:39 -0500 Received: from 66-220-144-179.mail-mxout.facebook.com (66-220-144-179.mail-mxout.facebook.com [66.220.144.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42C33116 for ; Wed, 13 Dec 2023 10:27:46 -0800 (PST) Received: by devbig1114.prn1.facebook.com (Postfix, from userid 425415) id BCBAB10CFA72C; Wed, 13 Dec 2023 10:27:33 -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 v4 3/4] mm/ksm: add tracepoint for ksm advisor Date: Wed, 13 Dec 2023 10:27:28 -0800 Message-Id: <20231213182729.587081-4-shr@devkernel.io> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231213182729.587081-1-shr@devkernel.io> References: <20231213182729.587081-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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:28:12 -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 Acked-by: David Hildenbrand --- 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 f7387a6d02050..4962e44131e68 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -452,6 +452,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 advisor_stop_scan(void) --=20 2.39.3