From patchwork Sat Dec 10 13:57:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 32032 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1328722wrr; Sat, 10 Dec 2022 06:06:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf56jQS1T+EfHnJJEbJjuIC/0ZhYKo3vgE8DGuX31u19usVuW3932aolYtim7D8+RSMN4Shb X-Received: by 2002:a17:906:c04d:b0:7bb:d6d5:76ea with SMTP id bm13-20020a170906c04d00b007bbd6d576eamr9223574ejb.67.1670680827866; Sat, 10 Dec 2022 06:00:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670680827; cv=none; d=google.com; s=arc-20160816; b=ija8mx8E8dtRGIio7IHzhRQ/F/xJ6dKmYMhlN9Dkqeoo433AJkj4lvW/5PCN9+17+n FNNjhBgeVHE6tmsHI/ma0GDgsV1gK5P6df87FN0oEAsReqva6kV4eD/oJnRJlO6/Xyi0 84rv1HovBu70Cn17dP+QNJU6rWEku2DOwXpZUVd1cQW0s0q+SuJqJFhqIAEQyxvbByQE gHPKFJ60UapaVAlqi5vDsS5D0EEfjcyRyazg1kBX/hsVBu0/RY7T6IRStAm/NORohsXQ Nmmr+FAmzQd31dEUeQ4Yok69d9t+dcxu3ROVwpz1Cc+/ejfx1XWKMOJTWG2CS3FbV3gB mviw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id; bh=McKbEzV2o2vj5WtRmVZLXgqMq/i0c2rvJVF1fwgbiEY=; b=lurWCs+TORal1W48EUEga6kOEIKNXGG26Dw27ADnuDcCp32mUWpnPDhPXtaHbQUi1X ojY+BBy/hvNWHCT8zqwAt97Wvd3Y34SVvhvebe/r+jjUec4cfoM2SsoTUgjLqTSum4NS COg7DyPDZ2I1FiQ+/usb6KIEJomQAxf5XghGV0ErXCyueZfJjOP2hZWNUWUm7YgEdtN2 1yiKRKUD7/DB6SW1WImYaSowSHWOZ+D89HHe8Ju/5S9s/8iLI7W5PXLX00ZHh41M3rzD bR/H7tHtXGq0WsqWlgBG46nJl4hahzywBK9ANzC8y+xeGGT95eD0Rnx9Ay4aUnlpJqtU maJg== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz12-20020a1709077d8c00b007a6c5a23a48si2246965ejc.551.2022.12.10.06.00.04; Sat, 10 Dec 2022 06:00:27 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230078AbiLJN7Y (ORCPT + 99 others); Sat, 10 Dec 2022 08:59:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbiLJN63 (ORCPT ); Sat, 10 Dec 2022 08:58:29 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97B2616599 for ; Sat, 10 Dec 2022 05:58:27 -0800 (PST) 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 478A7B82A81 for ; Sat, 10 Dec 2022 13:58:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 080F2C4339B; Sat, 10 Dec 2022 13:58:25 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1p40Mx-000kmO-39; Sat, 10 Dec 2022 08:58:23 -0500 Message-ID: <20221210135823.843880038@goodmis.org> User-Agent: quilt/0.66 Date: Sat, 10 Dec 2022 08:57:54 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Andrew Morton , Tom Zanussi Subject: [for-next][PATCH 04/25] tracing: Allow multiple hitcount values in histograms References: <20221210135750.425719934@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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?1751835819761085644?= X-GMAIL-MSGID: =?utf-8?q?1751835819761085644?= 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. Link: https://lore.kernel.org/linux-trace-kernel/166610812248.56030.16754785928712505251.stgit@devnote2 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 1c82478e8dff..31d58ddcc1d9 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)