Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4625732rwb; Mon, 31 Jul 2023 09:35:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlGKZJXDba/F3yi2b5S1Di9KWfKJjJZqVgnAN4Oonfaosnf81ixozkvWsW21kztB2DOnIdVg X-Received: by 2002:a17:906:3112:b0:988:6491:98e1 with SMTP id 18-20020a170906311200b00988649198e1mr264955ejx.42.1690821334219; Mon, 31 Jul 2023 09:35:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690821334; cv=none; d=google.com; s=arc-20160816; b=NInUKU1uotYcDnRpxokD10VC2Mi++3+1FWDZ2ysgybXF5EWr9Uq2kWpWwLilf+aXhU xt/QnjYZezO7fQkOaq5dhc9SG5Y7ngy5jBkdO7aIReJ70ByWnXKoIxA7MkRVqPffb9Vi mEFXad59W4JsyJAWelRqngW/aIHKMIVRMOvIYHK0RpI/rhybq+nnH+qWyNN+ZIVXy/dj jHOvXEMqswPz8DXsq1xyK/lNwvNChmuoJu17xmRJJS4IhquSNb9GBT82hR7NHpuUxCVo fucHzHtI3XVqJMUeS4WXntUyLHfB2Mqa9ioGehHGWWobWL3Kft5W+/gbZX1dpb2qQTT0 2eIA== 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:subject:cc:to:from:date; bh=92kVC+SSD+Zfl2EtlkUYdnZT74jEA4p3LGyZi9+yNIA=; fh=cnEp3uneTX0s3nC7QmIskh9dxBXTfoLKll/zh5qFxak=; b=r8TOR2kanr00x33qFpsaixla+9M7FiBcM6WD+Z591KBKp9iOB/MztognUjpAiYYsr2 l4KQaxGCp4As1HKtzKxKdbDU3RKbJO/rSIF1I4YPJSXHZCo3ynwkKD4NzHzfNss9MNnK QhFxeny/mtJPUHqQJMr4RLYgoDgcmE9QFWE4jBMGTOpAHwD5EKr5CX2plbzoj+fvOscW K6zYEMfVx7lCQUIl2bMZ31mNi9yOqjuatwC5oeoDoiwy77244yUaMTzY5X7lJ8INhaNJ TSbHI4hN62RhXsZ7AXQAJhHCF8UGbp/wONo76I6/u5uBHQkEIUre5MxdgrSU6ZiypSMC u27Q== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rl19-20020a170907217300b00988f21df36esi7185309ejb.594.2023.07.31.09.35.08; Mon, 31 Jul 2023 09:35:34 -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; 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 S232052AbjGaPkR (ORCPT + 99 others); Mon, 31 Jul 2023 11:40:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230511AbjGaPkN (ORCPT ); Mon, 31 Jul 2023 11:40:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E041198B; Mon, 31 Jul 2023 08:40:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 149D9611B9; Mon, 31 Jul 2023 15:40:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82B8AC433C7; Mon, 31 Jul 2023 15:40:05 +0000 (UTC) Date: Mon, 31 Jul 2023 11:40:03 -0400 From: Steven Rostedt To: Ze Gao Cc: Peter Zijlstra , Namhyung Kim , Adrian Hunter , Alexander Shishkin , Arnaldo Carvalho de Melo , Ian Rogers , Ingo Molnar , Jiri Olsa , Mark Rutland , Masami Hiramatsu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org, Ze Gao Subject: Re: [RFC PATCH v2 3/3] libtraceevent: use the new prev_state_char instead in tracepoint sched_switch Message-ID: <20230731114003.43842c8e@gandalf.local.home> In-Reply-To: <20230726121618.19198-4-zegao@tencent.com> References: <20230726121618.19198-1-zegao@tencent.com> <20230726121618.19198-4-zegao@tencent.com> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Wed, 26 Jul 2023 20:16:18 +0800 Ze Gao wrote: > Since the sched_switch tracepoint introduces a new variable to > report sched-out task state in symbolic char, we switch to use > that instead to spare from knowing internal implementations > in kernel. This needs to be changed to check if the "prev_state_char" field exists, and if not, then it must use the old method. Same for perf. The tools must work with older kernels. -- Steve > > Signed-off-by: Ze Gao > --- > plugins/plugin_sched_switch.c | 29 ++++------------------------- > 1 file changed, 4 insertions(+), 25 deletions(-) > > diff --git a/plugins/plugin_sched_switch.c b/plugins/plugin_sched_switch.c > index 8752cae..5dbdc28 100644 > --- a/plugins/plugin_sched_switch.c > +++ b/plugins/plugin_sched_switch.c > @@ -9,27 +9,6 @@ > #include "event-parse.h" > #include "trace-seq.h" > > -static void write_state(struct trace_seq *s, int val) > -{ > - const char states[] = "SDTtZXxW"; > - int found = 0; > - int i; > - > - for (i = 0; i < (sizeof(states) - 1); i++) { > - if (!(val & (1 << i))) > - continue; > - > - if (found) > - trace_seq_putc(s, '|'); > - > - found = 1; > - trace_seq_putc(s, states[i]); > - } > - > - if (!found) > - trace_seq_putc(s, 'R'); > -} > - > static void write_and_save_comm(struct tep_format_field *field, > struct tep_record *record, > struct trace_seq *s, int pid) > @@ -97,10 +76,10 @@ static int sched_switch_handler(struct trace_seq *s, > trace_seq_printf(s, "%lld ", val); > > if (tep_get_field_val(s, event, "prev_prio", record, &val, 1) == > 0) > - trace_seq_printf(s, "[%d] ", (int) val); > + trace_seq_printf(s, "[%d] ", (short) val); > > - if (tep_get_field_val(s, event, "prev_state", record, &val, 1) > == 0) > - write_state(s, val); > + if (tep_get_field_val(s, event, "prev_state_char", record, > &val, 1) == 0) > + trace_seq_putc(s, (char) val); > > trace_seq_puts(s, " ==> "); > > @@ -115,7 +94,7 @@ static int sched_switch_handler(struct trace_seq *s, > trace_seq_printf(s, "%lld", val); > > if (tep_get_field_val(s, event, "next_prio", record, &val, 1) == > 0) > - trace_seq_printf(s, " [%d]", (int) val); > + trace_seq_printf(s, " [%d]", (short) val); > > return 0; > }