From patchwork Wed Dec 13 00:04:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 13490149 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 03C6CC4167D for ; Wed, 13 Dec 2023 00:07:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 829526B03F4; Tue, 12 Dec 2023 19:07:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DCA96B03F8; Tue, 12 Dec 2023 19:07:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 511106B03F4; Tue, 12 Dec 2023 19:07:29 -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 2D77E6B03F4 for ; Tue, 12 Dec 2023 19:07:29 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E9863120A90 for ; Wed, 13 Dec 2023 00:07:28 +0000 (UTC) X-FDA: 81559855776.28.9782235 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by imf18.hostedemail.com (Postfix) with ESMTP id DF5041C0026 for ; Wed, 13 Dec 2023 00:07:25 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=amazon.com header.s=amazon201209 header.b=nJP9DAV+; spf=pass (imf18.hostedemail.com: domain of "prvs=704f7accf=graf@amazon.de" designates 72.21.196.25 as permitted sender) smtp.mailfrom="prvs=704f7accf=graf@amazon.de"; dmarc=pass (policy=quarantine) header.from=amazon.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702426045; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mc8BtMBoJccPwXhN5lfGmopEl26ZPwt65Ef0Tkxcd1Y=; b=h65RfaLbQYZEqLxEwf7wS5wF5wuaRKY8ckZtPjKbCtKSCTeOvy6cEG/dI9MK5zFbbC1HP+ D1qE3ynjdXI2BhrxJ9xlw25Ua5M2HY6ydn9HJDeVbsu4qIt/MhRcUTHgiMZy4jxbAc56Eq fh/9PfSIC4xtET9V6Wh+07K3zarsIus= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702426045; a=rsa-sha256; cv=none; b=FOUdXA7/1/fbUJsVdvcOfJRMG4IUI4oG+x62oF0WLc316bbqtny1qdiDxzCijfxgPd4FgE p0frum0rZW8YPsmXRWCpPbpLyC/nlJ1PsOh1E9YZR7yJxwpGv1KherVLGvfU/oVDr36tpm 7KlPOCHZpM0iVOO8QIuKR9xDOuZ1tbg= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=amazon.com header.s=amazon201209 header.b=nJP9DAV+; spf=pass (imf18.hostedemail.com: domain of "prvs=704f7accf=graf@amazon.de" designates 72.21.196.25 as permitted sender) smtp.mailfrom="prvs=704f7accf=graf@amazon.de"; dmarc=pass (policy=quarantine) header.from=amazon.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1702426046; x=1733962046; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mc8BtMBoJccPwXhN5lfGmopEl26ZPwt65Ef0Tkxcd1Y=; b=nJP9DAV+PMYgo36zjEPVnQszs1x7x97mrNCJJx7xx16JpMT8DRxxcLmt tDqFYct2S9Hom/kiK7hVqLwY/o/DCg7FOXYBXNE1oNXr7WR1OdIEz6faS GQoxmWBycdZm8Rp6RyPsK29WCAzO/8u/tlvJcGh1LTweRgcC6tzlYmW0F o=; X-IronPort-AV: E=Sophos;i="6.04,271,1695686400"; d="scan'208";a="368122532" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1d-m6i4x-e651a362.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2023 00:07:24 +0000 Received: from smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev (iad7-ws-svc-p70-lb3-vlan3.iad.amazon.com [10.32.235.38]) by email-inbound-relay-iad-1d-m6i4x-e651a362.us-east-1.amazon.com (Postfix) with ESMTPS id 5BC7680493; Wed, 13 Dec 2023 00:07:16 +0000 (UTC) Received: from EX19MTAUWB002.ant.amazon.com [10.0.21.151:32184] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.43.236:2525] with esmtp (Farcaster) id 342278a3-113e-4653-a12d-678bc8408d80; Wed, 13 Dec 2023 00:07:15 +0000 (UTC) X-Farcaster-Flow-ID: 342278a3-113e-4653-a12d-678bc8408d80 Received: from EX19D020UWC004.ant.amazon.com (10.13.138.149) by EX19MTAUWB002.ant.amazon.com (10.250.64.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 13 Dec 2023 00:07:15 +0000 Received: from dev-dsk-graf-1a-5ce218e4.eu-west-1.amazon.com (10.253.83.51) by EX19D020UWC004.ant.amazon.com (10.13.138.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 13 Dec 2023 00:07:11 +0000 From: Alexander Graf To: CC: , , , , , , , Eric Biederman , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , "Rob Herring" , Steven Rostedt , "Andrew Morton" , Mark Rutland , "Tom Lendacky" , Ashish Kalra , James Gowans , Stanislav Kinsburskii , , , , Anthony Yznaga , Usama Arif , David Woodhouse , Benjamin Herrenschmidt Subject: [PATCH 13/15] tracing: Add kho serialization of trace events Date: Wed, 13 Dec 2023 00:04:50 +0000 Message-ID: <20231213000452.88295-14-graf@amazon.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231213000452.88295-1-graf@amazon.com> References: <20231213000452.88295-1-graf@amazon.com> MIME-Version: 1.0 X-Originating-IP: [10.253.83.51] X-ClientProxiedBy: EX19D037UWB002.ant.amazon.com (10.13.138.121) To EX19D020UWC004.ant.amazon.com (10.13.138.149) X-Stat-Signature: 3f9m7u7ppetcucuu1s9sp1qerrwo9sm3 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: DF5041C0026 X-Rspam-User: X-HE-Tag: 1702426045-277304 X-HE-Meta: U2FsdGVkX18rY876b0ZSuYhCaTm5uihEZkCyGh7CV8jJoXc0XdPr6OVPffu9cF2FRMNb8gWCaEPas6eTG6lsj2F/WvtzH7RpW5iE9BUg1xQI9cMecgMtdi6hqQwJzbqcervCOAdodraDEXFPYGtYhwepSLgxbGyJbvUan6Djo9qjqHunRycOEaZf4ZyuWJ0wh8PtyE1qrAuuUl1oaxNokAJTYQHqFxXWnV2fGyxb1C1WzFV1I4NCrfm2aluXqRjKC/isDrlYgpwwLncO/JDOqYyHhWzZrGvG4tLU4y1GfV4wCIQvVUWvRWbTDkJEP3sNyJpZ+BMpq92M6hGEcD8Br5a+YUIyfgoDB6Elw/mOLdTx2R2si1jSCEJxEwtx4RJr3gsFwIf0NX3gwlNVwRaOT3Tuas5CNhStfAjySI5FHVuXbAWz6EF0TXUezGhkG2evFKz9ulEpTnEB6ZIrNcT5kFzk9ZNvj3BRsiy9lu3IUtbb5b82j9A5du3ZdLcJh8qMl7j3K8FNLvGaJZBQyapK1KjY7GCuh0wF8oyBO7ftqXStUnT3CRfv9xq6MlUOJMNfQdlPUPKKz9vjROMHj320LDs2n5Ac72O8hk3W86x2ssVBcYIEnSMo69TDsQx7nbCRCxZAKxVo/8vl1rhgDB1yeoBn2vzCHiuJ9zjHQKMVtmPoOQKABI2ptkVcnRnTK4mnYaoMEFpU5XowCXxlvNtNbBISl9pw/tpHG8dEihMYc9BPXZMsl2kyCl811LT99P+nCXAmrqLTsqRaZrl+vGNYSZtT36Ne77An7Sb4zZQDvPKY2txGsphd27k7n4XCsxA+Z8Fkrze4UDc6u7HRD8Gg953jOzlJRMbpScaEPI6H+77r6WYP6ubgvJvzun0zC1fbZJvwXDdf9bCl0+JLhBXYyTUqu7slfMBm2/I44PNjomSAzFrz5J986CiNrSTbnbA4MIaToD8VEAbjJyn0zHu UBLUSd/E pGqoojSqnnhRfo1M6VBrHVOOc8h2FD3aEeQjZtuzhJJWE00cqJnnMsfqGrbw6k2q8ybMxPY0aoVtZ9GT7IWpNRFpVm1dTby5ponRIfBfJKEJr2wML3pbmOW2VTqgLb9E/dlO2mu5D98TWVD5xq9mp9IY1BAOVFabrY251q4Px/mUnijj9W8+eDNGwDz0jJYTrlHk6hHFFR4kxhzU7aLimUUcodkJMVQwML2jH+J2BXnwNRdE0My5N/vRbAsMYxNgyGk0X3hEkDz0PB8ouY6PxH7f8V2VLZecxLTRdH+3zZuAcfAFTtHOQ9WxL/rbFgA5Jnt3typPijFjVXUSeepX0BEdliA5VmLDz1fT3wgBD2u8QTkkWKb9rN02slrs5OBrR2S2d X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Events and thus their parsing handle in ftrace have dynamic IDs that get assigned whenever the event is added to the system. If we want to parse trace events after kexec, we need to link event IDs back to the original trace event that existed before we kexec'ed. There are broadly 2 paths we could take for that: 1) Save full event description across KHO, restore after kexec, merge identical trace events into a single identifier. 2) Recover the ID of post-kexec added events so they get the same ID after kexec that they had before kexec This patch implements the second option. It's simpler and thus less intrusive. However, it means we can not fully parse affected events when the kernel removes or modifies trace events across a kho kexec. Signed-off-by: Alexander Graf --- kernel/trace/trace.c | 1 + kernel/trace/trace_output.c | 28 ++++++++++++++++++++++++++++ kernel/trace/trace_output.h | 1 + 3 files changed, 30 insertions(+) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 71c249cc5b43..26edfd2a85fd 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -10639,6 +10639,7 @@ static int trace_kho_notifier(struct notifier_block *self, err |= fdt_begin_node(fdt, "ftrace"); err |= fdt_property(fdt, "compatible", compatible, sizeof(compatible)); err |= trace_kho_write_trace_array(fdt, &global_trace); + err |= trace_kho_write_events(fdt); err |= fdt_end_node(fdt); if (!err) { diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index f3677e0da795..113de40c616f 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "trace_output.h" @@ -669,6 +670,33 @@ int trace_print_lat_context(struct trace_iterator *iter) return !trace_seq_has_overflowed(s); } +int trace_kho_write_events(void *fdt) +{ +#ifdef CONFIG_FTRACE_KHO + const char compatible[] = "ftrace,events-v1"; + const char *name = "events"; + struct trace_event *event; + unsigned key; + int err = 0; + + err |= fdt_begin_node(fdt, name); + err |= fdt_property(fdt, "compatible", compatible, sizeof(compatible)); + + for (key = 0; key < EVENT_HASHSIZE; key++) { + hlist_for_each_entry(event, &event_hash[key], node) + err |= fdt_property(fdt, event->name, &event->type, + sizeof(event->type)); + } + + err |= fdt_end_node(fdt); + + return err; +#else + return 0; +#endif +} + + /** * ftrace_find_event - find a registered event * @type: the type of event to look for diff --git a/kernel/trace/trace_output.h b/kernel/trace/trace_output.h index dca40f1f1da4..36dc7963269e 100644 --- a/kernel/trace/trace_output.h +++ b/kernel/trace/trace_output.h @@ -25,6 +25,7 @@ extern enum print_line_t print_event_fields(struct trace_iterator *iter, extern void trace_event_read_lock(void); extern void trace_event_read_unlock(void); extern struct trace_event *ftrace_find_event(int type); +extern int trace_kho_write_events(void *fdt); extern enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags, struct trace_event *event);