Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3474751rwa; Tue, 23 Aug 2022 05:29:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR70lGZM4WRfgQQsvZLJTfw4tvyDFXY09FfdFcIKVZA94tpcIO5Utfm3mJy6DTVFaTUXFsCn X-Received: by 2002:a17:907:7f8b:b0:73d:6f4f:30f7 with SMTP id qk11-20020a1709077f8b00b0073d6f4f30f7mr8426803ejc.323.1661257751689; Tue, 23 Aug 2022 05:29:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661257751; cv=none; d=google.com; s=arc-20160816; b=n7ELxymGcdHT3dN4oozFNt4XqE8/7IZz9T4EbJ6J8NrEfm1HeEQ04CZzuGooUMNv+o kiHgzaG8BCiyX2z4/WhCOh6aTHNzNQXa1f7cjux6yNGEtxlPXAOH6wz/dZQlHeZU89MP M11ZI6nQD5wyEWRPw4CGiJpHRFmxRtUHHDVf0wXnLTXtMkkCEkbSEvqx2PtVwwhlyK+Z bSVbua3FcJzJIVQYkDQjYd/pKDcg3CC9aSH7JzELeOf58pBnxoyc0g/cPHu6iOvEqLzC 5ylIolY0d3yccMpJod+7KUfk2Wokjywdp0gyE4of0R/dvMhIOKwOUiEa6PN2lc6ayIxV 7vQA== 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=pRnML24XEstqrQ0XUBpyhhFixwW5k610uJj3cTkWLec=; b=kjY8vBkWq2Qu8zUDa1qnf+oHlcDmiiOZLgEO7cmUTTp2zYy74xh9byMnZ0hUuk0QJr 7wvG8RsLDFUceQiVn2RLjAeh0Vuc5Aptta6kDWPmPOLPdGW5R8o8pdyPW95drRjKC3h7 Cgpovo8jCxsb5wM2SWml32sPvxv9AjaCGYCAZLqq7xRuoeURpwAJPl2sOmZEW8pz07f8 CaU9nd6+pKYCVsmsAzu+1BjLNndtClBTN4Jagu6/mchO+1A1FduIxeVbsuAF9O0eqtSF BEwvFhiFSgPYtfJtk3q3MtGllrkQxMk6cv4KkWlYfrSIY9g448F531n3yimiyfoDmbJD zecA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="FzewZks/"; 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 hu8-20020a170907a08800b0073d6b9d1deesi6673987ejc.434.2022.08.23.05.28.46; Tue, 23 Aug 2022 05:29:11 -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="FzewZks/"; 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 S1353660AbiHWKP1 (ORCPT + 99 others); Tue, 23 Aug 2022 06:15:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352825AbiHWKGV (ORCPT ); Tue, 23 Aug 2022 06:06:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D69D4319; Tue, 23 Aug 2022 01:53:14 -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 6779E6150F; Tue, 23 Aug 2022 08:53:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68C99C433C1; Tue, 23 Aug 2022 08:53:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244793; bh=JJQsM5JWENzuqdyo+/3XXUqAE06ZPzjerTGhvXhu4zE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FzewZks/I2xr6oI7vB/N/h7vl5+nBNFIMYzRDFDolsSvZ0vDtP3xzTjzwejQ4O359 +nFBQX375SvKGs0+iMn5bVz7jrEhpkjIbEr16XU366I8ZgD+GLiC0BLI0GDNRy/nK5 tYrzeuXcDk8o62bvZGKfrCKKUogEYOImDxY0Z/9M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ingo Molnar , Andrew Morton , Tzvetomir Stoyanov , Tom Zanussi , "Masami Hiramatsu (Google)" , "Steven Rostedt (Google)" Subject: [PATCH 5.15 153/244] tracing/eprobes: Fix reading of string fields Date: Tue, 23 Aug 2022 10:25:12 +0200 Message-Id: <20220823080104.290604565@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@linuxfoundation.org> User-Agent: quilt/0.67 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) commit f04dec93466a0481763f3b56cdadf8076e28bfbf upstream. Currently when an event probe (eprobe) hooks to a string field, it does not display it as a string, but instead as a number. This makes the field rather useless. Handle the different kinds of strings, dynamic, static, relational/dynamic etc. Now when a string field is used, the ":string" type can be used to display it: echo "e:sw sched/sched_switch comm=$next_comm:string" > dynamic_events Link: https://lkml.kernel.org/r/20220820134400.959640191@goodmis.org Cc: stable@vger.kernel.org Cc: Ingo Molnar Cc: Andrew Morton Cc: Tzvetomir Stoyanov Cc: Tom Zanussi Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events") Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_eprobe.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) --- a/kernel/trace/trace_eprobe.c +++ b/kernel/trace/trace_eprobe.c @@ -320,6 +320,24 @@ static unsigned long get_event_field(str addr = rec + field->offset; + if (is_string_field(field)) { + switch (field->filter_type) { + case FILTER_DYN_STRING: + val = (unsigned long)(rec + (*(unsigned int *)addr & 0xffff)); + break; + case FILTER_STATIC_STRING: + val = (unsigned long)addr; + break; + case FILTER_PTR_STRING: + val = (unsigned long)(*(char *)addr); + break; + default: + WARN_ON_ONCE(1); + return 0; + } + return val; + } + switch (field->size) { case 1: if (field->is_signed)