From patchwork Tue Oct 18 15:48:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 4230 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp2030582wrs; Tue, 18 Oct 2022 08:53:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4JPJkndIMlQWCC0jNiHG/nWkj4Aew19f5Fl+pVDy9KDN/pegujpMY+cPBbUABMxg8Np3A8 X-Received: by 2002:a17:906:8474:b0:78d:ce9c:284e with SMTP id hx20-20020a170906847400b0078dce9c284emr3116019ejc.702.1666108384504; Tue, 18 Oct 2022 08:53:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666108384; cv=none; d=google.com; s=arc-20160816; b=gbXT3FVUaPs3qNgpeiYaItIsVFko92Mipmhy/PpUh9B9Fo6IQzPGlPbFBD9Hb2SuvQ slK7IFeQHQfulHkO18x6y7ptRjSgyMbiUB8LfqlU0f4CfQYSl21DPhCcyZ2w60xJNfPj lcdcHoDL5JVnWGPORq+wuVdXCc1JFol165DyVHaDP2c3CE5VXOlooiL1EWKS2KCF9VA/ dYM0gDab/dCh9j+FsWE5KMTacGCNIVqlmVTJs2QgVjCpOCnnsmz3dL8est5gTXtKnTgL Tg3mCWv9YoRbA4gVa3HagJlc0ef1vHiZynWSOW69Drov09xeM46h6gQB0GKiv/KeFs/I AhSA== 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=2IEkB12Vcebd10iZRukhl0W5DdqWHvPpb1lm7IXweMo=; b=lcBnn1ttNop+YKydsS002g2GDei2e0CXaRta/PKHV6Uqz6FgdJcfQF1x5ljCE+w+vj e/vrsgo8PSGeD0silpSj5P8IKzPE0xauk+C/JrgTYyoCIq/7GtW2fTGdWPNc2rg+5aU1 F4aAIXAgIJtQzjs9LNEJi/1tX5/XYsqkB2ETGa1JDeitZlwjIGca7pSiXwFF1bNvmzEK 0ddPJzlSYeEY3ARfNeqy9BxZ8GDUA8SOmM0xbQwSQjmDNoQ65D80BdQrSrvaD/90Nx5q lsCPizOebyMzV7UxhTryBE52nb6jg88ef+AkGZzWPi1lwJi70lUQkcP/uCDX9xCWFKj4 8D7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Q/EheRqf"; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g8-20020a056402320800b0045ccd1715d5si11860449eda.435.2022.10.18.08.52.39; Tue, 18 Oct 2022 08:53:04 -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=@kernel.org header.s=k20201202 header.b="Q/EheRqf"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230126AbiJRPsz (ORCPT + 99 others); Tue, 18 Oct 2022 11:48:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231143AbiJRPst (ORCPT ); Tue, 18 Oct 2022 11:48:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25719C90EA; Tue, 18 Oct 2022 08:48:48 -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 C3607B81BE1; Tue, 18 Oct 2022 15:48:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD6ADC433C1; Tue, 18 Oct 2022 15:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666108125; bh=2ROdDPNbkFZUsLCIXz9ZIZxzJTpDkAw3NJo5QjtUD+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q/EheRqfRv/1URudhZBXzJRo1igQEFEg/nwqbGKtUxFv8xYsfwCVtiL/+oNk/QhCO vxhdjFff8eyT5h0n+jBkQTFcIaJY3fgEcCUOzz5hsz7ZUCFivXdX5gqFz17qS0lIwT iWV9tlacEAwbGA6uZS/SOVHiGIRHPNvDxaVIYE1SBBRlLk3hxOQANRWvmxKwEUL1vA dWN1hXDvBZmYCFip4g/RhFK8w86F7NTlyvRNc0G+/hYpN1beLQFGPpqSp0yQ38BwQp FhSijjnOJglVwe9yPFUU5Yrqko0BGtPXGZp2wLDmKD+LX+GPZ7WE/fmC5m6rPzjTem 5ZcWk03WtNSyg== From: "Masami Hiramatsu (Google)" To: Steven Rostedt Cc: Tom Zanussi , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/5] tracing: Allow multiple hitcount values in histograms Date: Wed, 19 Oct 2022 00:48:42 +0900 Message-Id: <166610812248.56030.16754785928712505251.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <166610811353.56030.10023036046735082272.stgit@devnote2> References: <166610811353.56030.10023036046735082272.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747041265153325310?= X-GMAIL-MSGID: =?utf-8?q?1747041265153325310?= From: Tom Zanussi The hitcount is treated specially in the histograms - since it's always expected to be there regardless of whether the user specified anything or not, it's always added as the first histogram value. Currently the code doesn't allow it to be added more than once as a value, which is inconsistent with all the other possible values. It would seem to be a pointless thing to want to do, but other features being added such as percent and graph modifiers don't work properly with the current hitcount restrictions. Fix this by allowing multiple hitcounts to be added. Signed-off-by: Tom Zanussi Signed-off-by: Masami Hiramatsu (Google) Tested-by: Tom Zanussi --- kernel/trace/trace_events_hist.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 48465f7e97b4..13bb7ec45836 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -1356,6 +1356,8 @@ static const char *hist_field_name(struct hist_field *field, field_name = field->name; } else if (field->flags & HIST_FIELD_FL_TIMESTAMP) field_name = "common_timestamp"; + else if (field->flags & HIST_FIELD_FL_HITCOUNT) + field_name = "hitcount"; if (field_name == NULL) field_name = ""; @@ -2328,6 +2330,8 @@ parse_field(struct hist_trigger_data *hist_data, struct trace_event_file *file, hist_data->attrs->ts_in_usecs = true; } else if (strcmp(field_name, "common_cpu") == 0) *flags |= HIST_FIELD_FL_CPU; + else if (strcmp(field_name, "hitcount") == 0) + *flags |= HIST_FIELD_FL_HITCOUNT; else { field = trace_find_event_field(file->event_call, field_name); if (!field || !field->size) { @@ -4328,8 +4332,8 @@ static int create_var_field(struct hist_trigger_data *hist_data, static int create_val_fields(struct hist_trigger_data *hist_data, struct trace_event_file *file) { + unsigned int i, j = 1, n_hitcount = 0; char *fields_str, *field_str; - unsigned int i, j = 1; int ret; ret = create_hitcount_val(hist_data); @@ -4346,8 +4350,10 @@ static int create_val_fields(struct hist_trigger_data *hist_data, if (!field_str) break; - if (strcmp(field_str, "hitcount") == 0) - continue; + if (strcmp(field_str, "hitcount") == 0) { + if (!n_hitcount++) + continue; + } ret = create_val_field(hist_data, j++, file, field_str); if (ret)