Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1499928rdh; Fri, 27 Oct 2023 17:13:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEIXa+Fb+sJ6r//d1I9qOcv/tPK6LO2UPAU+xN6hVrNy8dj++njRUPewDhxfvz6p/McT23 X-Received: by 2002:a17:902:ce92:b0:1ca:c490:8539 with SMTP id f18-20020a170902ce9200b001cac4908539mr4473013plg.18.1698452004516; Fri, 27 Oct 2023 17:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698452004; cv=none; d=google.com; s=arc-20160816; b=UUOqhgGb3tx6CHMC8nEYXKosqklY5fazZ9DMo0f00R7hsvQI0++AsxBM6+7YBF9v2U 62buSO22f5QqwokTu/5rikpOrjoxPQgALEaXUIi2zmTX2bX4Tqbm3ySRMUQBHGytJBtQ bMke/Q2qiDP6iMcdfs0twEv/cwgz/MGYPeip4EUs7KUmXvJr+N06mkHFawculmpaTnqX xQTfBDW2jsZV/5x9fkq2AHuD67lEwOBKSgd8QBHkDwIkAEVxmgwMK9TNgaax7xOEVNv4 /S5utr065I/HMJp29jQdKKyRecuGuEdj6oFJkMOVcJ7Dh6OkFOe0IoY2ZSJGjLmP/JVq +nxg== 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=31VaYngcTYzlNRfnB5nKk/Q/RitTaJ38QTejLRm4eBI=; fh=sS+J4OyOC0EcVLWJpS3mBHGeO+0+dYZJ+ImCUfzsrH4=; b=hhy3GYKdwAMQnKE4wDkdkGKsoT1v6z891MuPrYEri2Ow8kjkvRnQnDThMdJ+BkHWd3 8d5CfnkMDYCEYcwhVLyRgvgA3Ml0b4xCpMe2spMuJX8jgOMtu/IMh1oIZbcZq1c/+ADC HIznMj3ZZcprmAsyfGatcYgzlgrvZECuwCC0vOjJodC5KGppZn0ppJZbVAxVOiF5YBym sFocApIdI2+ztpiejmA/hIrXHZwRqnyGp9Rgpd9GQDZbQaKEQPTelemcG24RCjopDSl2 e8rL7PmwuLTxQOZDYs7h1KtJ9fOpJZTdzrtUov1HyzZjdIrzyxNS4Ia6Awf2NRGtcvc3 47fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id a16-20020a170902ecd000b001c3b4eb2135si1829806plh.463.2023.10.27.17.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 17:13:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id D399D83D9B5B; Fri, 27 Oct 2023 17:13:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346742AbjJ1ANC (ORCPT + 99 others); Fri, 27 Oct 2023 20:13:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231444AbjJ1AM7 (ORCPT ); Fri, 27 Oct 2023 20:12:59 -0400 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 B5F511B8 for ; Fri, 27 Oct 2023 17:12:57 -0700 (PDT) Received: by devbig1114.prn1.facebook.com (Postfix, from userid 425415) id 6C454E5A25F5; Fri, 27 Oct 2023 17:10:25 -0700 (PDT) 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 v2 3/4] mm/ksm: add tracepoint for ksm advisor Date: Fri, 27 Oct 2023 17:09:44 -0700 Message-Id: <20231028000945.2428830-4-shr@devkernel.io> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231028000945.2428830-1-shr@devkernel.io> References: <20231028000945.2428830-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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Fri, 27 Oct 2023 17:13:20 -0700 (PDT) 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 b5ac35c1d0e8..e728647b5d26 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 042ecaeb0beb..b2a519083d66 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -442,6 +442,7 @@ static void scan_time_advisor(unsigned long scan_time= ) 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