Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1068727rwo; Wed, 2 Aug 2023 08:16:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlH5VaJWAtwthulgRR/LMS7+RIQjqmHcM9LhJltS5bSGkMmezCBZk4t7acU6k1dEXgzkj5Q1 X-Received: by 2002:a05:6512:3613:b0:4fe:a2e:890c with SMTP id f19-20020a056512361300b004fe0a2e890cmr4109672lfs.49.1690989395207; Wed, 02 Aug 2023 08:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690989395; cv=none; d=google.com; s=arc-20160816; b=WNdNgililyVGJ4H7tqGpKFnxvr5R7yy4WCXTTAYXo0Sw+yqC65im+h/o+kg86dK3ST KggekcuLwdl41HPU1JQof7UR0zmmlknMpaBOZWsHN4qm3nJO6a1BbZ+LyPNBbd+ry4jt P83UC8gD/dV4qFofarsIKJNkAeJTeYkyihrG6lOz14yAih2ccYdOLunZ3FoYCDcH6uh6 iPOTwycK8MSLHT064BF/RiFqBULznksvY31O5I7/2qAR0XPKwghrSE2dGyDFEh8u7Qua UPMg4o5IHyy//cejpNRcrT77Yo6gr8HkXZNrxasguNh2mitYolr4CNQOItTIspJDVZpZ O5cA== 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=/fkgPyAWCZA1zIKBjfkIas5W+hvG6lVuiEIIig6l83g=; fh=+W+h24UyqrvCEgcJUSCSBCwhRFkn2iVTZdPAA+CSSz4=; b=bXpAMS8tc8L4bn1qAuNsscxtfwnQcwHO9V3FRjHGKtQgP3EXQsDPl95cWoMtcVqJUq zBCN7hLYqu1dxR7h45IpGCqRvrSpN4bj75zWohbz/+U499O2BLbhUBkFL9DHHmXUaFSy kkDbx7afduQO8qbSeCP2PDFBd2TFgHdLaxpISzr4eXv+Tk64EIa2z/q5VdnjdDTs6mG0 n+YL0EiQrMp9l9peglh81eRkSVCt/ByUaui9Q48vwq3t6qv4gM8KLvI9VDCGe0UjwSwZ /QF34f4QRHb3uSWjzn8eXV7joxL7Pts9lsnNUbT3ZIhBJ0gIL+V/2wvYeOYIlnvGdeni 0iog== 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 c14-20020aa7df0e000000b005221da34ca8si10247798edy.377.2023.08.02.08.16.10; Wed, 02 Aug 2023 08:16:35 -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 S233924AbjHBPJv (ORCPT + 99 others); Wed, 2 Aug 2023 11:09:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233767AbjHBPJk (ORCPT ); Wed, 2 Aug 2023 11:09:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9C0B3588; Wed, 2 Aug 2023 08:09: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 9832E619E9; Wed, 2 Aug 2023 15:09:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62899C433C9; Wed, 2 Aug 2023 15:09:00 +0000 (UTC) Date: Wed, 2 Aug 2023 11:08:58 -0400 From: Steven Rostedt To: Ze Gao Cc: Adrian Hunter , Alexander Shishkin , Arnaldo Carvalho de Melo , Ian Rogers , Ingo Molnar , Jiri Olsa , Mark Rutland , Masami Hiramatsu , Namhyung Kim , Peter Zijlstra , 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 v4 7/7] libtraceevent: prefer to use prev_state_char introduced in sched_switch Message-ID: <20230802110858.723d0fa1@gandalf.local.home> In-Reply-To: <20230802121116.324604-8-zegao@tencent.com> References: <20230802121116.324604-1-zegao@tencent.com> <20230802121116.324604-8-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=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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 On Wed, 2 Aug 2023 08:10:02 -0400 Ze Gao wrote: > Since the sched_switch tracepoint introduces a new variable to > report sched-out task state in symbolic char, we prefer to use > it to spare from knowing internal implementations in kernel. > > Also we keep the old parsing logic intact but sync the state char > array with the latest kernel. > This should also go to linux-trace-devel@vger.kernel.org. > Signed-off-by: Ze Gao > --- > plugins/plugin_sched_switch.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/plugins/plugin_sched_switch.c b/plugins/plugin_sched_switch.c > index e0986ac..4c57322 100644 > --- a/plugins/plugin_sched_switch.c > +++ b/plugins/plugin_sched_switch.c > @@ -11,7 +11,7 @@ > > static void write_state(struct trace_seq *s, int val) > { > - const char states[] = "SDTtXZPI"; > + const char states[] = "SDTtXZPIp"; > int found = 0; > int i; > > @@ -99,7 +99,12 @@ static int sched_switch_handler(struct trace_seq *s, > if (tep_get_field_val(s, event, "prev_prio", record, &val, 1) == 0) > trace_seq_printf(s, "[%d] ", (int) val); > > - if (tep_get_field_val(s, event, "prev_state", record, &val, 1) == 0) > + //find if has prev_state_char, otherwise fallback to prev_state Use standard C comment notation "/* ... */" > + if (tep_find_field(event, "prev_state_char")) { > + if (tep_get_field_val(s, event, "prev_state_char", record, &val, 1) == 0) > + trace_seq_putc(s, (char) val); > + } > + else if (tep_get_field_val(s, event, "prev_state", record, &val, 1) == 0) This should be: } else if (..) { > write_state(s, val); } -- Steve > > trace_seq_puts(s, " ==> ");