Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp161760rdh; Mon, 18 Dec 2023 15:11:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHuO72Lgfp3Y1xa4xjDcWsA3WByhjJ5c9a/G66hfRudnM5hSWL82kEiC5y/t7krFfawghse X-Received: by 2002:a17:906:5192:b0:a23:7624:6152 with SMTP id y18-20020a170906519200b00a2376246152mr19600ejk.73.1702941092942; Mon, 18 Dec 2023 15:11:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702941092; cv=none; d=google.com; s=arc-20160816; b=pWGwOUDkXPfm2ayWSrgCvcgh3JyDjG8ZSk3Bba7u2LP+CjrEkx14oMrGCYLWpdMPt5 gFQY4lx4H/1fy0GoJbpPZeBj9lRCYMSAiMT8Uuyd/n8W+3MN8pzZhBL6JQL/IX+lVuw1 Ugyykx0sNUcmhRwUJdJwKDhff5CPZOqj1Gs1v30iAm+WjY5JpzWkAWBgA6Zk2Ee2Vtog o/vUZ6RB7koGmWweOyyDOuEGn2guk6e34k6lciPpyfVNYQkkXveqJ+/eS77I++oVwNt7 C8CuSwnnYUsaxt9P4yZTXvmhqCRD8ZBQbylpjEEefT3SsY0vYT7n1WzUkwygTVK7Ar1+ Sw5w== ARC-Message-Signature: i=1; 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 :date:subject:cc:to:from; bh=1Fz3XLdrz2+bpgvBdPbZhoJrVUUleR20qZ12O9sFG0I=; fh=sS+J4OyOC0EcVLWJpS3mBHGeO+0+dYZJ+ImCUfzsrH4=; b=WUynzVunC5Km1VrBReYkLjrDOKpAZFzPUkJf8igfFR6lKpySrtcvZeXHDhzTgoZIQc dWITTQvr4jcCqYhTTydiiuV9aHhfqv28SA1BKWMRSazcaz8BmBxSpMSNoBV8rLeEruBt QLi7EpbRmf5sOk9U5tFHZhaX3/dyt88hgwrOdBB/Jj2aUPr8bj+DcLQvV6q7wK+B1bCy c2ZxkfQFOuI7dN3GljcDf84c1lFEzjSddp88O1Ckp8Iyxa68oRIqIRvEtdGZNJLipi73 WocAu5UXEhKykZQYgkBB2+p88+UwXLL1pADrXVoOeRutRaF9Xi6A2JYohPqJMRn1BFjI /qvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4468-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4468-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 a27-20020a1709062b1b00b00a2333088439si2095045ejg.744.2023.12.18.15.11.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 15:11:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4468-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; spf=pass (google.com: domain of linux-kernel+bounces-4468-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4468-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 ADBA01F24655 for ; Mon, 18 Dec 2023 23:11:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA4AA768F0; Mon, 18 Dec 2023 23:11:11 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from 66-220-144-179.mail-mxout.facebook.com (66-220-144-179.mail-mxout.facebook.com [66.220.144.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA2F176098 for ; Mon, 18 Dec 2023 23:11:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=devkernel.io Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=devkernel.io Received: by devbig1114.prn1.facebook.com (Postfix, from userid 425415) id 7028E111427B3; Mon, 18 Dec 2023 15:10:57 -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 v5 3/4] mm/ksm: add tracepoint for ksm advisor Date: Mon, 18 Dec 2023 15:10:53 -0800 Message-Id: <20231218231054.1625219-4-shr@devkernel.io> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231218231054.1625219-1-shr@devkernel.io> References: <20231218231054.1625219-1-shr@devkernel.io> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 10e2696907250..82688fc6f119f 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -458,6 +458,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