Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2820051rdb; Wed, 4 Oct 2023 12:24:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+2O4dPJ6+BuLmN7IbGkRlMekHZJ/2xPGBo8cAo1CMepyHplvc9IWoaMZgIdM+w3iERE21 X-Received: by 2002:a17:902:ce8d:b0:1b9:e913:b585 with SMTP id f13-20020a170902ce8d00b001b9e913b585mr939063plg.13.1696447478638; Wed, 04 Oct 2023 12:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696447478; cv=none; d=google.com; s=arc-20160816; b=h+IMDDlQPETC1upYvpPVqBZrzto9izlQK0GpvPHdiWlMiZzFXJ4fnmaJP3R/rz110x q06Gg1jeF3y8PWzRX/aAJPIQjca5aEnEIfaKbbr9gwtMu6yhZqveXWWVWZ1rt+OEmpDg ankcSqlHIXP9Zv+Qrpe4nSLqyxmGQa5dU1k92nFn7+TBEN0e7EokRKyP4S8ivE5mSqAh 3vXnepm7OYnsrdKZXvOSbsTCVsS86PsrSN5oUnpWVoV89TXWlMZa60L4AV52foqDJiGT rIaX6kohD8iWe7sOGozL8UlejGYEot0MhTJQlftTgsRAkpmJy+CD154FjqaKV5XmLokU mchg== 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=nGJLAZBPfk0bEDQ5MQJUdfphtdeAgk92zsf1B92wAEU=; fh=sS+J4OyOC0EcVLWJpS3mBHGeO+0+dYZJ+ImCUfzsrH4=; b=QNPP+OY08Z19jbrWZd211noY7FBc68/2LNVp8OG6ej/KW5WBBtWjEIi5PmfPXuLbob vLsrHW+ApO5tQrG7x61owBgh4iYzH+6u5tgkvxfJmmOeSSk0xv1qyqGkXSlMJA47DlAD YONG2T+8EPoZTn/qoN7ivklkfIKB/54PdzYyTOAf8DUslXRsGgy5g8QJKzypfGCVpp0z KeuEEv7ufVJCXEdoH+3KGn6c3XpkXMtZAw8GN2AcnGNRT4MPtSlOptr/A8DnTjcPdgP/ apHD37evq46Y2u4MCKDDnjuK9Ci3ZVUv7l/Mzl4NyZwcwMlFhsmJYWSJU8UImUXoikpv 11BA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id la7-20020a170902fa0700b001c426636990si4005714plb.637.2023.10.04.12.24.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 12:24:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 9753D8115473; Wed, 4 Oct 2023 12:24:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245448AbjJDTHr (ORCPT + 99 others); Wed, 4 Oct 2023 15:07:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343889AbjJDTHY (ORCPT ); Wed, 4 Oct 2023 15:07:24 -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 C1F8430EA for ; Wed, 4 Oct 2023 12:03:15 -0700 (PDT) Received: by devbig1114.prn1.facebook.com (Postfix, from userid 425415) id 0521ED08C001; Wed, 4 Oct 2023 12:03:02 -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 v1 3/4] mm/ksm: add tracepoint for ksm advisor Date: Wed, 4 Oct 2023 12:02:48 -0700 Message-Id: <20231004190249.829015-4-shr@devkernel.io> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231004190249.829015-1-shr@devkernel.io> References: <20231004190249.829015-1-shr@devkernel.io> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 04 Oct 2023 12:24:28 -0700 (PDT) X-Spam-Level: ** This adds a new tracepoint for the ksm advisor. It reports the last scan time and the new setting of the pages_to_scan parameter. Signed-off-by: Stefan Roesch --- include/trace/events/ksm.h | 28 ++++++++++++++++++++++++++++ mm/ksm.c | 2 ++ 2 files changed, 30 insertions(+) diff --git a/include/trace/events/ksm.h b/include/trace/events/ksm.h index b5ac35c1d0e8..164133014922 100644 --- a/include/trace/events/ksm.h +++ b/include/trace/events/ksm.h @@ -245,6 +245,34 @@ 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 + * + * Allows to trace the ksm advisor. + */ +TRACE_EVENT(ksm_advisor, + + TP_PROTO(s64 scan_time, unsigned long pages_to_scan), + + TP_ARGS(scan_time, pages_to_scan), + + TP_STRUCT__entry( + __field(s64, scan_time) + __field(unsigned long, pages_to_scan) + ), + + TP_fast_assign( + __entry->scan_time =3D scan_time; + __entry->pages_to_scan =3D pages_to_scan; + ), + + TP_printk("ksm scan time %lld pages_to_scan %lu", + __entry->scan_time, __entry->pages_to_scan) +); + #endif /* _TRACE_KSM_H */ =20 /* This part must be outside protection */ diff --git a/mm/ksm.c b/mm/ksm.c index 12e70f806b2b..93dff974f6ea 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -415,6 +415,8 @@ static void scan_time_advisor(s64 scan_time) advisor_ctx.change =3D change; advisor_ctx.scan_time =3D scan_time; ksm_thread_pages_to_scan =3D pages; + + trace_ksm_advisor(scan_time, pages); } =20 static void run_advisor(void) --=20 2.39.3