Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp956234rwb; Wed, 26 Jul 2023 05:41:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlEdjKxOGz45vIyiRn5ReTjxLrxaLJeQ6kMc+AuKUQ7xa52Gkap1OhiPExfEJ+XuqQiH1XW3 X-Received: by 2002:a17:903:181:b0:1b8:a389:4410 with SMTP id z1-20020a170903018100b001b8a3894410mr1601050plg.0.1690375316038; Wed, 26 Jul 2023 05:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690375316; cv=none; d=google.com; s=arc-20160816; b=zq6b1X4rsyPfukvPrNqEQ7tNf74f5nw8+IrTy+7IZvHdwoTQ+t03wihjEYrkmWcro5 lzBa1CtUasqwRlAi/GtSBtsLDPvQxDD4KZ0t1JRj0GxZt2TnDy/pA7kN2K7em7zMCcr3 r5GJMcON+eaqUp/4LFjAF5qYe2zEh/7fM/YYDawRo5kLSKaT2jS3ctIIxpp89Y6ibXu9 7aDx5yTe/3q7unFOp5jgIXNvq0aldI49PFZt4dPAR5Q4QitZJyv+P4w7U3iZUl7ihU8l +XpKu8jDHnNa1eCoBTkAJm9ppsuhmRyMYNtS8RO7k1nSlp7Nyr+TOea4/iYHXqHnR0O6 IlGA== 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=PzcxxlbFJ3XgasuaSW3q94g6VrQbmuetHpQHuGg7FzU=; fh=bdj1owIhHCrd5hN/dHRLD7g8I8CgOAzvEwVKQ1Hbjho=; b=KaoghJWbL34wgLly4My3c7xVuVBK262Aj8kE6wuZgC/aPB1jDKfPDfQ1pCk1Z/DH++ Q5q6nxkA5k6xlPrUab404XLVSHjQSkc9BMChSaEwId+OgeAKeHLkkGlDO5viCLHzmcwJ WMEXE3mlOEv/X+0WFzLAwbBK3okt52Jqd+zbj4FfajjnBL5bCsNmtJyJKgmPe1PBO7kx SM/gSc5JCAi1XRYCzs8MU+02A6VDXnFjI/U6CjU5cJqtr1fDAJ2LHgvxhCYlDUNeq24K N7ANN1GdWSZSQQEubqJ7pbFb3teQwKSwH8V0IFgLxe/IeY9ca5Af6azTeReipaqImHH/ WtKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=jWr2FVUN; 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 a13-20020a170902eccd00b001bb9d64f01fsi6925518plh.85.2023.07.26.05.41.42; Wed, 26 Jul 2023 05:41:56 -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=jWr2FVUN; 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 S234252AbjGZMQu (ORCPT + 99 others); Wed, 26 Jul 2023 08:16:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233645AbjGZMQq (ORCPT ); Wed, 26 Jul 2023 08:16:46 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D37C82698; Wed, 26 Jul 2023 05:16:39 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-345fcf8951fso27553145ab.1; Wed, 26 Jul 2023 05:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690373799; x=1690978599; 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=PzcxxlbFJ3XgasuaSW3q94g6VrQbmuetHpQHuGg7FzU=; b=jWr2FVUNFVAj8c4IATVZ7wOpIy5pyYjdrKhq1XnaRhW1LWqd5o94aebPTcPg6y62Zn VxNeDdLGwitNL9vOKacamAgjsVgGmOwgKaY8yKEuJw+kiQpcVhKdjipI7lNgvxUadI6A m/NriPfv8n0kFYHkjwWYwtNO9qxJbYBovyrRAU7lQxna//uxQHpt3hw6dd1Cyf7SKrGn zCJHJVqTSsdFLb1rgn/ipwTkz8Iv9tIwjJtTdrk5wtLOCZgT1LP+tqWwLG6dkFR3h7p+ zVd3jQOvAQdgI6DPk6xKH9DRtETNMBLvZmDvky8v/gTsWHa8EzwJlDRaUTbEAXH7PCGB t44g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690373799; x=1690978599; 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=PzcxxlbFJ3XgasuaSW3q94g6VrQbmuetHpQHuGg7FzU=; b=L/+6VjyMA6Sz9Ygb9VK9HglL6HyZ9nZGjBqlGu9Qw5kbavuZldbXcCRNYDnCXR32Hu ifyCTnFbtumRyOboe4UOyxE1MCEfPGoBwpGZZqqbSWIeh4OKTx18ot4AW8ciXBMsZj9k 9pKUxY5RpYmYnYO8x5auZ1ARym/lHyzW7LORI1qMFCw4cESOERJckHZbdoHSOj5/WCTx uslaCtwnH1i/ldcYdTwJA76RF7K3akadaVrHRAX7tijYXYBu/teXnz7wAzBHemDaU1s0 MwovRIoacdDWdeKwEPWLIBp4k1ts772nDP/Lz66x7i0vRR4AEO2sbHWOGPL+p/wyrJw0 GY+w== X-Gm-Message-State: ABy/qLasiJQSFIl6rJto0b98ukAz5rmYWcAfkNzTE5ZD0JGz5w6gkI7Z sLP/KfkWYz2/scbFdIg2s9U= X-Received: by 2002:a92:c549:0:b0:345:8373:bf68 with SMTP id a9-20020a92c549000000b003458373bf68mr1969298ilj.25.1690373798957; Wed, 26 Jul 2023 05:16:38 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.25]) by smtp.googlemail.com with ESMTPSA id ms19-20020a17090b235300b00263f446d432sm1172880pjb.43.2023.07.26.05.16.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 05:16:38 -0700 (PDT) From: Ze Gao X-Google-Original-From: Ze Gao To: Peter Zijlstra , Steven Rostedt , Namhyung Kim Cc: 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: [RFC PATCH v2 3/3] libtraceevent: use the new prev_state_char instead in tracepoint sched_switch Date: Wed, 26 Jul 2023 20:16:18 +0800 Message-Id: <20230726121618.19198-4-zegao@tencent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230726121618.19198-1-zegao@tencent.com> References: <20230726121618.19198-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_NONE,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 switch to use that instead to spare from knowing internal implementations in kernel. 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; } -- 2.40.1