Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5474811rwb; Tue, 1 Aug 2023 03:16:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlH/IgdVmFVbV4wjzwIsH5G1CgOVIGnCzoLmRNs3CN1zjbaxSAoWt/LRCdigQz5PbZ00loBm X-Received: by 2002:a05:6a20:914e:b0:122:10f9:f635 with SMTP id x14-20020a056a20914e00b0012210f9f635mr12954401pzc.19.1690885013602; Tue, 01 Aug 2023 03:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690885013; cv=none; d=google.com; s=arc-20160816; b=Lu2c+ZlvlVef7r2owH5S7t7/NIlgUX31qZEXZyUZmpVi5LN0JLKLOOw+Zd97PAHLMD AUVJp752uht9RG4fqdzm2VjMAqGjy7Jm8zlvVUODjkv88p4rv3AZXH6OXjv+Hl/a/K4J kaQRbq5hlSNuANSLzZrFHG/i5sLimjrt3c9SpKwjWlwksGLN1LAbd0ZvhI9BEP36HOhA 238tLwGfFBxHTVZ4cUObpBB4viY9oQ7JlKnMWLeMvNtqDCW1+cTgWTgIedlq6yJklF1p qguy5mabvDluInTzWbaDAZrTrdcOjas8tZtAGJvGViFdG/4G4+N7sPflUzPLN7rILR8e uEvQ== 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:date:subject:cc:to:from :dkim-signature; bh=w1czaeXwKPoW79DQXCoJFC1V8bFxJyQ215iwxz8lUyU=; fh=4S4dukURCUlSsjzSa0Ofy3qHSrrdu/uT1HnGBPj5BK4=; b=BSse506fX3l8AMKdZYnHhSZCFLt5MAyw3pJh8bEKisU9kRn6wLWKxdrO6hF23HPoGk z5bDifhMRt+1EB6iWpW/7y86dvJgz9CBn/Mh5g82qGK6jVf2owOrHmBsRggCwdENkiU/ Qyys0Z7Paaypgg/eg6nAo6QazodsM4ywW6RBbN/Prr5TLFh4iXqZmZea8vnC0GKtpYYh aI9K4wobMOtbqYZEMEKWtGHB1AfPlKYr8/aRwnUTrtOHOYe26Gs2lMr00EPloHTeZHq3 HajFvuY0W3F9admtxyDr4+Q0OJunuCbtAFGxmt9YfW725pzFb/eKpV+VZwfCi8jgVM1e YgHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ms8c2ZbB; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kw7-20020a170902f90700b001b0450241d1si1865436plb.283.2023.08.01.03.16.41; Tue, 01 Aug 2023 03:16:53 -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=@gmail.com header.s=20221208 header.b=ms8c2ZbB; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232429AbjHAJCe (ORCPT + 99 others); Tue, 1 Aug 2023 05:02:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231949AbjHAJCO (ORCPT ); Tue, 1 Aug 2023 05:02:14 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DEFB2121; Tue, 1 Aug 2023 02:01:56 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3a3efebcc24so4104504b6e.1; Tue, 01 Aug 2023 02:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690880516; x=1691485316; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w1czaeXwKPoW79DQXCoJFC1V8bFxJyQ215iwxz8lUyU=; b=ms8c2ZbB4R4fcbOy+mUJuwgXu4e0yufWtAlHMDXY2WnBmnyeTwE7ArkyOg6QsjA2bF SFuuk5Az0zk8szoQauYILOraZ47zU/hlFz++Kexz1kHY7bRL5ni1Q7n2u0vma1bhrKcx 9is5gEAYNI8Q7DXpoPBNDolyn3ifDb+Cswg7wY6ws96ts/SHMg7sXLMaBIx6NHz8eA4x IiW+VBQfO6KbRqBTLiKIqqnLAa+MoQil/+hq8vda8g3cCzy8U0SgyUK+PfNSBjd1m68g PZnJjsRC6jhWQm29Eo9oSg0WFrasNY1uIsqDwVxjf/q75cC/ICsVPyEhobGM1jBNjrCH MOcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690880516; x=1691485316; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w1czaeXwKPoW79DQXCoJFC1V8bFxJyQ215iwxz8lUyU=; b=aWBV2NJ9WTJ7m5VPHRi50sDgRREdhC84t+HJQoKN6hegMFAGhL13iGVHt/AqtOibhd segJb3lyOYaoXDi0S2NbMf2ZkudZyupzvsXO5mImsYz5eewNUlhS6Q9+9fnmDwbXzict zlIQ17lPTHWgiZzGihJQ+dJxV51PKMkv+510CEMopK0IV3lMoSzBIlDGX7PocvYp/nEd JZBB31t6K5fnnrkdnlQNjRt0t56Ua/y714yFrPYFo4By20r68C8byH+OB1Y/ILOP3Y/L /bveExIat7XcD+X+4NFS3mOmVSHEpYXh9vfjbnHodoZU5Noo8nu0OKceN1+oQK3COib+ 05Wg== X-Gm-Message-State: ABy/qLa3M5vnEp1eNchkDI/3EVhj7Gwwp2eRXojbqhxQ1kB7F4Cv0rrO Jo8IfQND0hbaA1MChE6P1mA= X-Received: by 2002:a05:6808:1595:b0:3a7:4e0c:faa9 with SMTP id t21-20020a056808159500b003a74e0cfaa9mr910611oiw.29.1690880515818; Tue, 01 Aug 2023 02:01:55 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.20]) by smtp.googlemail.com with ESMTPSA id x34-20020a17090a6c2500b00264044cca0fsm1592523pjj.1.2023.08.01.02.01.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Aug 2023 02:01:55 -0700 (PDT) From: Ze Gao X-Google-Original-From: Ze Gao To: Adrian Hunter , Alexander Shishkin , Arnaldo Carvalho de Melo , Ian Rogers , Ingo Molnar , Jiri Olsa , Mark Rutland , Masami Hiramatsu , Namhyung Kim , Peter Zijlstra , Steven Rostedt Cc: 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: [RFC PATCH v3 6/6] libtraceevent: prefer to use prev_state_char introduced in sched_switch Date: Tue, 1 Aug 2023 17:01:24 +0800 Message-Id: <20230801090124.8050-7-zegao@tencent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230801090124.8050-1-zegao@tencent.com> References: <20230801090124.8050-1-zegao@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,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 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. 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 8752cae..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[] = "SDTtZXxW"; + 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 + 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) write_state(s, val); trace_seq_puts(s, " ==> "); -- 2.40.1