From patchwork Wed Jul 26 12:16:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 126341 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp386323vqo; Wed, 26 Jul 2023 06:03:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlE39PkYZne1RX/k1rrdBAaz3l5uI50WsKUc0Ac7wi0VZmneriwUvdnvh+1pmLaXWTlPZyuk X-Received: by 2002:a17:906:73c8:b0:997:e7d9:50f7 with SMTP id n8-20020a17090673c800b00997e7d950f7mr1792863ejl.66.1690376622934; Wed, 26 Jul 2023 06:03:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690376622; cv=none; d=google.com; s=arc-20160816; b=HHLD24cGDNlLsIC9rEt1zk7pgJmUP4yux7nP7tzvMGLAl86IPPy24Ui7tQcpfY+VAB 15STWiKnuzctQTItNHA7WEORwkn8rF21Oiv9G6E9EwT4QbJhUEYoU1S58DZzltCc3nEi q4MlfLti57whxZA77Ehoo41yjmEl4dbMANQXy6O+PX8WkWBa1DK7MhSaGUBvb6lPw9wR XIlsU54D87OM2ibyJ7Y+KXwVMZIVgHgrJGJGOtKnT+chSV0scIi3b/Xt134PiUUlh7H5 zmUEXQ27FHdaAdj1XYVZV/rjKhbUP0S7oW2rsOCvrkTAqPrbXPl6cXoNHpdgFoab/nis 8lsg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r14-20020a170906350e00b00982c5ee4393si8984751eja.828.2023.07.26.06.03.11; Wed, 26 Jul 2023 06:03:42 -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 S233715AbjGZMQu (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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772488357814672046 X-GMAIL-MSGID: 1772488357814672046 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; }