Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5128699rwb; Mon, 31 Jul 2023 19:14:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlEDWe62mIdp1ACP4vSA0cszLkLEIFtNS/SRgcW8fAcgsjQ//RWE6wY4gVUdnqLIw1Je9QNT X-Received: by 2002:a17:906:cc0d:b0:99b:dfe5:74f5 with SMTP id ml13-20020a170906cc0d00b0099bdfe574f5mr1189089ejb.41.1690856042292; Mon, 31 Jul 2023 19:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690856042; cv=none; d=google.com; s=arc-20160816; b=rEz8KLkLd5c98/MhTtYVEX/4WaJNdbj6d4hsMT1nfcT4xXXFFDwctHNjmLR8yq14j+ DMzlcrNybqHQK6V0ojP9YjinqQEJ8IS6Ty0Phc7i3uSL+8lQDUPM7f3f9WnaX46qp4FC G4bTUr5wEyBWvh9hBAV9eoXMOc18RUX5bwha+OHXWhq0iSrXmsEt+lwv+nFxXVbJWdtv hp03jkVvoqtQBfOEXVb9lLb1jtYikST+fyM9H2eVDOq3qQLuqEJJJ/ZVW/Rbp5j7vvPR P/GCH9brD5/xmxnZU+mxIhj2lfBmoXvEg+Jtqn3vGQmVG+e57RsN7c8zcrltvxPPPTWU Ywrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=hyXrFrMGa5vDv1JXbFyGkaG6866MRSC88OmLGwPocMw=; fh=RPaymWcWdpuCqECJSI3zyIgg6cBA5CRNntumQh+rM18=; b=GOTt2ZG6X93YoyFc63yjzUk3qYtZCJaDIjAceNfSt1jzr/9JiCcycS5E/NYABOsvjq 5sBsb223zInLyVgb7Sz/5pU2dsLmNC1tQRTLLbbagK2PhZF7SKmVaNkGQLpAvmMQjW57 yPccHWuN8kuN8Vp4zhTv8FXmIJn42bOv5EBp2SDLQ9fP7rTQXNLssu/C3fMPAl3NrP/G dhjtfCSMDReOftB7d6JeWaPmkXAVB1gmakC7LkX55P7sPbWYEFt3jO1R7gL6sR1FBfcO ncRLDJhSxO73xE5hFgDKW5+A387ECpoadOwxPmV//NMGHH4Z4A7L8EmG6ettnmnXJT5i fGFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=VKfZWhFq; 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 pv24-20020a170907209800b0099bd0683c1esi7547043ejb.949.2023.07.31.19.13.36; Mon, 31 Jul 2023 19:14:02 -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=VKfZWhFq; 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 S231834AbjHABhM (ORCPT + 99 others); Mon, 31 Jul 2023 21:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjHABhK (ORCPT ); Mon, 31 Jul 2023 21:37:10 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D56A114; Mon, 31 Jul 2023 18:37:09 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-31771bb4869so5336310f8f.0; Mon, 31 Jul 2023 18:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690853828; x=1691458628; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hyXrFrMGa5vDv1JXbFyGkaG6866MRSC88OmLGwPocMw=; b=VKfZWhFq52c6OvI9vU4cseSRxVuvU0E8af3iFDOR71GbqAD922EXpiKXitjh2F31pu YRzb72EySjkdNdjBUVWbue8Ia5FCSY/Fw5LkdlqqKOO3wxJlrWhFio1zKVKc7lbDUbQO k4uwtClPU9qCjx3QvCKGWrMc2EEuCflgKKc7P0mqkESSHqK2UHCbtdNjW+R5bbS0qQ89 3oPZKiIeAXfOQfjKYJN+/++HQOjJ4ohehQQVOT7bBO8vQ7MU6J/SBLvLzn/+DK8Ie5C6 cFPwW9/k0av7o53A3e68vAaGmzY5Q8Wz9JGQTjAHgGay+vVoMY0+IQW87wZDpO5UeT4Q Da5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690853828; x=1691458628; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hyXrFrMGa5vDv1JXbFyGkaG6866MRSC88OmLGwPocMw=; b=WCnoI1nHGRtxGexylTV2LU94OonH3DbVB16nS7o1v4LCA8Gfd3NlRCjIhFETf9WhO8 wiK0qclbWVmWXlnI9r8PIh3Q2fbz/BDw2SZpd9NVk1qmb7ZqoUln00CnqVLGdSDPpkUC 4AUmUqjLR3Ov8Hfo3y+Ox98HoeUhK2FYNlDf7Vy4AyeM19IkF0TXBHwb1MowDy0IUXuu 9cZAMSaScc/n+flM31Ea0iCRPzkGl8JNE75EyqhIZQ68JcgkTTEyqjqWFyp89jvlxOfs WH3ZeUbGBtfqryqyKfXTRxxeokmvvWUrkxcIAbetkNXSajTilqMPRaLDlM3KxA9Ml8Ec 5Ckg== X-Gm-Message-State: ABy/qLaLMAlXTlrRN23XAaYLAVOK71oFpTm+eb8rLhvWUh5AGCesC1YA orMkzmQ6cGzJ4950hhJthgo/oehvVtwfHYbXFbw= X-Received: by 2002:a5d:67c6:0:b0:317:6f5b:2fbe with SMTP id n6-20020a5d67c6000000b003176f5b2fbemr1047722wrw.69.1690853827446; Mon, 31 Jul 2023 18:37:07 -0700 (PDT) MIME-Version: 1.0 References: <20230726121618.19198-1-zegao@tencent.com> <20230726121618.19198-4-zegao@tencent.com> <20230731114003.43842c8e@gandalf.local.home> In-Reply-To: <20230731114003.43842c8e@gandalf.local.home> From: Ze Gao Date: Tue, 1 Aug 2023 09:36:56 +0800 Message-ID: Subject: Re: [RFC PATCH v2 3/3] libtraceevent: use the new prev_state_char instead in tracepoint sched_switch To: Steven Rostedt 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Roger that! Thanks, Ze On Mon, Jul 31, 2023 at 11:40=E2=80=AFPM Steven Rostedt wrote: > > 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 mus= t > 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_switc= h.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[] =3D "SDTtZXxW"; > > - int found =3D 0; > > - int i; > > - > > - for (i =3D 0; i < (sizeof(states) - 1); i++) { > > - if (!(val & (1 << i))) > > - continue; > > - > > - if (found) > > - trace_seq_putc(s, '|'); > > - > > - found =3D 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) =3D= =3D > > 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) > > =3D=3D 0) > > - write_state(s, val); > > + if (tep_get_field_val(s, event, "prev_state_char", record, > > &val, 1) =3D=3D 0) > > + trace_seq_putc(s, (char) val); > > > > trace_seq_puts(s, " =3D=3D> "); > > > > @@ -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) =3D= =3D > > 0) > > - trace_seq_printf(s, " [%d]", (int) val); > > + trace_seq_printf(s, " [%d]", (short) val); > > > > return 0; > > } >