From patchwork Wed Oct 4 19:02:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13409344 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 563ABE7C4E9 for ; Wed, 4 Oct 2023 19:03:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59D9A8D00B1; Wed, 4 Oct 2023 15:03:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52B418D00B0; Wed, 4 Oct 2023 15:03:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A0888D00B3; Wed, 4 Oct 2023 15:03:21 -0400 (EDT) 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 F22188D00B0 for ; Wed, 4 Oct 2023 15:03:20 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C2A1B120415 for ; Wed, 4 Oct 2023 19:03:20 +0000 (UTC) X-FDA: 81308702160.03.0FF5F07 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf01.hostedemail.com (Postfix) with ESMTP id 1480040024 for ; Wed, 4 Oct 2023 19:03:18 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf01.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696446199; 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=nGJLAZBPfk0bEDQ5MQJUdfphtdeAgk92zsf1B92wAEU=; b=LpPRwphSwPIPNW6M6kP1mxIF8sidIhr5OMDxTULvCtvk2E92gFEDOPDyvTyL/p7De2Ze6G YH2iSHrhKe0kPdDXbgw5+7tvr2dHY9n17O2e/089KSteRPnYqj3K1nqPPJHyAbuNFqwqG9 NDYBNimCUQXTY/N5C0Op3vRal4b+l2I= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf01.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696446199; a=rsa-sha256; cv=none; b=CpUAjs04hPjddRcWMvi8d46WFtUf4YyCNxqPAwUUtD/Cz8ZFkeB0pumNcVb6gF5K3T2QYW MZbwHl3cVDSoUHimtaBhwZYLcEgCMKZrXm5hnLcGCfKqwER78sjug0+nYOEn0QRqGz8axd xnq01Gd2nJuoVsO3Ui17gnEBNlO9Z+k= 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 X-Rspam-User: X-Stat-Signature: 7ihw45nb9kzjno6din7fqgtgd68dm94o X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1480040024 X-HE-Tag: 1696446198-207927 X-HE-Meta: U2FsdGVkX1+nxEcC6AUMKXHgayN5IDGFKg30pWdik+TSPkXVzouWJibatc1b56N5eINhxTS8nkMG5PnRi3hTDLBINmKlPTTQw6KG4eQiw8/4Fb9CabpuoZuiKjjCTpVcelB5WctTPmvTCwtSzX20yODD3SHeBYobHyVTvj4OZtkLYjqkERj+s6SNPx71EbslR9ftysmt/kMwAkSaHJ4ikAAAcgZ2lBv26S7J85sFCQcrLByi8l6Lu1iHExKrPbvb+Xc+mxBs3tzCVA9rd4sSMnd42CEk64t8COOX3+dv3pPsTSxIhLRPj+bAYn+iNk71pnUFhx13jpXlurMfsLA9x2e9psATaNSSE1uSDHKBzvTN8YohRToBzUHxQd2zM4DD0R34baQ+LIs7+LpdKuL0iai+kJ1/+JOKS3fRYWe0i535pfavS8ZwLsbFtC4P5nVouGkdgx5IzA58niMA0Do3vZpZQc9QfWC2s+fKKIo56u99HiiGtsOtyeppVp/pedHIotx2mV/bk/jiaEJkie6qf+ILrH7C8BEMUH3QAovOhzICCH1DvD1QuTfDbW0s+XXDojJWqSArm8ap+4zzC6meEG4Qy0PExj332M5OKGNH1O25taZcCVl7GPgkTEOA5IWMD0ImAQKEWvk+IvrvCZi5fQynwAUR0oD/g9CP989W7WqyFWZ+sKjJ6sy+jtjChfwolBTmIvur+UBcCSKZ+LQmGpmuOjfhjVFOioqjLH/5b1TEc63MdY4UrW2olJ/GC+xITWIXUuWULCaEfaa8cPRArZg50MVm9pPPTvWB3OfLNlD5JJ8Ykb2vnjL6u5qK158tQxdI93Gtu/JfSq3uH2LV6oo4waryY1AWxK3JUN3S+shGX9o/H60uqkuHki5MYxoxbHqLOLKVwW6zIccPZ/ps5WQYXVndW0hce4t8pzOXQQajHImoSmJ0RHR53Am3uW2Asl+nt/bu2VQUCE1gC+P LLV6R6SW 1R8boKdB3Zyn+QzjJ89nJ+Oz/wZMWjgVfmP5d X-Bogosity: Ham, tests=bogofilter, spamicity=0.000131, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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) ); +/** + * 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 = scan_time; + __entry->pages_to_scan = pages_to_scan; + ), + + TP_printk("ksm scan time %lld pages_to_scan %lu", + __entry->scan_time, __entry->pages_to_scan) +); + #endif /* _TRACE_KSM_H */ /* 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 = change; advisor_ctx.scan_time = scan_time; ksm_thread_pages_to_scan = pages; + + trace_ksm_advisor(scan_time, pages); } static void run_advisor(void)