From patchwork Wed Aug 2 12:47:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 129832 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp455799vqx; Wed, 2 Aug 2023 06:26:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlHUlVH9VNRYO3ATOk8veNQq6DJOI+Nx+E+i8MCTqRXW22N7O1igjVqS/b2rDXJXavSXK/oY X-Received: by 2002:a05:6512:46d:b0:4fb:99c7:bb60 with SMTP id x13-20020a056512046d00b004fb99c7bb60mr4304810lfd.59.1690982809952; Wed, 02 Aug 2023 06:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690982809; cv=none; d=google.com; s=arc-20160816; b=d6tYwPHuNFPdlAEZ5mwJz2XOc8vr7CwM7Z6Jz+T/iCSFsPOrOVYAnSzrg+b8u9Jtfj s5A7oTrmemIIonMk+r79TqBuZGDXi0Co5yWab14HdKmAwpJVt8VW6tpaKr8l1A+YCh04 Rhct/3ygqyzzwC7+Gm6g/l8mpdw6U88JIzd1Cz93HOufLTdPAd829CogwIQ7Deo5atPS UWuCoPDuIeY0GB/POsMcaArZ2tU3y77fveglJ/d5s1aE/eYgGOz8mcabePmtHhgvSkOe sXDJRgR64q3nn18AQGz8SsAYKm6UKP7wApxQQKySlquGIzzfoBXcRISM2KkpCE1RSDsi J30A== 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=u8lpjzm6rHULKX3RnedYfP137m4qvGL5uKJaH+JzOyE=; fh=4S4dukURCUlSsjzSa0Ofy3qHSrrdu/uT1HnGBPj5BK4=; b=Xr+Fkg2RSWXeIaUsTYmZ3YVcu86LFHzM3EOkT2FY8IMkWicHhsXPzLRH6P4Ah0g9Ad O4uGrapP+k8NO7AU9ce4BzkGqHNnHW9Ej/sHVhN6DzQtqnzdl4gThZHt8SZbvIlMIogJ 0TjAmaKSqtzi2lQV+JHQOLhu9jzuiyJxjY/oW2EG8eglXoArx12THas5zdCX+dtLXMMW LE9D/fo8clIc6dw/IEWkFxw8+3V7WNZRND3Yg61VIO8l155OZ4EFy/rJVOt2Vuu2ntPY qODsOogC7OP9MuQ4v4NOy3c8hA2nQFtoiiaZpBfAAqk7FogRo+nfiQIKdt2S52eRWjUo n+Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=dsOEdkUx; 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 lw15-20020a170906bccf00b0099bc8469e26si10126673ejb.923.2023.08.02.06.26.24; Wed, 02 Aug 2023 06:26:49 -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=dsOEdkUx; 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 S234754AbjHBMtR (ORCPT + 99 others); Wed, 2 Aug 2023 08:49:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234818AbjHBMtB (ORCPT ); Wed, 2 Aug 2023 08:49:01 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6057830C6; Wed, 2 Aug 2023 05:48:52 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2683add3662so4705778a91.1; Wed, 02 Aug 2023 05:48:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690980532; x=1691585332; 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=u8lpjzm6rHULKX3RnedYfP137m4qvGL5uKJaH+JzOyE=; b=dsOEdkUxZ1tD0QOsLdlp1zsXXHcieudYGt0U2fn/8f2w/6NdSK5Nom90sLaMCS79VO LzqM7DSiv3m8Hwx1t07Zp19pmLFJJP2zZ9CmQCc0FSGxAQYwSJ2UM2Wz7IX8t5y7cvht /VJGkDkDYaZ1Z/vu0FhjBcDt6WKWLEY26NZ83tqM5JGm3h8Z0GleINZTIljljgp/xkGM WPxbr793xnvOXWGTd3A+7KkbCjd0N94kwA5ZIW7s8roJg6Z+Es0YwTH4qsn9JpljLHUv 9t126fNkmkPiX8RijOxRbPQAI1E+2Pwmza6sfmocbKLSsYEILpRw/DSffy3zvmN0xLcc kZBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690980532; x=1691585332; 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=u8lpjzm6rHULKX3RnedYfP137m4qvGL5uKJaH+JzOyE=; b=EEU4+lsvkd7NInan/4M5KbL5Hxqiehvl+xqT0PvTqLf4xmKeUNtGIf0KhgD6lfH8w1 qHXlL7As0k2B5XxObHjDqzFZPgWVzsClGIQG1EwiqMc07f4WjxgTCp3hi0+4U5YUDV6J FMM3R8p8obuXaJa7xsudoab1kOdjZj63zZhF2hmATzLkBJz1GqAOip3Bs5tsibN9Z8Qe SEE6qSUmiHrT5WUTv7TQydtvjnuwWD4egwf5r8phMOXrRRNveBa0Ot8qP/w16Q+Svdv3 MB+fuHN7qE4Gt472HJEJSKOfgYJId0zalJ+bBiE7gq88jDGxsds878V41yn23GjWaO6N PDZA== X-Gm-Message-State: ABy/qLaAzkBBBuxFJhMR52rfCxoVNcDKuL3yi1C/QGP7ocgJgBHnGyFm DL+nm07c7jKrhSty44qUTTc= X-Received: by 2002:a17:90b:4a8d:b0:268:1217:46bc with SMTP id lp13-20020a17090b4a8d00b00268121746bcmr14634627pjb.11.1690980531731; Wed, 02 Aug 2023 05:48:51 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.17]) by smtp.googlemail.com with ESMTPSA id x34-20020a17090a6c2500b00264044cca0fsm4811993pjj.1.2023.08.02.05.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:48:51 -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 v4 1/7] libtraceevent: sync state char array with the kernel Date: Wed, 2 Aug 2023 08:47:24 -0400 Message-ID: <20230802124840.335638-2-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802124840.335638-1-zegao@tencent.com> References: <20230802124840.335638-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_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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773123990610877924 X-GMAIL-MSGID: 1773123990610877924 Update state char array to match the latest kernel definitions. Signed-off-by: Ze Gao --- plugins/plugin_sched_switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/plugin_sched_switch.c b/plugins/plugin_sched_switch.c index 8752cae..e0986ac 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[] = "SDTtXZPI"; int found = 0; int i; From patchwork Wed Aug 2 12:47:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 129827 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp451738vqx; Wed, 2 Aug 2023 06:19:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlHjmxUqMM4mbHzjV+1WMkNfTzFO7wZIGVy3RcahMQVjuPDfj1o0D83nhMQZQU51ZEtePpBs X-Received: by 2002:aa7:df02:0:b0:51e:2282:e1fc with SMTP id c2-20020aa7df02000000b0051e2282e1fcmr4878397edy.6.1690982398971; Wed, 02 Aug 2023 06:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690982398; cv=none; d=google.com; s=arc-20160816; b=JCuJG0Unvenq5qo1J8EEDD/ZomxPcfarXJv71V4R2etN22+nd1EAp7t5RLgk8062ZM QPFLH/k2h+E4qeGfe+97lRB71ThKTZI3r7k8V2hSKMj55ilvbgLKRMkAorrBwtDaZ6Sk 2k0Z2VCyGNHjlkWW9hLPIkyQ8h+5ebBVhWsr6a0EuirFf/ZWNSahqqAaYs48UtHjqxg9 Z1+O1HwL88lDvu0RnjXnRUQsKVKh4kkt6XKbSKoNxwza0jeER50LoiF8YRfIAPtkrp0e jGLI2h0AXqx3UjW4NIvoaVEvz/KBoRZYE8lQV6GOWj99CRSbBzdJW0llbyRXsfjIlQUh FWBQ== 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=CzdBr4YE6+e2aCPihxyG1VP6AlkYIgUBNXtEC6jGkqA=; fh=4S4dukURCUlSsjzSa0Ofy3qHSrrdu/uT1HnGBPj5BK4=; b=JVPHzg/MdtsUR76DUqdGw/wqEg4Fie2EZsFiFj7cVuC0ggQx4sbR9IIch7NhF4juMW SUKRmgkLrOkqOpL8qtlNNWCG3dQjormUgzC0MMSWfbzl+MnBgf74RrH5Q96z4bTtyDmj 86gJx1yil//G7olOnuZ4tzZGQBhJy1OAw2yyz2DT0iI0Xqci03MB6XKhixVoHBSCJi8r eVNCW9k8U8tG83R67SYSqi7RK1pA0r7i7j8GhAl+ittFK/rDm35QXygMTK6Sz5jTWU1S p2+/PNthK/Ix/9TBP4WuOrcnbw+U1LD58Ii3DVdWEzy7usApXkeyTl3i1azsgOBmVba7 q+IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=affZwz5T; 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 p21-20020a05640210d500b0052241ef59b6si10597710edu.317.2023.08.02.06.19.30; Wed, 02 Aug 2023 06:19:58 -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=affZwz5T; 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 S234882AbjHBMtW (ORCPT + 99 others); Wed, 2 Aug 2023 08:49:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234777AbjHBMtI (ORCPT ); Wed, 2 Aug 2023 08:49:08 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D46C73581; Wed, 2 Aug 2023 05:48:56 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-56433b1b12dso2361239a12.1; Wed, 02 Aug 2023 05:48:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690980536; x=1691585336; 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=CzdBr4YE6+e2aCPihxyG1VP6AlkYIgUBNXtEC6jGkqA=; b=affZwz5TEk3WIR+PRuKQAQZIq234JaxujRitv/TmpCwQ1HiXjIUtfisiW6PsYsy2WJ z6H0HlNkN6qsdwiaIFnFaobjoGoPPbfnfQa2cqi9nAquKLz0X0Sd+ooFwFMDR1WwHPpE pegy5hefVZ0Zy/SPcKkxFZb9N2evvh0O/0r1N+JlU7TJwXsjTtL+sVl1K6fuiX37ABsg Jgs1lA22+oPPSEB0BqL9BVhE8KM78m2A56G8LPKum4AWTZOoDp719Fh5p5bCK/6k9ELP 613jSrxGDKHtBBvNGOGuQDN3uPGTJ2feM9YRuwotVBxZi1Bd3MS5qJCQcwOaaohs5hEp T1Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690980536; x=1691585336; 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=CzdBr4YE6+e2aCPihxyG1VP6AlkYIgUBNXtEC6jGkqA=; b=BxG/avEX7AVvNaQZAd7x8iP02euQbX1nFijnWPPU4brc9/lwOJIk2zbntdApGWPljg eYVTQ2KfPETpIvuCgDQnZXzzx1KCdS/FjwpXK7UJL9d6g7aXO2+cDwy/vicdSL1w76eF aO0pafMKk6rinmDGBq8w9/j8grDr3Do7HUbDyLueAFg3ZLM2zsn1OUFAcJYDasKvtAWp z1i+9Sk0Rs9h/Yknus641hbCEKEC8OWWCIPUKv8ORmzjvIZF6xShap6E52HzyrAbqwTJ ZuD1IGEAmUnu4Q9ZDcx5DD8i6edLyclsH5BatP5p8abGyFmHYlSEuMZAj0TjPyyGABcI XzoA== X-Gm-Message-State: ABy/qLbjDzTKRrSNXXgkY4BM4IF0p7tWJ4Dr3NjTOUyCdlvhMuuzc66w 7FEkUhS2Tlu46RRrTf0ZMN8= X-Received: by 2002:a17:90b:1954:b0:256:8dbd:74fa with SMTP id nk20-20020a17090b195400b002568dbd74famr12027905pjb.22.1690980535749; Wed, 02 Aug 2023 05:48:55 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.17]) by smtp.googlemail.com with ESMTPSA id x34-20020a17090a6c2500b00264044cca0fsm4811993pjj.1.2023.08.02.05.48.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:48: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 v5 2/7] perf sched: sync state char array with the kernel Date: Wed, 2 Aug 2023 08:47:25 -0400 Message-ID: <20230802124840.335638-3-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802124840.335638-1-zegao@tencent.com> References: <20230802124840.335638-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_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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773123559503872262 X-GMAIL-MSGID: 1773123559503872262 Update state char array and then remove unused and stale macros, which are kernel internal representations and not encouraged to use anymore. Signed-off-by: Ze Gao --- tools/perf/builtin-sched.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 9ab300b6f131..8dc8f071721c 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -92,23 +92,12 @@ struct sched_atom { struct task_desc *wakee; }; -#define TASK_STATE_TO_CHAR_STR "RSDTtZXxKWP" +#define TASK_STATE_TO_CHAR_STR "RSDTtXZPI" /* task state bitmask, copied from include/linux/sched.h */ #define TASK_RUNNING 0 #define TASK_INTERRUPTIBLE 1 #define TASK_UNINTERRUPTIBLE 2 -#define __TASK_STOPPED 4 -#define __TASK_TRACED 8 -/* in tsk->exit_state */ -#define EXIT_DEAD 16 -#define EXIT_ZOMBIE 32 -#define EXIT_TRACE (EXIT_ZOMBIE | EXIT_DEAD) -/* in tsk->state again */ -#define TASK_DEAD 64 -#define TASK_WAKEKILL 128 -#define TASK_WAKING 256 -#define TASK_PARKED 512 enum thread_state { THREAD_SLEEPING = 0, From patchwork Wed Aug 2 12:47:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 129830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp455013vqx; Wed, 2 Aug 2023 06:25:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlGwYKlQno9RZPklhJJnDqWaa4LUpphYiMc7WLuriX0saDeMX3qPGZIHu+bFobTKfXEzoY2A X-Received: by 2002:a05:6e02:170e:b0:345:af82:dc3a with SMTP id u14-20020a056e02170e00b00345af82dc3amr18044530ill.14.1690982725851; Wed, 02 Aug 2023 06:25:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690982725; cv=none; d=google.com; s=arc-20160816; b=cTVsamzaLNeBV8t2KsvtmVx8V9t7zUgaLTW0OYW0XI4z/GJJouYLiTrKykngkz57KN atxipboPTu9LYdjL91YjNniJ+DBceNkwDEXCAOD+v1sutqyg+byniPXLZuAyQ0OBlyB7 Xo9ovy59pNPfZUOXZbcAq9I+kZLnF78uufxjmgc6Y9LeExlvi8EwRTXyEyqwpn8jDfcg JqGiah3njpc58xo+ax5QS5KHCS4Nzdqxe7wURFU1AerJoGsBT57gbmfFswZiROecWHMX qNGGx+5fw4sZ32Imhg7dxYCbGq1641yCaJto0rLidg6GOi1SnGfA5ViLKChccbuorVbf ggrQ== 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=ZqGWXQUnHEGIAJjlk8NVej2IuOd14tKht3c5V5V3ivI=; fh=4S4dukURCUlSsjzSa0Ofy3qHSrrdu/uT1HnGBPj5BK4=; b=p2UsDbsmy2synjDYIjCFj/JKvwGVG02VrNWPJF19IuXTpIUxJiiRL0eQWxpmHdPQzd E8CJ7H7yIoqCgG63+st2hVRLrcuUS/midgdsnWdA3Qnw+c7XODEI8ghPYkUw+NYEQuJ0 5/ZtAFCZS158UnGahm0dkFco/MXM9SfL/lNuvbsqn9DiknExcRVMVFyakY9HnT7dgXW7 jwSiFe95fvoshy9Cp25kfrdMjLJHclfNkTY61koldyPHhG6mmXZ0w081RuNqpdsiJDy+ Xe9SuqgwDIkGGAnMQxU4In2QaUFHsnqXgnNEKLwRyzn8Dmg5L8dfmc1Ck2tTT5KTvvxv TC6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mtOsLo07; 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 fz16-20020a17090b025000b00268149f78fdsi1194516pjb.147.2023.08.02.06.25.00; Wed, 02 Aug 2023 06:25:25 -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=mtOsLo07; 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 S234846AbjHBMta (ORCPT + 99 others); Wed, 2 Aug 2023 08:49:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234788AbjHBMtJ (ORCPT ); Wed, 2 Aug 2023 08:49:09 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FFE0212B; Wed, 2 Aug 2023 05:49:00 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-56487a5401bso131267a12.3; Wed, 02 Aug 2023 05:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690980540; x=1691585340; 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=ZqGWXQUnHEGIAJjlk8NVej2IuOd14tKht3c5V5V3ivI=; b=mtOsLo07GMllEngNvb9+BqwcT7KAe81fbqwVPSDxezQtx9R2AIdEPawGkHCXKfy6EU rM8VkRK4Rxt7kcHvnT1IyKrCQMUISW2CKsEevszJxDVwBDTgFZBF6mry0a+5o/N1LQDN uC0DKs/PuonpeBIAaFtiX0zSCnljcsy/40Q2fszofzPbTmxwjwFH2ORITr3zwkVMmU2m OUJzeFQ0cUqFY2pEMVwouQZCUerqOs4jwfX5n8x+6ABL/ZyYnPsjMnDtJOKiv1hJ7ya1 wVRggbfxbLJsxFeGYbwuvFM0fjKTdKVQ0ANtzU5dDDsJCuhED4seqnTXBQpU3j3lAw7N UPpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690980540; x=1691585340; 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=ZqGWXQUnHEGIAJjlk8NVej2IuOd14tKht3c5V5V3ivI=; b=hjHQI9iG6o1wEvkEJOOmK08ae+N52drb8k/pjP5wXf/6cS7vYaQHIjvH4HMp4VFptJ c6L4veXHEV8Fn4wVoD30msPz1z0k1vJzcaGinSuvvY4cN06r7zrFW/c9oCDGDfqyQzoK FbefpNv5BozHqsPz2SJ4HCqFdVsHjgwJZ07yjy+niB7zN2G0Ldx6hdX0mObSX8gRHWc3 H9EYN1UcPw2KAocAD9b1gjs5uXU1i46VIMWNbNWHddQAAQJ5D6QF7wDRuNx6IZMnna6V oY4FYRBHXsEzoTpPzaqxOur8V3thB9XFBdUd77QWmU/qg9BmDo3bmf/ROAI3pPtQxW/M d8BA== X-Gm-Message-State: ABy/qLYXBIoD/TJgGWMdj85Cu8Xexr2A/CqQyGaJS636wUeSDbSLs0+R lkt/k1XRfM7SkGs22nq8ey4= X-Received: by 2002:a17:90a:2a48:b0:263:ac11:c6d2 with SMTP id d8-20020a17090a2a4800b00263ac11c6d2mr13717420pjg.25.1690980539783; Wed, 02 Aug 2023 05:48:59 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.17]) by smtp.googlemail.com with ESMTPSA id x34-20020a17090a6c2500b00264044cca0fsm4811993pjj.1.2023.08.02.05.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:48:59 -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 v5 3/7] perf sched: reorganize sched-out task state report code Date: Wed, 2 Aug 2023 08:47:26 -0400 Message-ID: <20230802124840.335638-4-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802124840.335638-1-zegao@tencent.com> References: <20230802124840.335638-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_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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773123903039873466 X-GMAIL-MSGID: 1773123903039873466 Mainly does housekeeping work and not introduce any functional change. Signed-off-by: Ze Gao --- tools/perf/builtin-sched.c | 57 ++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 8dc8f071721c..eb310d1a7625 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -94,11 +94,6 @@ struct sched_atom { #define TASK_STATE_TO_CHAR_STR "RSDTtXZPI" -/* task state bitmask, copied from include/linux/sched.h */ -#define TASK_RUNNING 0 -#define TASK_INTERRUPTIBLE 1 -#define TASK_UNINTERRUPTIBLE 2 - enum thread_state { THREAD_SLEEPING = 0, THREAD_WAIT_CPU, @@ -255,7 +250,7 @@ struct thread_runtime { u64 total_preempt_time; u64 total_delay_time; - int last_state; + char last_state; char shortname[3]; bool comm_changed; @@ -425,7 +420,7 @@ static void add_sched_event_wakeup(struct perf_sched *sched, struct task_desc *t } static void add_sched_event_sleep(struct perf_sched *sched, struct task_desc *task, - u64 timestamp, u64 task_state __maybe_unused) + u64 timestamp, char task_state __maybe_unused) { struct sched_atom *event = get_new_event(task, timestamp); @@ -840,6 +835,20 @@ replay_wakeup_event(struct perf_sched *sched, return 0; } +static inline char task_state_char(int state) +{ + static const char state_to_char[] = "RSDTtXZPI"; + unsigned bit = state ? ffs(state) : 0; + return bit < sizeof(state_to_char) - 1 ? state_to_char[bit] : '?'; +} + +static inline char get_task_prev_state(struct evsel *evsel, + struct perf_sample *sample) +{ + const int prev_state = evsel__intval(evsel, sample, "prev_state"); + return task_state_char(prev_state); +} + static int replay_switch_event(struct perf_sched *sched, struct evsel *evsel, struct perf_sample *sample, @@ -849,7 +858,7 @@ static int replay_switch_event(struct perf_sched *sched, *next_comm = evsel__strval(evsel, sample, "next_comm"); const u32 prev_pid = evsel__intval(evsel, sample, "prev_pid"), next_pid = evsel__intval(evsel, sample, "next_pid"); - const u64 prev_state = evsel__intval(evsel, sample, "prev_state"); + const char prev_state = get_task_prev_state(evsel, sample); struct task_desc *prev, __maybe_unused *next; u64 timestamp0, timestamp = sample->time; int cpu = sample->cpu; @@ -1039,12 +1048,6 @@ static int thread_atoms_insert(struct perf_sched *sched, struct thread *thread) return 0; } -static char sched_out_state(u64 prev_state) -{ - const char *str = TASK_STATE_TO_CHAR_STR; - - return str[prev_state]; -} static int add_sched_out_event(struct work_atoms *atoms, @@ -1121,7 +1124,7 @@ static int latency_switch_event(struct perf_sched *sched, { const u32 prev_pid = evsel__intval(evsel, sample, "prev_pid"), next_pid = evsel__intval(evsel, sample, "next_pid"); - const u64 prev_state = evsel__intval(evsel, sample, "prev_state"); + const char prev_state = get_task_prev_state(evsel, sample); struct work_atoms *out_events, *in_events; struct thread *sched_out, *sched_in; u64 timestamp0, timestamp = sample->time; @@ -1157,7 +1160,7 @@ static int latency_switch_event(struct perf_sched *sched, goto out_put; } } - if (add_sched_out_event(out_events, sched_out_state(prev_state), timestamp)) + if (add_sched_out_event(out_events, prev_state, timestamp)) return -1; in_events = thread_atoms_search(&sched->atom_root, sched_in, &sched->cmp_pid); @@ -2022,24 +2025,12 @@ static void timehist_header(struct perf_sched *sched) printf("\n"); } -static char task_state_char(struct thread *thread, int state) -{ - static const char state_to_char[] = TASK_STATE_TO_CHAR_STR; - unsigned bit = state ? ffs(state) : 0; - - /* 'I' for idle */ - if (thread__tid(thread) == 0) - return 'I'; - - return bit < sizeof(state_to_char) - 1 ? state_to_char[bit] : '?'; -} - static void timehist_print_sample(struct perf_sched *sched, struct evsel *evsel, struct perf_sample *sample, struct addr_location *al, struct thread *thread, - u64 t, int state) + u64 t, char state) { struct thread_runtime *tr = thread__priv(thread); const char *next_comm = evsel__strval(evsel, sample, "next_comm"); @@ -2080,7 +2071,7 @@ static void timehist_print_sample(struct perf_sched *sched, print_sched_time(tr->dt_run, 6); if (sched->show_state) - printf(" %5c ", task_state_char(thread, state)); + printf(" %5c ", thread->tid == 0 ? 'I' : state); if (sched->show_next) { snprintf(nstr, sizeof(nstr), "next: %s[%d]", next_comm, next_pid); @@ -2152,9 +2143,9 @@ static void timehist_update_runtime_stats(struct thread_runtime *r, else if (r->last_time) { u64 dt_wait = tprev - r->last_time; - if (r->last_state == TASK_RUNNING) + if (r->last_state == 'R') r->dt_preempt = dt_wait; - else if (r->last_state == TASK_UNINTERRUPTIBLE) + else if (r->last_state == 'D') r->dt_iowait = dt_wait; else r->dt_sleep = dt_wait; @@ -2579,7 +2570,7 @@ static int timehist_sched_change_event(struct perf_tool *tool, struct thread_runtime *tr = NULL; u64 tprev, t = sample->time; int rc = 0; - int state = evsel__intval(evsel, sample, "prev_state"); + const char state = get_task_prev_state(evsel, sample); addr_location__init(&al); if (machine__resolve(machine, &al, sample) < 0) { From patchwork Wed Aug 2 12:47:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 129823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp447996vqx; Wed, 2 Aug 2023 06:14:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlF7QmCjnAexuF38KAAMGNpeDHtVQmFBayc++0x6tccCw2uxWbmpbnD6UwPNK7Q4BDPkBLJp X-Received: by 2002:a05:6a20:9719:b0:11c:fc27:cda4 with SMTP id hr25-20020a056a20971900b0011cfc27cda4mr16128126pzc.11.1690982079252; Wed, 02 Aug 2023 06:14:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690982079; cv=none; d=google.com; s=arc-20160816; b=dXxQhT2gK+bDE8CxhFQdElYXYJBDgrhs6RchaHuRxfyRXyGwaCWFI7KymuKuGa2YJj MoZZOMtNlLK6fuJcAcPa7Fl6sFsSk4UkMEMTuDzY/H7Wu+qXgVaD67YzdyeW043sqqV/ bRMhyHeYRhrIxxtXXXqzEWqnL3FZEloWhLUGGu3+iBf9SIdRbKAImnWh8nbGa2JG1jyT iMA5hdYWw832W9/b3B8E0CtYZpg5AXVdKlVPIcaHjFZvn9htCz0Ld0N0GIjUwfVAtpqw zHdpCcYxEiWiMHWQ0PdDbdMyf7Bkpv+REL18djvzB/dV/A0db2uklSOsOEWIwof1u+g8 JNSQ== 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=DEZCAX1WlrsUv3nMNvtTambxp2M6PKeC7k4D0cytuU4=; fh=4S4dukURCUlSsjzSa0Ofy3qHSrrdu/uT1HnGBPj5BK4=; b=VA6lXloz7F4uC0lu/k0DSPvIePYfi2YgWlyJEmYKKnMD0iaa+duOFJhdiUJLcr7R0y BY0snjBs/eqbl4sD6MCZBElNygAAjPvsZXC7X0fYmQAZpBuY+PXiq5RDa4Gq/j4Awi46 +KZzY2V+6SrxXT6f6JOQCUvGx6Ss/i28hV0u6DJcQATslhaeHWLpNRU+LF9vxFGCf8/x TN9Rw6DPFgB5K+XPbMc5XMq4mh2+nm5A2CGOlqwi2JFk1PeMvoE+qWiLOFP+MAdSut6M jZtUF0npyIH8xU7IOC+RdZAaKjlmowmGu8cZ5EVouOghbzreLgebQT+wM0597JeUq/kA nqow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=lPf1Tobb; 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 l20-20020a63ea54000000b0055be9543340si6163917pgk.872.2023.08.02.06.14.22; Wed, 02 Aug 2023 06:14:39 -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=lPf1Tobb; 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 S234900AbjHBMtl (ORCPT + 99 others); Wed, 2 Aug 2023 08:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234737AbjHBMtK (ORCPT ); Wed, 2 Aug 2023 08:49:10 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65FDB2D78; Wed, 2 Aug 2023 05:49:04 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-26830595676so4780327a91.2; Wed, 02 Aug 2023 05:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690980544; x=1691585344; 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=DEZCAX1WlrsUv3nMNvtTambxp2M6PKeC7k4D0cytuU4=; b=lPf1TobbUrw1GTawCUCLEnAAjBp8pdwI/dfI2qxVqSsOzmaDY1I+0giZV4UOon5Bwx aaQF4Ez1LU7MqaKaQztnoUUnCEOS3Eo9ITZInVOl3qTGyypRbi/2ozpnE5g9DTNgvFDR x4gMWe1eSGUT5rT+cmAb9/RzoegOd+IagpZUOpNOvR1AP1oyn7kGFJiuAVsO5611TxVZ 0Qc1Ey/L3IONZ+w8KjzFyGeDwiU9z/JfUJmzka7SXLJFWahWxjGZBoIEnuI506kn4zoc UOIyu73yPY4qu+P4tWN2r0kNbC+L+GnMCrnAJNhvdYENrTKBF0XRIFiJEvenJCK2iEeU hJ+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690980544; x=1691585344; 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=DEZCAX1WlrsUv3nMNvtTambxp2M6PKeC7k4D0cytuU4=; b=Pj0b3DTgqw67I7VUbLwPIRSOaDMesxzjgztKph26jTS07v7fXyxpxLH+p+9H+3V2sl bRVSPnqFOFN7SsWtUMvGJQyEMWDUPcpZPFkEFSYRNkmpzlLFrl5w1ivV57ina8/avrTD XuiuNCBG2g73w8oVyHmNsozH9MrENKkXIqikhAzuoaZSX+t39trq8079akrxo8xAIz5x er9BVzC/nZe+cQnzusnsxxRnY8Ap17OX/orEQ2MNdaYPpxx5AvKos73rOPWCaNBweLIl MRJt+umsaGmwmASIOj4RbZ+VFPTOgA6OFdY1cWZPs9te+sEEfF/VIj3XHeigtUFTNgTy 2JLg== X-Gm-Message-State: ABy/qLaPzKukVWihMC7q7QpC4wSgWTitabpugKDopXq1chY4KGwbF1HP yShPyyzeNNs+BmOiZffaW8I= X-Received: by 2002:a17:90b:350b:b0:268:634f:61f2 with SMTP id ls11-20020a17090b350b00b00268634f61f2mr15998891pjb.17.1690980543891; Wed, 02 Aug 2023 05:49:03 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.17]) by smtp.googlemail.com with ESMTPSA id x34-20020a17090a6c2500b00264044cca0fsm4811993pjj.1.2023.08.02.05.49.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:49:03 -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 v5 4/7] sched, tracing: reorganize fields of switch event struct Date: Wed, 2 Aug 2023 08:47:27 -0400 Message-ID: <20230802124840.335638-5-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802124840.335638-1-zegao@tencent.com> References: <20230802124840.335638-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_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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773123224879300837 X-GMAIL-MSGID: 1773123224879300837 Report priorities in 'short' and prev_state in 'int' to save some buffer space. And also reorder the fields so that we take struct alignment into consideration to make the record compact. Suggested-by: Steven Rostedt (Google) Signed-off-by: Ze Gao --- include/trace/events/sched.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index fbb99a61f714..7d34db20b2c6 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h @@ -187,7 +187,7 @@ DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new, TP_ARGS(p)); #ifdef CREATE_TRACE_POINTS -static inline long __trace_sched_switch_state(bool preempt, +static inline int __trace_sched_switch_state(bool preempt, unsigned int prev_state, struct task_struct *p) { @@ -229,23 +229,23 @@ TRACE_EVENT(sched_switch, TP_ARGS(preempt, prev, next, prev_state), TP_STRUCT__entry( - __array( char, prev_comm, TASK_COMM_LEN ) __field( pid_t, prev_pid ) - __field( int, prev_prio ) - __field( long, prev_state ) - __array( char, next_comm, TASK_COMM_LEN ) __field( pid_t, next_pid ) - __field( int, next_prio ) + __field( short, prev_prio ) + __field( short, next_prio ) + __field( int, prev_state ) + __array( char, prev_comm, TASK_COMM_LEN ) + __array( char, next_comm, TASK_COMM_LEN ) ), TP_fast_assign( - memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN); - __entry->prev_pid = prev->pid; - __entry->prev_prio = prev->prio; - __entry->prev_state = __trace_sched_switch_state(preempt, prev_state, prev); + __entry->prev_pid = prev->pid; + __entry->next_pid = next->pid; + __entry->prev_prio = (short) prev->prio; + __entry->next_prio = (short) next->prio; + __entry->prev_state = __trace_sched_switch_state(preempt, prev_state, prev); memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN); - __entry->next_pid = next->pid; - __entry->next_prio = next->prio; + memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN); /* XXX SCHED_DEADLINE */ ), From patchwork Wed Aug 2 12:47:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 129824 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp448266vqx; Wed, 2 Aug 2023 06:15:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlFloDSP7MNUKNrvOzr+OTO7BeN8vSxES0fMC1fJa88zFLlPhvzwtTkIzQ/OHuSIFLTxA2+a X-Received: by 2002:a05:6a20:8f04:b0:111:77cf:96dd with SMTP id b4-20020a056a208f0400b0011177cf96ddmr18488775pzk.5.1690982102711; Wed, 02 Aug 2023 06:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690982102; cv=none; d=google.com; s=arc-20160816; b=JcME9DGzT7lg7B6KNx8skUyL2h1wSyKwVrQgIXMKcDvhh+0+iFpFigDCzGRTP2FJli ewaeuQ5JT1RGXtxO0fWHwxWFmyeXRezM8v2B/Qkjjd3KgpM+pBkNgBifxd8QEkAEzPrO KRw8txhGF3trmSdjr96m1itkCtqUDP/3v2KqubaPYTeuenppZLG4visa+lsEVHA2ish6 nnnnBjVvJyex7+XobMFdMVKAXwLv7iKUSqkdJprJ7QfadAJaczvHGTLpRlOpGqtBps+P jSwm5u2hMmL3ZnMcmr4623qzLJkiUkG34Jnh+mNMW6bhIn0Miz4w5BYb7DcA+1IKTLQi S+JA== 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=g/qteU2mNw/BBJfHNte7O9hoGmnD/YD+enA+yhOHga4=; fh=4S4dukURCUlSsjzSa0Ofy3qHSrrdu/uT1HnGBPj5BK4=; b=J5O1NdVdvjAN5noUpIWDqEQySYVegwWgn7/73YZDCsf/0gbVF/nT0PLd8g+7c2WRXN wJJ6hAspfQ6b85J7n1LwFm8GekSYu24w4Zy46PRkBHMrD/xQt+0mBOAUrNyWkQtbi3cv U1uco4wo/LT80OU5Fs4cxEIXJ2urZ3aSiY4ORK4Uz435ixYKsZyt4E4Hkl+nlOZ/oaag kHOHSoqxllSKF07hxeJHCgZSmY0hiHiC0GrQOqSTOmv3K9U8qyFR23TH14tWv9/HP6fO oPoTPSbGfB2QZh2iZdwkEHbz9TAb0JRDn2lxwaGZkiSxaZxAoxEIjjCZc9xXEBYrc9Nn 4Wqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="OP/jxunn"; 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 e184-20020a6369c1000000b00563e25c07c0si10628780pgc.270.2023.08.02.06.14.46; Wed, 02 Aug 2023 06:15: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="OP/jxunn"; 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 S234874AbjHBMtx (ORCPT + 99 others); Wed, 2 Aug 2023 08:49:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234866AbjHBMtO (ORCPT ); Wed, 2 Aug 2023 08:49:14 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2A4726B0; Wed, 2 Aug 2023 05:49:08 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1bbd2761f1bso56941595ad.2; Wed, 02 Aug 2023 05:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690980548; x=1691585348; 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=g/qteU2mNw/BBJfHNte7O9hoGmnD/YD+enA+yhOHga4=; b=OP/jxunnVEjIALdrKgklqzA4TO2+S7yZyoB1vbzcHPo2X6iSraTju6MNy/9+cLsb0I taQTHYoyq2w90sy33wYlAJ3mIV/itOpiNrHrs8ni5c/sxk9SwynCw+cMAkmx5/3XaO23 uJSstfIzoSZPaoSyDGEbhJoGIP+LnCLdWcvbNVAOZHI77pnQhyMrAI1moxomYA2BNZJQ KEGFxlUuaUpR+ot+U0zWAn2nNBi4288T02gfxTbIZsiyQb8R2sqC4SkhLv4DoMzQKMLa 1Sr8TCBwWEMtoFHmJ1CJzneu/JOAvkXbjmm1+wpAelgMux60eLIaTMMqTgpF/hrXJDtV Zv0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690980548; x=1691585348; 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=g/qteU2mNw/BBJfHNte7O9hoGmnD/YD+enA+yhOHga4=; b=HuZjXGx9xMf6ygdAChCGhZOlf95spDLPOIU79YBTM7Mhj9o0TMnMT5jUWNXNQBJ8Ie 9c4cYOqXhddL82LgfYpaxJpk1MxQs4m0vG//pHpVsb91rV4FsXnA4eEIEvGTemgd1nQ2 +AMsTEQTBxaGp6IQQGGnUn29ykVea4e27DzrJqh9XfUSJL9HpHhdBaeKnQfffmggBRMX sNf4twc//qGt4tnBMeFAGFOX6RwLUV1fUOskAXA2kzAkS5KTEQi0GmDE7LrwM6Nh4DZI wMp8pZmlN4JEC5wrhYlTqTuIaEG2Mig0dgLuTyGCyXtHPk8b+0baDhgOgAUMN0/8uMRm KXGA== X-Gm-Message-State: ABy/qLYa2kc1JvUWi7QX4cMe9H+F6Ts99fr20agiuPtmiRNH64Huz4ti lvZIXTcR9W/EUS83BZI8Ri4= X-Received: by 2002:a17:902:dac4:b0:1b8:8dbd:e1a0 with SMTP id q4-20020a170902dac400b001b88dbde1a0mr18050733plx.13.1690980548101; Wed, 02 Aug 2023 05:49:08 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.17]) by smtp.googlemail.com with ESMTPSA id x34-20020a17090a6c2500b00264044cca0fsm4811993pjj.1.2023.08.02.05.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:49:07 -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 v5 5/7] sched, tracing: add to report task state in symbolic chars Date: Wed, 2 Aug 2023 08:47:28 -0400 Message-ID: <20230802124840.335638-6-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802124840.335638-1-zegao@tencent.com> References: <20230802124840.335638-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_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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773123249447899677 X-GMAIL-MSGID: 1773123249447899677 Internal representations of task state are likely to be changed or ordered, and reporting them to userspace without exporting them as part of API is basically wrong, which can easily break a userspace observability tool as kernel evolves. For example, perf suffers from this and still reports wrong states as of this writing. OTOH, some masqueraded states like TASK_REPORT_IDLE and TASK_REPORT_MAX are also reported inadvertently, which confuses things even more and most userspace tools do not even take them into consideration. So add a new variable in company with the old raw value to report task state in symbolic chars, which are self-explaining and no further translation is needed. Of course this does not break any userspace tool. Note for PREEMPT_ACTIVE, we introduce 'p' to report it and use the old conventions for the rest. Signed-off-by: Ze Gao Reviewed-by: Masami Hiramatsu (Google) Acked-by: Ian Rogers --- include/trace/events/sched.h | 44 ++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index 7d34db20b2c6..1c7b94793495 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h @@ -6,6 +6,7 @@ #define _TRACE_SCHED_H #include +#include #include #include #include @@ -214,6 +215,27 @@ static inline int __trace_sched_switch_state(bool preempt, return state ? (1 << (state - 1)) : state; } + +static inline char __trace_sched_switch_state_char(bool preempt, + unsigned int prev_state, + struct task_struct *p) +{ + long state; + +#ifdef CONFIG_SCHED_DEBUG + BUG_ON(p != current); +#endif /* CONFIG_SCHED_DEBUG */ + + /* + * For PREEMPT_ACTIVE, we introduce 'p' to report it and use the old + * conventions for the rest. + */ + if (preempt) + return 'p'; + + state = __task_state_index(prev_state, p->exit_state); + return task_index_to_char(state); +} #endif /* CREATE_TRACE_POINTS */ /* @@ -236,6 +258,7 @@ TRACE_EVENT(sched_switch, __field( int, prev_state ) __array( char, prev_comm, TASK_COMM_LEN ) __array( char, next_comm, TASK_COMM_LEN ) + __field( char, prev_state_char ) ), TP_fast_assign( @@ -246,26 +269,13 @@ TRACE_EVENT(sched_switch, __entry->prev_state = __trace_sched_switch_state(preempt, prev_state, prev); memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN); memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN); + __entry->prev_state_char = __trace_sched_switch_state_char(preempt, prev_state, prev); /* XXX SCHED_DEADLINE */ ), - TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d", - __entry->prev_comm, __entry->prev_pid, __entry->prev_prio, - - (__entry->prev_state & (TASK_REPORT_MAX - 1)) ? - __print_flags(__entry->prev_state & (TASK_REPORT_MAX - 1), "|", - { TASK_INTERRUPTIBLE, "S" }, - { TASK_UNINTERRUPTIBLE, "D" }, - { __TASK_STOPPED, "T" }, - { __TASK_TRACED, "t" }, - { EXIT_DEAD, "X" }, - { EXIT_ZOMBIE, "Z" }, - { TASK_PARKED, "P" }, - { TASK_DEAD, "I" }) : - "R", - - __entry->prev_state & TASK_REPORT_MAX ? "+" : "", - __entry->next_comm, __entry->next_pid, __entry->next_prio) + TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%c ==> next_comm=%s next_pid=%d next_prio=%d", + __entry->prev_comm, __entry->prev_pid, __entry->prev_prio, __entry->prev_state_char, __entry->next_comm, + __entry->next_pid, __entry->next_prio) ); /* From patchwork Wed Aug 2 12:47:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 129838 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp463156vqx; Wed, 2 Aug 2023 06:38:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlEyGQMUyaU+thIJcdSoy14NLZsQID41gDXhmw5dNdvWhfkSlnxwi/UrswTPGcf1X5aJh3t2 X-Received: by 2002:a17:902:eccf:b0:1b6:7f96:42ca with SMTP id a15-20020a170902eccf00b001b67f9642camr15963904plh.66.1690983506367; Wed, 02 Aug 2023 06:38:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690983506; cv=none; d=google.com; s=arc-20160816; b=BsIwPenEVIgj5uomeHHnUD8qCPWG9ewUEpqRKm+j0X+l0Bv7ywlu4CSFLRcEK95/an hroZo5nhHtIwXWVOOAl++2WFxveSQrN9qEnYf0rVNIRA292ZM00DFLHxFCUNPDhKiu8R Uj2FAA6iKOaflvElggiAw5Dhi52AOCv8u5u0q/YEHk5X/puTVoEEE8pfPoLKjMh0gV/7 tOOBF6KLrBbZ4v6HwvmKURuvIsLjKiRkxvkTcGZs1SPXLB50OHAG95FN7VSh8cTlHfg4 8wNtXWi3FAU6K24jOeoD0lWrNCjKJZ2w3ti2Wwg7BB+o5M39/EZNYu5H0KFq0Psd/ULw eOpA== 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=GPn/mgTWKV+oBePvxacidtJnH5NXaYh0/ilB9/OG6C4=; fh=4S4dukURCUlSsjzSa0Ofy3qHSrrdu/uT1HnGBPj5BK4=; b=YzEmwh4rejZ+4/wMILosKf0wqusd285JuHOmxcLn+YP8c6Ir0crzgZtouCx9U3KXEb rPQxrlJ3/0Q0hnf7Y3hE5R5PI55iXlZRnpjck32SVf5Lb/NBYJ4rqcRWYBH4MtkkJkjh cWvazFFMNxLgAo3TsUZUq9pTvqe7RaATLSyY/66xpSVaI9yx/rzGe+9n4y1J3iaEg2y4 ogyxQBunhytrCHHrlqywDqlFxOQt6BOGeqltH2I+Yo0l/KadZVb0DaNhRXfqi1P1KUbQ L9EMTrRhvtTC9UJ34d9xLdwmhgPs2aQOvWq5QlO+sr3uTRwD19Wfz2ybdnD+HXnmTPnS YZLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=BsmjiHo5; 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 p2-20020a170902e74200b001b841d54b7csi11196244plf.206.2023.08.02.06.38.10; Wed, 02 Aug 2023 06:38:26 -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=BsmjiHo5; 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 S234698AbjHBMt4 (ORCPT + 99 others); Wed, 2 Aug 2023 08:49:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234822AbjHBMtP (ORCPT ); Wed, 2 Aug 2023 08:49:15 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0E92271F; Wed, 2 Aug 2023 05:49:12 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-790ab117bd5so120086739f.0; Wed, 02 Aug 2023 05:49:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690980552; x=1691585352; 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=GPn/mgTWKV+oBePvxacidtJnH5NXaYh0/ilB9/OG6C4=; b=BsmjiHo5WQQKClP5ASFtdsx0MlRD8yQSsvBGCM+NZ5GvwEDKFO8y8x02RduX1Q6Hm6 CPuaI/jLsxd9z57uutSrPQ/rPOttOx01/WFA9pyta/NEqdzAgQCF1ZTBA9m8iM1/kpH3 z65NBjwVeazO0Q8Fc2/yZui8mj2KvOcJTGPVddZxrfMPGHLddhmkwsjCZrSvoWbOl6PY KSP2aAZQBr9d9BufbCAvdlad/j3ulGI8JGqpcRfoX87o1QRM+qO8z7oYSjF6YKA4Gx+u A+tw5BJaWOYgThrR+7cZsLAHUHDjeb4pxkr0vdUxgfJoZvAA9VhrD0lJwG1rFh/ISIwO DPWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690980552; x=1691585352; 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=GPn/mgTWKV+oBePvxacidtJnH5NXaYh0/ilB9/OG6C4=; b=AmyxQjQpYDADpRvLQrE0r2Ib59A3+9pmM4Au7H/AvglyvXT8ZxNeoleArPhD3aOxfA ewsAVtazXP1xPUBmJ3H4Dzs3vrfjjlLYEBAvhGJspvg3f8nX1HBJTfw9j4BNcwEXVdDO mx9NSNF289GaauZfB/lKj0j1T2egU7inW2HlljBOnWdMTohto0L/y/6m9qDIHe5UAt/A V+Vk3KBs8ms9tJWJa+ZFtFPS5WwCm8joCZGF+yKvkOD9XbWAPD8xUtfHIBIK2ih9z+V2 15ZFOmngC7j/7ZzAxz67HIq2X7LDZD8ESXzyfuTz6VouGYEb+tbBeZE688ZY4owfW3w5 /Sgg== X-Gm-Message-State: ABy/qLbSNwiNFPEGTRpqjLcLUg/pg1snIpU5KMAR4Lb6EiBDtTABIezF sBiuGV77I0ziFmCezai5LUg= X-Received: by 2002:a05:6e02:1521:b0:346:f30:ad58 with SMTP id i1-20020a056e02152100b003460f30ad58mr16967213ilu.24.1690980552110; Wed, 02 Aug 2023 05:49:12 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.17]) by smtp.googlemail.com with ESMTPSA id x34-20020a17090a6c2500b00264044cca0fsm4811993pjj.1.2023.08.02.05.49.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:49:11 -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 v4 6/7] libtraceevent: prefer to use prev_state_char introduced in sched_switch Date: Wed, 2 Aug 2023 08:47:29 -0400 Message-ID: <20230802124840.335638-7-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802124840.335638-1-zegao@tencent.com> References: <20230802124840.335638-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_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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773124720758023360 X-GMAIL-MSGID: 1773124720758023360 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 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 + 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, " ==> "); From patchwork Wed Aug 2 12:47:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 129829 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp454512vqx; Wed, 2 Aug 2023 06:24:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlGI71oCGhOYGF1MwB+jprEXWuUvW0MsjWrKv6I4bAiv0l4VGJJJSJzH/jkBCI/bYUzYUtZZ X-Received: by 2002:a05:6e02:12c4:b0:348:8b42:47d with SMTP id i4-20020a056e0212c400b003488b42047dmr15694312ilm.28.1690982676664; Wed, 02 Aug 2023 06:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690982676; cv=none; d=google.com; s=arc-20160816; b=TyS2GCoKYeAti8ji6q3/IAgWZYT66c0B1H3MoQNQAA2VQcHFHu48WgH/QyCoPm3cy6 Kr/XHi56NLsH6lWoQzCSgDZMyNOI8VdJHuSrcQD4k0ZtFqc04uvmDN3AFyHkOFvK/v2E 2AuUan0TWR/2IR4hqzpmREeLC/1Jf1O99C5ZrxVyPd5XsicZl/G1kjY5rQ/eQAvuWJxt 6mKWpgjfzxzKuQDzrL0cAjcp+3odZGt/3YS7dBKfdU6IvrEYHx4nAPMIoZ5ICwDIrxId EjXk1nSyhXQ54KhrmsDv7bqvwuW+bHV1p4jkg49/lFY/c/MXj34easwPodmmSILWO+Ud Qx/Q== 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=KWetw+9fo7xpR+/Y1RDX5IOHvVHf8sfB8Rgzd3Bsv2A=; fh=4S4dukURCUlSsjzSa0Ofy3qHSrrdu/uT1HnGBPj5BK4=; b=K2RdOnla4zVI9FdN8tyto/oPL0siN5N4g1GNjuXQsXYIBKF7jrCy/r89wk7bI3q0Fg SqaZFud0RWLA+LE2anwl1m9GkDuiI6dukC94Gtcn/+dGRUssQp+Tr2/o1UP4Iyoj8NQi fwERIV8crGFCrofgWqzr4PTNzFuzK9IukB2C11BljPYpQ0U4dAF51jdLtQ11OvWVljbC VwKF3OBPCFHK8MZdQT23bUJXwkhHBAuc0Oq5pD78v161OfjJlIYH5GzJzeRg/no/mzjc 3ljhI69Om0lC5L6unXSdUtxUkpBPUIudpJFXSWNfDSsw0AWqMRNcBMoF10tqiKENB2XG BVpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=GIHzjFSz; 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 129-20020a630187000000b00563f2833cdesi10749291pgb.112.2023.08.02.06.24.06; Wed, 02 Aug 2023 06:24:36 -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=GIHzjFSz; 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 S234893AbjHBMt7 (ORCPT + 99 others); Wed, 2 Aug 2023 08:49:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234818AbjHBMtT (ORCPT ); Wed, 2 Aug 2023 08:49:19 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDEDA2D4A; Wed, 2 Aug 2023 05:49:16 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1bbc64f9a91so57190995ad.0; Wed, 02 Aug 2023 05:49:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690980556; x=1691585356; 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=KWetw+9fo7xpR+/Y1RDX5IOHvVHf8sfB8Rgzd3Bsv2A=; b=GIHzjFSzPcLYW4yJrPyLa5ImpMP+/3NnozdLXPCWfIEItaUDWT708653DBDRF9JDF1 7KJP2GCIClBAH9TSQ1KVLatrwc9yTBnkpzhENvv4RrL7sEfnb7UiXjrEyIlloYFhdoPb kV1D/qaJGKouufSXYhMmCQ6s3RuM7Snwrzt8TCemadIkH1WZ+Bjv5jWhtNkd1ZyZsdBX V9GoTGqzCtbsRZqsjZNFncaj+eA6BDJ5scmBkGEoP4jvts/pO08/1t3W/xVXwEtFegRb mzsuOG7V5o6E5TBzDQ56qCiReA6n102vgs9RiJ+P/P0i3axrYk1X/byHeLt3snHWyPwR aBRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690980556; x=1691585356; 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=KWetw+9fo7xpR+/Y1RDX5IOHvVHf8sfB8Rgzd3Bsv2A=; b=RMSoKbTxu3CpfqqqlJ8ThXzPCJWfgfEffOJ+UcwW8a6y1beW0RG+b/SnFhC7ISv7J6 klf1g5KJosImE4XA5lCwxTdElzxzIzEKRC0anRqfTGYZHTVq8E9nMA1Y+cABTICiWdRP OHmV6+J8uJE9ck4nuSaKbeL6ikmaHwioqzGVwbM75G4EfS7TuTVPUGwD+vMBipJ9CoFJ gm4BhbZQmuCudJuwOKc/M9CrGWR/WtIRyToMm4D4+1u7gP5ml1CdIZcUVMiVscAheDag gb9ROKYR/7ZZ7mXxZ+GF6Ro/JyERrMXvaxUr00+8PvzN3zMaR8rEvsrP6ROALB8f1g1A O51g== X-Gm-Message-State: ABy/qLZuDCHWBNqKL7p9vDfX2eQe2sthYRGpbuwsAicoEU7GhDk9tWvK TlQSUNChgeVRSVxMwds3nks= X-Received: by 2002:a17:902:f551:b0:1ae:8892:7d27 with SMTP id h17-20020a170902f55100b001ae88927d27mr17956049plf.42.1690980556116; Wed, 02 Aug 2023 05:49:16 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.17]) by smtp.googlemail.com with ESMTPSA id x34-20020a17090a6c2500b00264044cca0fsm4811993pjj.1.2023.08.02.05.49.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:49:15 -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 v5 7/7] perf sched: prefer to use prev_state_char introduced in sched_switch Date: Wed, 2 Aug 2023 08:47:30 -0400 Message-ID: <20230802124840.335638-8-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802124840.335638-1-zegao@tencent.com> References: <20230802124840.335638-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_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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773123851320776342 X-GMAIL-MSGID: 1773123851320776342 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 --- tools/perf/builtin-sched.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index eb310d1a7625..7f76ba51e36d 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -837,7 +837,7 @@ replay_wakeup_event(struct perf_sched *sched, static inline char task_state_char(int state) { - static const char state_to_char[] = "RSDTtXZPI"; + static const char state_to_char[] = "RSDTtXZPIp"; unsigned bit = state ? ffs(state) : 0; return bit < sizeof(state_to_char) - 1 ? state_to_char[bit] : '?'; } @@ -845,8 +845,20 @@ static inline char task_state_char(int state) static inline char get_task_prev_state(struct evsel *evsel, struct perf_sample *sample) { - const int prev_state = evsel__intval(evsel, sample, "prev_state"); - return task_state_char(prev_state); + char prev_state_char; + int prev_state; + + //prefer to use prev_state_char + if (evsel__field(evsel, "prev_state_char")) + prev_state_char = (char) evsel__intval(evsel, + sample, "prev_state_char"); + else { + prev_state = (int) evsel__intval(evsel, + sample, "prev_state"); + prev_state_char = task_state_char(prev_state); + } + + return prev_state_char; } static int replay_switch_event(struct perf_sched *sched, @@ -2143,7 +2155,7 @@ static void timehist_update_runtime_stats(struct thread_runtime *r, else if (r->last_time) { u64 dt_wait = tprev - r->last_time; - if (r->last_state == 'R') + if (r->last_state == 'R' || r->last_state == 'p') r->dt_preempt = dt_wait; else if (r->last_state == 'D') r->dt_iowait = dt_wait;