Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp680483pxb; Tue, 5 Apr 2022 18:30:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5UEDy/rr1QUnzdNltxeKxv1SK8nIqm+gSpitp7kBgLKZZ+bItGWOdli7Cz+Ni2xlEPwnp X-Received: by 2002:a17:907:da9:b0:6da:beb8:fdac with SMTP id go41-20020a1709070da900b006dabeb8fdacmr6044436ejc.364.1649208658983; Tue, 05 Apr 2022 18:30:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649208658; cv=none; d=google.com; s=arc-20160816; b=HFMTgY8+65K3/b4LUN/o/Pvf8if5jJgnngNM/N8oBj7cdvIUpuQuvnWgZoD3hZo0Wf GdnqMWcZPH4gM/Afak1fnynmz7f6qfFj0CZegZXxdaFjEGjZowG2a0s1z37RTQT83RdX g6EjuhTErUjkNRbD0BJALognLvo4cN8ZCkiyOhXT1xVxphgrR+hERKrv2tOceiGK+KhJ 9k0z+fC3jDUsp2TPPLp0vzE0ROK1ueLCx93evPU8+z5fmw9IeEd/zi0WiNBG387zu7fc PbGzDBKWFVGbjWLoqXA/hwy2ixRUb8UDN6sXBKzNCFrW0trBFe1duxLFA3LichKcArsH ryUQ== 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=xnpjklKvl3K8uYbFHCLl5RSl0e6gOXxLXWmXF4twYeM=; b=P4cuk1qF8aI8pDIefckETJSz4qA2ZXhqpUNR5FFnSUwdbhmu6dWwTjXULqXjcIbhiM xEHjzYuU2A/rh6iHBAwKK68+MVhDG7ncsXYzr7HPyOXE2p7/IdE3Y5UxANHUWoeFqYLj ckzqB+YXuwQ6zfYQ3Iv+76K6EYXViCv45+sTwYI7pDJNtJFQ+y0xc9NZcdTz7OjePru2 vL7Vmkk3KfZiF8NbTwHeZCa8+Guh0udiLOP0N9VCiJlD3yVDimMkXqjXpEJRPi8Sczgv SfaMUQEN9tT3ML/642fxNlSUXosWgvsjIEXzFBsjuw72eX1YnjxS1mQnokT3OdqH2sOo mRJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EwbPD11V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cz26-20020a0564021cba00b0041ccec68261si5703354edb.448.2022.04.05.18.30.26; Tue, 05 Apr 2022 18:30:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EwbPD11V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352797AbiDEKFJ (ORCPT + 99 others); Tue, 5 Apr 2022 06:05:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238545AbiDEIak (ORCPT ); Tue, 5 Apr 2022 04:30:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90CF8DE91; Tue, 5 Apr 2022 01:22:26 -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 3170BB81BBF; Tue, 5 Apr 2022 08:22:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9774DC385A2; Tue, 5 Apr 2022 08:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649146944; bh=wsdO9d1F6uTe7dSW3RYVQHBqDtUksx2aJMjLKfL3E1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EwbPD11V9VfUbOdV3qRpdmu/E5+0/LKlo7kitKnka6m1LWVhzesj4W0SSwnMiQwwI fZnJOJvgKR+pEQT6KKOra7EIhEVFk8wtGG7FZWu1PcGws32NaKVX/z16bzJuCOKGRR zB6DbYfmhmtVV7NjrTA2SC35dLIWw/Ma0s42kJF8= 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.17 0945/1126] tracing: Have TRACE_DEFINE_ENUM affect trace event types as well Date: Tue, 5 Apr 2022 09:28:12 +0200 Message-Id: <20220405070435.246395977@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 2a19ea747ff4..f382ac9597f2 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