From patchwork Mon Dec 4 23:49:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13479204 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 637F4C10DC1 for ; Mon, 4 Dec 2023 23:49:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5EAC46B0083; Mon, 4 Dec 2023 18:49:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 572CD6B0085; Mon, 4 Dec 2023 18:49:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 413F26B0088; Mon, 4 Dec 2023 18:49:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 319AE6B0083 for ; Mon, 4 Dec 2023 18:49:25 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0C0D21602F2 for ; Mon, 4 Dec 2023 23:49:25 +0000 (UTC) X-FDA: 81530779890.30.8E61456 Received: from 66-220-144-179.mail-mxout.facebook.com (66-220-144-179.mail-mxout.facebook.com [66.220.144.179]) by imf27.hostedemail.com (Postfix) with ESMTP id 6FCAC4001F for ; Mon, 4 Dec 2023 23:49:22 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; spf=neutral (imf27.hostedemail.com: 66.220.144.179 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701733762; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KrJCHAvMqaPD2ExlYvE6d8JvnMrC8e7u3sjXW8vUDYc=; b=YUxzR+ONK94ld6jTefaRsy21HWDbYAeH1vUuX8j9BcqtR+MesO0fMPXeX9BoU9Y1qSkP6u kyuuAiaPR0vVGPkwfDoz2cBFz0SjzMIe6KW8Hf9rx1poXGT8JHsn0bvLKRF4aQao31eEgk 9aDxRH8bpiLc5aooX7WwBKSON1CvavA= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=neutral (imf27.hostedemail.com: 66.220.144.179 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701733762; a=rsa-sha256; cv=none; b=8KgFlpj4zbHWZqycWb37Ickh5iFA7xOhn7KgYnVb/GGQjvq+TDuQz0SiIm9XAEbbXzA5Z6 5cp8txfpv0oALYdjCA4rY+sKHJOg8JRmORA/42IVrju+wUEgqwPrDHvC+9tEKgOMefipFv 27Pcqxxp9XhDF0bOxjnVHG0Zt3udsyo= 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 X-Rspamd-Queue-Id: 6FCAC4001F X-Rspam-User: X-Stat-Signature: tpfxx69rumryrqxhki99kfcdhdscok78 X-Rspamd-Server: rspam01 X-HE-Tag: 1701733762-707583 X-HE-Meta: U2FsdGVkX1+INNaTk/i7XFHt2XvUgEZnrt66Z5qhl383vspwIpUxAyFX6K2W6Vp6uNIhW6kbUDWdkvILHYTKVqJ4u9n2Pt8k8Ei709rpMmDqZzDsqTdwsvF3q6Ly5Tdx/+9/LYjeEU93yxi7yZYiRJllhwR11gF0sTl6WomqgM27Ht6mC5+eXPcqpXLik4vfHR+IndsNXIshopH0qgudQeFBaudxnX5AvNQCTLsR4QeCkguWVYYf5ZDInghkQENUOABZR3N285Mi2DWwehKy0xW855/eDYSr0nF8jklTYcno81FgJhS+DXcj20/mfTwCpcFxAlmxjdboX+/Jcm840A72UmmWiEs73aY0BoB1ASHpyaieFBvf7bUwADXepqDKif5IT2NhYF/4JyPRydtIHAH7D/6FoobfeyOYBMy5gN1PP7Uq4s/SR2GsYwnhT6/SqyARSvW8GBR9/tYBYKWoR1nXJr2qnEOfJT65C0i/Z1nqjJLaTnSVAD02AyEv5cw0njmAiSpXJunjCiNR1jhXrJRkkcC1mhN5Gp0OhMDLzTZvIY0g8fQIiW3IdutZp6/v5AEnQNOPdSFy0Pe43sXn4+MWsd2oEbmJIIVufYPo46Uq2Qfx0ZSr/4SOCU6uXLfewzCQ1BLF54o0nwnPR6hTx12+Rya2whaHEf8TjeLv444H8ufAERWX5jcMTdvHqlDEvCO+/TwcnQYhfzB3QlLcedZPPO2GDytiEnful71g8lzDgwrqjBmJdy4LyJ3mv5W1Zv9RMSBiZ36s1g6aluQDbmM25FJfSXh0QMWT0P7xwG0ujZo7k3kuWbERVld9JZjlWXMJvBfa527lxAyJ8o/ECFjRuQcA4QcvCrauyVQwhTJBUn+56kjcowv1OckXMX7xs9neJWX/gyFPUsU1ZcOUZaNgX+pyv1bonouow/k7z96P8fgnnO8M40UVuNpnFCLd7yLtaQryldD61EGI7TS KJXeWylA qOPDcFOdeg5SzZNM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000008, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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) ); +/** + * 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 = scan_time; + __entry->pages_to_scan = pages_to_scan; + __entry->cpu_percent = 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 */ /* 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 = cpu_time; ksm_thread_pages_to_scan = pages; + trace_ksm_advisor(scan_time, pages, cpu_percent); } static void run_advisor(void)