Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp199796lfu; Wed, 30 Mar 2022 20:38:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTLsheh0+uKhDCOIZ3IV/88Wd55zN547bLEfaTJf9WWCFImaWeg+foj/HZpK5bPyEYS9JD X-Received: by 2002:a65:6941:0:b0:381:fea7:f3d8 with SMTP id w1-20020a656941000000b00381fea7f3d8mr9190785pgq.235.1648697927304; Wed, 30 Mar 2022 20:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648697927; cv=none; d=google.com; s=arc-20160816; b=c3AbMMLL9fB5GKSPVw4vcoX5wVqZD2PPkd5OMnWhYFKVyVfVEFvaerkIv95tfzbJBp 86slM4DOOWQ9s1zSrlhKMmiD1v+N64Ll4HX6YD+pSxbhhW97WYAaX4d3RMlXzzjfmG3n qQf2wLGWDtuPSRBO7lTa4Htq8YbLBzPNrnedqFGZc/P3ZiVSLGG7RIeQa6teoaXWljjN hUtRhVtsLO9i/+nlO94KmKjCNK/8DFiOoWUQvSh285iGtYnkNRIbEFiELt+68PpnVoBZ pAZ+e6/5gVzR8Uwb3fE+TiBo8+n9euu+lb1BwSB0lu4jj1P0F85eEeM+4LRvFbyc3loZ IvOg== 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 :dkim-signature; bh=rEMrzBzKl+4iqC7h6A2IsPRfshLs8Ob2Q89h7oAHEng=; b=TSim6haIxT22rATOv/yfUh+3tlvrPYN1BESIGmu7+U73STH5x15QQt19GPLPS4WW1L 6DYtSwyZLzvD9ACN/4YXbXF3gltVPWMON6vqgwLa7xPmjzYoiSTZJRMmLObonEN5/lF4 ePYjEImYdYqUmrw3wX6AOUJsDaMxzcvkUulvC9C2MMHoms8SGMNYax1kDs0vUqKVPJQa pVG3A1SlU+atpbxJFTzgs1/aKowQkvh/HwyKSg3RLgUAknUdqkt+TaT0ssuHCZtKnBgR c7mdbTEBIzsQJXkU/DHzYaMTXFf1GF/r0ee1/vbP45M0sB7frb4LM85b2vNhPEWYXze+ CDWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LUyNdCda; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c20-20020a63d514000000b003816043f042si22974389pgg.567.2022.03.30.20.38.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 20:38:47 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LUyNdCda; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5E62913197A; Wed, 30 Mar 2022 19:59:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241159AbiC3MJl (ORCPT + 99 others); Wed, 30 Mar 2022 08:09:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344943AbiC3Lxs (ORCPT ); Wed, 30 Mar 2022 07:53:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA14E27CE27; Wed, 30 Mar 2022 04:50:06 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 89CAE6162F; Wed, 30 Mar 2022 11:49:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40850C340EE; Wed, 30 Mar 2022 11:49:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648640998; bh=9EsNKNlIV5Wgj9NPbFp6r6pG57BKyaapFpbFAXDtpLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LUyNdCdab5OMqiTu9XbcIMc5+E1zb3hKswxmeXvqWzCLLBvvmdcOzfMPZqErNZ3DC IpF+G7h35+qiP3NbQexVdBQcPVC1nEu/hbFcXye0Bu7ykeLK2tP+hGX8/s4Y/bi7DI LURaIczov2vPnz8/IBEDCt+7SbLeXlhX5pFskFyFNusqJ7CJh7+1TzizXyqWVXb2b+ G2diUxZysgt1qfoC6i9OY+pAyZPLhPPum2kiN24IYe7YOjC6KKFAIKsWjSSWttepFA sEE3UE9hu/hIeukRiYt0mjAw0Xdyh+cv/cagNL0oS0Fb86BhMnZcVafopos2gpyGrI 1+XWt1pwg/mqw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Steven Rostedt (Google)" , Ritesh Harjani , Sasha Levin , mingo@redhat.com Subject: [PATCH AUTOSEL 5.16 55/59] tracing: Have TRACE_DEFINE_ENUM affect trace event types as well Date: Wed, 30 Mar 2022 07:48:27 -0400 Message-Id: <20220330114831.1670235-55-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220330114831.1670235-1-sashal@kernel.org> References: <20220330114831.1670235-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 92be9cb1d7d4..af4466d69fe8 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2633,6 +2633,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; @@ -2668,6 +2695,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