Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp911795pxb; Wed, 6 Apr 2022 04:04:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAiDMH0Kh386B4JtQFDEVvQiyYq5JFsPCWmZO8VDpPryDOkic4DdwGUpPneL3J9ZVW8WPr X-Received: by 2002:a17:90b:4b43:b0:1c9:85b0:2db8 with SMTP id mi3-20020a17090b4b4300b001c985b02db8mr9235266pjb.23.1649243076976; Wed, 06 Apr 2022 04:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649243076; cv=none; d=google.com; s=arc-20160816; b=ZAOS0aSJvG0bfMMPwYtcb4ChNa9znco+56p/l8EgxGmgnWsgfNjo8S0CbBc6LRNIhT FOGVozTgSgCUZCB+mDTcTHPf4RmI92mAtSJUmEsRaoeFiAkt+jbM4+Pqn0R0Ze8doxEr vn7p59gZCXezqIbQp24JNvQRctw0qzcUPunkG1LVOUJSKm+WVL/B5nziCQqq6pUekI7u Rj9EOg82uDhw+MQSksG1iHOofjpnkw8XCu4Oo0qPQIc6c4DxNPII487Wt5Sr+PjyaqE7 ZHavWn+GVZfForvyrbMKwsnY/+73H9dumTqmSmva7ulry1zNfu9m7dZvtsKtn9X2Sy9r UiMw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mEg0ymuekEjgJ3tG2iAwjnfQrTDonEqg4cKyO5cvPr4=; b=cI6FxPS03diVrYOJoY1RT4JN8J9HF8bL/+PHI0i+yXkdLvDm5RPpNwvLcWh6rjWcln bcfHE4ZHIfsnc+ydNKVTFm0UWHFuJJYjA9C61O33G1e1lWNlPpdkLTmdcH+X0t/SadGT bYkaTwt35siLPLr86DLM06sKlWTyLZpuZstas+GK3ZNidqT9i3EOaMakZLCn/KylMVXC 2kIaIGz3XVNpdJUEMI7BLxCSC0U0y8MRYYXALPcsck/wM28U55gujXioz3E20dCawChE rYS4b1H04XBCsi4mIyQRrvBOUzrn7DGjMzLS17BSIZnzZzBkGXkdjZkosBzcJHW8tIok uw5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gzEF4JQs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k28-20020a63561c000000b003981ec7cad6si15613306pgb.342.2022.04.06.04.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:04:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gzEF4JQs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C743F5BE749; Wed, 6 Apr 2022 02:27:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377516AbiDEV2m (ORCPT + 99 others); Tue, 5 Apr 2022 17:28:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352608AbiDEKEr (ORCPT ); Tue, 5 Apr 2022 06:04:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCE5FBB905; Tue, 5 Apr 2022 02:53:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 72B18B81B75; Tue, 5 Apr 2022 09:53:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4ECFC385A2; Tue, 5 Apr 2022 09:53:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152409; bh=w2Xf9GEivdqIvsKCrbOSWWIVqMoFrXkYI9J7Vz0cuCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gzEF4JQsYxfcEhzaUIGfrKFuK9vsBgb2W8Zb3GiUhV5imEbH32sZmHtAaUM9h3NCI JGKxMximPalTDvf+OOfLUrtv/BbuWrk5W1PvOdrcCDB4Kf0LWEp/TC7SHWc9r4NTsG J1LNUQB0HsxNbeuOnS6jrxr83dFdQlBsw9HmEFuU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ritesh Harjani , "Steven Rostedt (Google)" , Sasha Levin Subject: [PATCH 5.15 766/913] tracing: Have TRACE_DEFINE_ENUM affect trace event types as well Date: Tue, 5 Apr 2022 09:30:28 +0200 Message-Id: <20220405070402.793652822@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steven Rostedt (Google) [ Upstream commit b3bc8547d3be60898818885f5bf22d0a62e2eb48 ] The macro TRACE_DEFINE_ENUM is used to convert enums in the kernel to their actual value when they are exported to user space via the trace event format file. Currently only the enums in the "print fmt" (TP_printk in the TRACE_EVENT macro) have the enums converted. But the enums can be used to denote array size: field:unsigned int fc_ineligible_rc[EXT4_FC_REASON_MAX]; offset:12; size:36; signed:0; The EXT4_FC_REASON_MAX has no meaning to userspace but it needs to know that information to know how to parse the array. Have the array indexes also be parsed as well. Link: https://lore.kernel.org/all/cover.1646922487.git.riteshh@linux.ibm.com/ Reported-by: Ritesh Harjani Tested-by: Ritesh Harjani Signed-off-by: Steven Rostedt (Google) Signed-off-by: Sasha Levin --- kernel/trace/trace_events.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index dd17171829d6..b35a66a8e7ce 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2637,6 +2637,33 @@ static void update_event_printk(struct trace_event_call *call, } } +static void update_event_fields(struct trace_event_call *call, + struct trace_eval_map *map) +{ + struct ftrace_event_field *field; + struct list_head *head; + char *ptr; + int len = strlen(map->eval_string); + + head = trace_get_fields(call); + list_for_each_entry(field, head, link) { + ptr = strchr(field->type, '['); + if (!ptr) + continue; + ptr++; + + if (!isalpha(*ptr) && *ptr != '_') + continue; + + if (strncmp(map->eval_string, ptr, len) != 0) + continue; + + ptr = eval_replace(ptr, map, len); + /* enum/sizeof string smaller than value */ + WARN_ON_ONCE(!ptr); + } +} + void trace_event_eval_update(struct trace_eval_map **map, int len) { struct trace_event_call *call, *p; @@ -2672,6 +2699,7 @@ void trace_event_eval_update(struct trace_eval_map **map, int len) first = false; } update_event_printk(call, map[i]); + update_event_fields(call, map[i]); } } } -- 2.34.1