From patchwork Wed Aug 2 12:09:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 129836 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp461218vqx; Wed, 2 Aug 2023 06:35:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlHTawlTLRDemREvGJkjOp2i0l5ZgnCTWqIX+Y8M9jXIVsIOvV8HSXAfGcsIQLIFRmx5XZFe X-Received: by 2002:a05:6e02:10d0:b0:346:7502:aeaa with SMTP id s16-20020a056e0210d000b003467502aeaamr13260499ilj.18.1690983323350; Wed, 02 Aug 2023 06:35:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690983323; cv=none; d=google.com; s=arc-20160816; b=yejv7+tOSNnRm5vr8VFFe2HJIUaPrMIUgVYSVQy/soRUrytaO8aNYN6Fgs26C8xpeo /j59eA7ZY9s+ZJxqTnvEuB1yJGUay6vu4yb4mm/qF4an75ZHT6J7u0E2swuJVjlfr2Kk 4h+uMGPhWnDGp7VCbSR5PbhUiPgqJCPxh8d1VLQYN4sNrnkfwkQD+cECXizReX1YL+vG AZ6cSDNSHn0LDCvLzQOWnJO/s+5XOuP8Qg7zxb/QfrBVU5b1rP1lTUqvwy3FebvZQnnT 7vIH/VtagNzTWUgmwkpNMzNLVNuFMq+4hIWiEq+Z/YcBhrlC6fCtCjbQ23WYfDWqHA/u r3kA== 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=OqjfD/RL+k6bTKIksMVTPU+J5BvaOOS810Q0Em/J47DrPS6dZmWayDE4TRvJ3o2+T+ VMsNGz9lZ6j/PhN1dwa2BdDPBToEeI2FmkYIKvaQu43y/ETg/CjOIs8XBpg81eAP7X3/ RziUayTWfAEyaBZQxqCDzVIkirvVt/rVh3SRMGan1CYPNM0dsVYdyeWiaxgulib+Xw1/ aILBBvOpJgOMk76VJCu/YiNBhXPoX7CqfBR5mQdcDqIuVn7DSSrZrbSrq6jXhtHL50CI vVyEQG9jrKwpgA6fVK6JmIOwSSik6FdD1y6oD/JRSssiPjuyT7pLM1CwM8x5Q8G98fEc VS2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=qDhWpMiP; 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 q20-20020a656854000000b00563eda6a8efsi6069907pgt.234.2023.08.02.06.34.38; Wed, 02 Aug 2023 06:35:23 -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=qDhWpMiP; 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 S234440AbjHBMLf (ORCPT + 99 others); Wed, 2 Aug 2023 08:11:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231171AbjHBMLa (ORCPT ); Wed, 2 Aug 2023 08:11:30 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50BBF1BF9; Wed, 2 Aug 2023 05:11:29 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1b9c5e07c1bso57245955ad.2; Wed, 02 Aug 2023 05:11:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690978289; x=1691583089; 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=qDhWpMiPmib0qqnREtOztQZpDsTPdJdWHHMZI23ihdKILrWa9RKCZKneIgluadIyZV k/DsHqzpgh6zo+z0WUcVasAAtxg8wCEIs2YEl4RBmRyoXr9upFn+lca+ZIMRl9p7ysIX gZNZ6xxkEL9DfCNTvL6vQw2J3VlGXgBnpr5A/AYAG6Ymopo8OVNeBofOyPSVLxDDUHHd uOGCP7/mSJomw/L6ZjWH3qg+O8qfQvxIfoQbf4nVoYjQTdechqL/vwrxfsjD1vyzGUGz sL8Xh7n6VyvBeHlEePIscQm0rL23Mdw1HvtiIc2dTLUqumsgeV9dyFWY69Sg02nqdYyz mhQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690978289; x=1691583089; 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=VPxAOWpMBoIy9/34zfY4MxeERHARZW6TZ7ba0tptNyrHIHksM6Qzdx/84+UTgy+S0j /Wgy4KIglTsBoU7aHgb1IMSb9/UoMb1cBIG+njZuQiWOJk6epUKRNIU6Hx2evRILjGOc rGnWZZEIXTwmykkzJimWQNnhUMwNqcG6xfG72P59LA1Cm0QWUpe8LsizJbV/cO1Z49xG YV+xg8p+8hY4LA2CLtWKXtw3UK+xsesTVTmIXCsbOSiAd6uEwxPFGjsVoQhM/g7Z8CO3 2hie5KpjNCjue/geVOan/TnYYzJAaIPwp7+QD/kN0nakryQEb2Wa4RaqV1ELnsaC7Im+ WyAw== X-Gm-Message-State: ABy/qLbj/5KJUw7LY8+TKmzxGI0/O1ajdwjJuSYGrLQOHrS9eM/d5Ew7 SUlUXrbo0fyGmNtq9Rtnzlg= X-Received: by 2002:a17:902:7283:b0:1bc:1270:1bfd with SMTP id d3-20020a170902728300b001bc12701bfdmr7909491pll.55.1690978288680; Wed, 02 Aug 2023 05:11:28 -0700 (PDT) Received: from localhost.localdomain ([43.132.98.115]) by smtp.googlemail.com with ESMTPSA id kx14-20020a170902f94e00b001b890009634sm12293173plb.139.2023.08.02.05.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:11:28 -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:09:56 -0400 Message-ID: <20230802121116.324604-2-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802121116.324604-1-zegao@tencent.com> References: <20230802121116.324604-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: 1773124529109910126 X-GMAIL-MSGID: 1773124529109910126 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:09:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 129821 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp446495vqx; Wed, 2 Aug 2023 06:12:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlFT4/e92PoD54FuaqAAmDcTlRKEcBIaZ1ikdxOEnmIvg5E2ukLLGo31MdHjJnmOHTL1gDKl X-Received: by 2002:a05:6a21:4887:b0:134:e14c:851b with SMTP id av7-20020a056a21488700b00134e14c851bmr14948796pzc.23.1690981952136; Wed, 02 Aug 2023 06:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690981952; cv=none; d=google.com; s=arc-20160816; b=OfyJCNsyAWGFYOsMJq+IU+KV/feV1Eu44AJNW18cCDteAgX2ls+GDpSYivhdAbt3qf OFVPFT+gbo9xIdAWoH6jWdt4y9RGth5w6WinW7F+X74U0ZOu/zgIDkYaPIBlEHNHQdu5 4uP+GTcxgFcC51u+AtHjijy9PIGo0Un6yerlg9rXSUIaddPGquqgM05RH9xXDTMymLsg lofmjsvRn2q65j2FjcMPrFVf3cKjvfSfdnQFFn1TQGXcLHqasH5hojOHYK2ZGNnMZTIC 5pCEB5IcxdWHKvX5HwrIgd6JUYAXs6f94cUfZQbXRsEz4I5Cb/PgbhHnhRhTasLMFzke zRew== 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=QMwGk7rqssSAGhj7vNRsmygfgKVCaIWXJ1YRE7kR0YA=; fh=KxelqS1vSd6AMLVGC49oyyDD8tvbYlRF2dLroWHbcXM=; b=MQPAVDISXxRGJ+f2cwkAzhCDPIMkT/x+nxJL1uOq2yjfmmg62R3kPLQyrEzQtYEulK aF0daXSRHDcmoGMTOGFdzvtOfEtswGPPwX7K4jO6fOsOgib1OZFP1WDy56c18mhPPqPm E31WuyBUiRdwvcMK+5xiamvVa8RQcZCvMCEVs79lj5C5vUw7UGM8Pz7K/zvReMSphwd2 F/vj6/4gk+0o/RjxW3YF0W4t5m4pSyNKZF7HKwkCOxnGPk/wtXeX/J4JEYLhYaqtIDMB xZQZ0vL841HY4N652EQj8WOp53ufeGeDGLkj+iZlBUWEgTMwQRy9wruyktxHYa5E9LCj eSrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Vzy2N+AG; 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 z3-20020a633303000000b00563ea86ad90si10716550pgz.464.2023.08.02.06.12.09; Wed, 02 Aug 2023 06:12:32 -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=Vzy2N+AG; 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 S234447AbjHBMLh (ORCPT + 99 others); Wed, 2 Aug 2023 08:11:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234448AbjHBMLe (ORCPT ); Wed, 2 Aug 2023 08:11:34 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7965F2728; Wed, 2 Aug 2023 05:11:33 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1bb7b8390e8so42034925ad.2; Wed, 02 Aug 2023 05:11:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690978293; x=1691583093; 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=QMwGk7rqssSAGhj7vNRsmygfgKVCaIWXJ1YRE7kR0YA=; b=Vzy2N+AG7dXCqR617X1+uJMRtDJIV2AwsiOW8fmfACy6LxhPOYD0rTspFdUobZUJmh lNMZTDfIHwePI8PXV3YiW8lJwRqwM9DBjyeKLRu5CSZr5+OBxJyzNfbIU6JSqxdsdw1F 95A12YLXqO+ZV/zztH2/rtV7BsQ2dSJp/Shqalt7QLltqXCfQZ+6mNet7+5ajVek81/F ZLmRvlmNBYrs4aOosyWxMIbTvKOznBcE4rlfSZRK1VZVrW6vl9c3PeDKMqGbt8Tzeb7x nO8WhNhRpkcrVJk/B4w4jeynUyhxQLi8Ep43VnVA3ZGsEaEL34fEKHdLT7o2rx4ritzn Ay1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690978293; x=1691583093; 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=QMwGk7rqssSAGhj7vNRsmygfgKVCaIWXJ1YRE7kR0YA=; b=T3oYiAzHl3dW7nUjkSuVaXIJu91/YOXdQV06EDiw2E2o81wAp7EjK4NOe09qaUhml4 8kfZgUfjOwahjwUoe8SG40H+kS4xlnADthPsejfIwvzv9oidPNII103SPk0I0wrbyvKm 14rjle7aZF/DFe+eM4Tg9ZU6qNljqME6iwjNlHZKT135OXDk04H/x9pFgVal2tJiVFs5 onL5MsaoKSF8/NvGnc6SjDhPbsc32Sld6dnCpCvOnZdade/439MnDiGNJH815smJRjN+ P8aqsm8emfsDqSv1zMwh3VPbVNtCIGkkkVIciZlaayw09QSJhuJmYZsBAJe6HCXRrUds j+Ow== X-Gm-Message-State: ABy/qLbyLplCcs/waSd9CsC07jWEAtlx2FpCF5yFhrDjtgwdmXCeC4Vs 3ZF6KJn3FSzU/MUWGCWUv/8= X-Received: by 2002:a17:902:da83:b0:1bb:4861:d3a7 with SMTP id j3-20020a170902da8300b001bb4861d3a7mr14948719plx.16.1690978292854; Wed, 02 Aug 2023 05:11:32 -0700 (PDT) Received: from localhost.localdomain ([43.132.98.115]) by smtp.googlemail.com with ESMTPSA id kx14-20020a170902f94e00b001b890009634sm12293173plb.139.2023.08.02.05.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:11:32 -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 , Ze Gao Subject: [RFC PATCH v4 2/7] perf sched: sync state char array with the kernel Date: Wed, 2 Aug 2023 08:09:57 -0400 Message-ID: <20230802121116.324604-3-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802121116.324604-1-zegao@tencent.com> References: <20230802121116.324604-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: 1773123091354496010 X-GMAIL-MSGID: 1773123091354496010 From: Ze Gao 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:09:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 129877 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp521393vqx; Wed, 2 Aug 2023 08:04:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlGwUkPo89gCpV6YVUc7G7TQGVtP4KbHArddiNbeXitwUo6gXoGny5y3v2bXVf5+Trv0Evz/ X-Received: by 2002:a17:902:d303:b0:1b8:3dec:48de with SMTP id b3-20020a170902d30300b001b83dec48demr15163575plc.47.1690988684796; Wed, 02 Aug 2023 08:04:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690988684; cv=none; d=google.com; s=arc-20160816; b=ef87NHRgkOJAGSs0yq5yWDa8v4+85iwqC6wXVkFvCcFgUuMhFvGYIl4SsMLRK8zTXr Xmry7tCTUgvbpodDUJ2qhbUngi4oYX69aYpvMWJBdxR0o9QWPSB8rcOIBgMVUjOgTOv9 x46M67eZGbH5DRG+SCnkSS89Yb85t1mm9YriY+o0tU22W2h9OqQBC2LAFKtbRo+wMaJ5 JgURJNsdaCcuQEOtaMMqOFlxD5udI2lGXwETZQqFiuUHaUbTReRSBV9ysW7mGDYjDReU DQez1ux/JrWsTa2KzvR2862jWD84UsjJApBDdkq53v0vktg49KCNoWPnouWLCpz2QHXB Sz9Q== 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=sKqWYNfl8fJ68DijSnR03a2E90X7vE9zAdPb7C9K5/3XYNzlhEyWPAwGImyVAQ+3jK 5lruu7T4prXeXOwoea3LwlFX/+s5aDoG3Tah3Mrr4CWfJDNr6wHWW5urVqCBB+xDTIiz 5HQ8xtRy2PfBTdw9S3BWVNnmrTcyMZbAu9PfG+jO5GDvNLkuAUpSu663hl1sDb5DkxKu 1jZAcQmYPUVUORJ8/mNW3gHpj/72ECp4GyT2KY9zyzZ8wFJKod2zAuQ7AraRPhKqg3Z5 uUjRkmTJ5CI92C/ouyNHnSvhRanfHZuWsMiDZ7Nq0AedBGKk9C6HUmvRWNBpF0NSKwRw ehUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=sDgeP+W6; 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 h22-20020a170902ac9600b001bbcb3d9265si10858336plr.68.2023.08.02.08.04.07; Wed, 02 Aug 2023 08:04:44 -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=sDgeP+W6; 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 S234467AbjHBMLr (ORCPT + 99 others); Wed, 2 Aug 2023 08:11:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234462AbjHBMLk (ORCPT ); Wed, 2 Aug 2023 08:11:40 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A94E1271F; Wed, 2 Aug 2023 05:11:37 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1b8ad907ba4so43267905ad.0; Wed, 02 Aug 2023 05:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690978297; x=1691583097; 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=sDgeP+W6It3x/c+hnUfPaWiCAwbaeo0jUWBK6/dZhZk/YzMKkkI5MmcTIs/+J91v4r 7llUnq2bZ8J9DkJ2dKelVrQJ/27SQQNVwxqdQF896REqNipbyzgZtgHMjtANcCumrODk llX5/OjZiRiFEvMXqSWRCSpqeqKPID9XMVGWWAJu/LNqM3wWUbA2q22l17ddS83iWxBt bh/2cKzHn03XqrkyDg6CCwG5lxCDtdpb2yvg0tBMslgnVboQPDnVNs0lX+uFSICGVx2q XcN439Y/JoAzhBLWXANCXqLXxyIrF2lQrI6vnKZv5lAuCK4zuRYkB3aDhUHHiR8ivQ0H bXfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690978297; x=1691583097; 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=KlDD5Q8lLco/9a4u3dTXQu/W2k+w8VrEBU3Q7YMMORADc2caFAJU+AY7ZMbIpw53KQ 2vN1ZlnsVnD75T2WrXBVTSTUCJNkStMsG8f15NRiMDS6ysjaFvmxRzT5O3rb96SXgZCA D+n+Z6lzfiSjAbWvSSv9NM8DuaO62vDY2Gqte8fRuZZk90x/ALAiwSdEuJal/ED9DGmi 6TwIiFxE8e0+sdnj326yCZL/0NU4q7S/aAfyz+ZFC97PZMl+yoOn3K8M6fdIfIDMhf59 ONRYi2za3oY1Q19RqjtdgSASz0BzUrxDdPY+xXbmO99eeBYbNGtJ5YOVF4IU9J+pgFb9 9DkA== X-Gm-Message-State: AOJu0Yw/JuToomx7komC73HbzPrSFl7Jvx+s0oedJheE8QeuMQHSXEIQ JQQhq0IjZPA+59f++mRL91c= X-Received: by 2002:a17:902:efc9:b0:1bc:3944:9391 with SMTP id ja9-20020a170902efc900b001bc39449391mr353150plb.25.1690978296884; Wed, 02 Aug 2023 05:11:36 -0700 (PDT) Received: from localhost.localdomain ([43.132.98.115]) by smtp.googlemail.com with ESMTPSA id kx14-20020a170902f94e00b001b890009634sm12293173plb.139.2023.08.02.05.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:11:36 -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 3/7] perf sched: reorganize sched-out task state report code Date: Wed, 2 Aug 2023 08:09:58 -0400 Message-ID: <20230802121116.324604-4-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802121116.324604-1-zegao@tencent.com> References: <20230802121116.324604-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: 1773130150681817683 X-GMAIL-MSGID: 1773130150681817683 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:09:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 129841 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp464632vqx; Wed, 2 Aug 2023 06:41:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlFM82S16GRzhBwoJYH5Vu6sMo3AS+RnssO38acJDtmwhxGG+tlSI1MjyEaK3lG5PUROHSwy X-Received: by 2002:a05:6871:28a:b0:1bf:304f:80cd with SMTP id i10-20020a056871028a00b001bf304f80cdmr2742568oae.51.1690983661778; Wed, 02 Aug 2023 06:41:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690983661; cv=none; d=google.com; s=arc-20160816; b=HUprFX482roYM7t0Ia9zWBbmMpdfiIQp1ZtAp2JRMfmOtXFamWSvLtTH626lU+FHII wbdJ10DTVDLB9A1kGUfRkempgcC3YMYs2aAtfyfegy/EuToStQBytL/LBHji7qJ0eXVc BeZqd0fVjJUjf23HkCKbUoW8n+5VNpNVwiXwbhQMm0ShAsTUnHuxIKz93NlvUst+kV8Q vnVhKg9+gJHFkO7iXUKNyFdsbgNaXDVMbEPToHoSzJRfPECjVVDVD5xwSzHrIrZEP3z9 bJIwz8ecROxgEIoT3VL5bwe5tIFSuq2mUzLCsMrINdkbZpeLCeyHMCI6NkB9bKgiYOB5 gXgg== 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=A56hq21QDHutjmlsgYiCNksVDWHMEJru0EKZ0qnQsm8=; fh=KxelqS1vSd6AMLVGC49oyyDD8tvbYlRF2dLroWHbcXM=; b=Vr5xw5iLpvWW1vr626AYx0R1n04XHSW0Gtr7Mp9BuagItMs3bItN+lxnYUEkC8aBUC 8kjkjpYeS76sGi10Swc1p43/xO7J1rWQnzDK1/lZIE4OQViJNjw5qGx6K7JRHTj9yuGX Hhy6lW2IOW/3YatmFgJfG3XtBaSjraxuoDGN8oNk70lKDix3dQBx+rd1Al9R/W/W0heu f/VisEKX0yrU58spOubpWYjS4hBbRvXxaeO4bIHe+2KxWh6t/Y2xHy+tvJvHG+vgajJR ce6nh/TUGFSMB+RKTJh6ImZ1i4OD8uCxcbTY/gzfVwLAovoIMMi2wLj+QhFcFZ03/9G8 FmFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="n3Fh/1G/"; 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 mu5-20020a17090b388500b00267ba6a708bsi1296593pjb.166.2023.08.02.06.40.47; Wed, 02 Aug 2023 06:41:01 -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="n3Fh/1G/"; 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 S234489AbjHBMMG (ORCPT + 99 others); Wed, 2 Aug 2023 08:12:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234474AbjHBML4 (ORCPT ); Wed, 2 Aug 2023 08:11:56 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E91372D7B; Wed, 2 Aug 2023 05:11:42 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1bb7b8390e8so42036255ad.2; Wed, 02 Aug 2023 05:11:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690978301; x=1691583101; 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=A56hq21QDHutjmlsgYiCNksVDWHMEJru0EKZ0qnQsm8=; b=n3Fh/1G/jOeXdtg68kIR9ZBYRGKFax3mlHfOidugyA695m2zqgO5mbpqiXdGYSHYXI yHekuRo90hIwLhSpa6FVeD17JR1QSvtaTjNv955Ou7ygGTBAadw01lS2o5nzy0BHcEs4 pcMydd1VKO4YvnmpuwycOelDmHEYTFnERZlMQF7r7nBpeWrygj/0oZFuebY/Y9nc5eHS ueJU8zHnVig7A5/bYW016eAXkRwPCB3rYTnswo+htRWXYM2t1nCxlhZ9cQWCtxSbNrUu 2YiOCISGpUih35t8wYiPMpGGA+QVSfRTfW3bRoW20ew3csNgVhzkVx39nvVG5fvHpYEt vZsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690978301; x=1691583101; 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=A56hq21QDHutjmlsgYiCNksVDWHMEJru0EKZ0qnQsm8=; b=gQ8T2d8AwycydDhUyUmAU0S3anRIMw5fJsrsZRNQfZeLR/ntcfQMYG7oPltGYIjOv+ UjoLlU8KCcxUTU5uByeS5EhnD3xgyFiyAPoyD9GGrgv1Zo0axD0y3oDeevUej07BALtK zkcOqn+qJ/AccPPHBpvYg4lMBQY1wUkYtoZ85HSi+bG8QV9EYnrOYncfD45aVoL8mVxx uArVbABSlM6cazXGln+ZQmwruGhetcXWMLr73tzaOiK9GnqLmiMEEkwb58L0NWU2faCc WFVD+dKUJOPJWqaQy+/f8SGvFSrm7rhbnUKngXpsltnq3PTQy8ybE9azmCOUNNi2y7q3 JCgQ== X-Gm-Message-State: ABy/qLavUnb2tefcvA6DU+8DVpava4p/9gdwsiE6IqakMn/UlSAAEzyY fhIx/0T3uU1++Dsb/vRVeWE= X-Received: by 2002:a17:903:2301:b0:1b8:9f6a:39de with SMTP id d1-20020a170903230100b001b89f6a39demr15067440plh.65.1690978301071; Wed, 02 Aug 2023 05:11:41 -0700 (PDT) Received: from localhost.localdomain ([43.132.98.115]) by smtp.googlemail.com with ESMTPSA id kx14-20020a170902f94e00b001b890009634sm12293173plb.139.2023.08.02.05.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:11:40 -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 , Ze Gao Subject: [RFC PATCH v4 4/7] sched, tracing: reorganize fields of switch event struct Date: Wed, 2 Aug 2023 08:09:59 -0400 Message-ID: <20230802121116.324604-5-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802121116.324604-1-zegao@tencent.com> References: <20230802121116.324604-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: 1773124884368447296 X-GMAIL-MSGID: 1773124884368447296 From: Ze Gao 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:10:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 129815 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp422526vqx; Wed, 2 Aug 2023 05:34:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlHAKYqq/cmTokHZEFXMjqzS+fnAiOLWo2kOywIbXwZ5Fk8bBCtVSCsIURI+ncslh9pI6msN X-Received: by 2002:a05:6870:82a4:b0:1be:d3a1:fd9 with SMTP id q36-20020a05687082a400b001bed3a10fd9mr10206816oae.9.1690979697681; Wed, 02 Aug 2023 05:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690979697; cv=none; d=google.com; s=arc-20160816; b=RUGzO80C+CIlcPC//BTfEjFp23OMc9ilnCxbULk8VprpCDCF6Shs17vlAKM1NHnAZM 05cLcrfzHbkNM9L1dkHhXi7vKNMo/I8/HwofAt9ds/AlKXyU1epJkIY4KdirVhx425TR ydoWfoxjxhew6YwLSWVInPyGl+7uoGDpQzaJzB5aUVB3X2szrR2suDD1KQGZUnxw0Mxn bWSUwEHhmLr7KKOqLyHRiXnxAB1xZQxaoOUW8z8w4ENNils8gEbUNz1QkGJBzS3Eh9EF h4ikcL0qrP7K5hY1pl+L2orVtVJMHCPW4xE636uz7ohj92tKwKyOYP4hJ/iMMZa1vjFn vY7A== 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=4CM5cahXoMpsce0ksxrUnsFD5Y5C6ho7KAY2TXexFWA=; fh=KxelqS1vSd6AMLVGC49oyyDD8tvbYlRF2dLroWHbcXM=; b=v6NfUpuv4EvW3ebCxf5aFdDi6D48AfJByGRU8MR5G0ouHg0qHctr+pfIdpUf4CP//F kCUaJ/iyEofGyHHzXnns1rRAEif/o7OtJTN5VjTYXokgqN1dHmHeiIz2E8VJ6Pwdl6t1 uEZtXwkpcVKGGHDF1+t8oqbSP+7grUlDT48+p+0OMAY+fvmVdz4/tR6bMDg9stO9c9Do 07DN7FcIEnuo0AA16xzVUQahe2npdSXrOSMlAdIf8yHNO8yt+qmQNpgYo2dpjLVPFqAV k9uMTUpQHDomEvbyoy0xALYrTWe618NxaiG6ZEuuSE9aA40tCvIs+78wPrrcwsdFOKVa ChIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=gdF734EW; 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 lc5-20020a170902fa8500b001b9d335175asi5916974plb.292.2023.08.02.05.34.24; Wed, 02 Aug 2023 05:34:57 -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=gdF734EW; 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 S234488AbjHBMMU (ORCPT + 99 others); Wed, 2 Aug 2023 08:12:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234485AbjHBMMF (ORCPT ); Wed, 2 Aug 2023 08:12:05 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20D252D4E; Wed, 2 Aug 2023 05:11:46 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1b8ad356f03so42082075ad.1; Wed, 02 Aug 2023 05:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690978305; x=1691583105; 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=4CM5cahXoMpsce0ksxrUnsFD5Y5C6ho7KAY2TXexFWA=; b=gdF734EWkU9OnMkBaivwtHzXYRbnETPo8fXWApDkqnoLjTTcWM52zjCepXhgLv60rX uu+x/g2BUXJVYS4AHV6VldapUIFlSNcOljFQqaMKw0OXopwyC+t07nuB2NQrQrUGwpKP 3Ba26I0T0zih86GAv8qkWRqlzQH+z8sFvK61LfO5j3JqTDt8klfrTPz+RU80nVnUffd0 QvRbFRRxg7LKp62u8xqpyHTG9b/hD8GX1fop07TZQfZggg8W0UQ4OSXBZgTQtolVFA4a gvHpGxkwcgKxiG1t5NU358WhWE3oGtkMSOGtPTdW28a7NrY5201jmIBcUIY5EcPC0OIn uBhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690978305; x=1691583105; 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=4CM5cahXoMpsce0ksxrUnsFD5Y5C6ho7KAY2TXexFWA=; b=iUq0hEQel3C7sT+VaOqmJE39TWp2PJSD673kKWVgaeHS0rL2eTdLL2zPsWPK2q5Ku+ tcjgBtza12cpjwTvUhdGF5onTvUw2CrNMczhe8PvNsWmLoUkNdl+b/ESqXB++QHF5GUz 7ABJYY+fednX1tmq/cMqAo8SyuCAyYlGWzgFWwekBv6kxgKCvw9YGT91mjug1WQy5PK7 sOEt0gqQFpwY2iVIpTR22BDsFN1NhNTAQdID0MyJba9tl8PtBgqX/hFMhCtkEWbuBfjX Z3z8LwTkXyLQ/DwYKJsVnHbBwdS2LHZOsgXIal3ACQOJGIqvEZUumeu0jqh3Sw/QTMwi ravw== X-Gm-Message-State: ABy/qLYrdQpluuCYlUszfqmVRFX1eCqJb5QF47Ee85uF78wY042CmhPR QfN8ccNTK2KG7i7IScUnzP8= X-Received: by 2002:a17:903:1cb:b0:1b8:9044:9ede with SMTP id e11-20020a17090301cb00b001b890449edemr16848580plh.62.1690978305253; Wed, 02 Aug 2023 05:11:45 -0700 (PDT) Received: from localhost.localdomain ([43.132.98.115]) by smtp.googlemail.com with ESMTPSA id kx14-20020a170902f94e00b001b890009634sm12293173plb.139.2023.08.02.05.11.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:11:44 -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 , Ze Gao Subject: [RFC PATCH v4 5/7] sched, tracing: add to report task state in symbolic chars Date: Wed, 2 Aug 2023 08:10:00 -0400 Message-ID: <20230802121116.324604-6-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802121116.324604-1-zegao@tencent.com> References: <20230802121116.324604-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: 1773120727387231446 X-GMAIL-MSGID: 1773120727387231446 From: Ze Gao 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:10:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 129835 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp459569vqx; Wed, 2 Aug 2023 06:32:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlEda9IQXdbepOdqikOwElO6F6qwiAhFkFOoyG/ZEkn+DtTJbqSm1AmxbNq0ouyKtLudF1Zw X-Received: by 2002:a17:903:32cf:b0:1b9:d38d:efb1 with SMTP id i15-20020a17090332cf00b001b9d38defb1mr19962644plr.8.1690983177201; Wed, 02 Aug 2023 06:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690983177; cv=none; d=google.com; s=arc-20160816; b=yRyBLigrtdb+1TAnV4wH0zpYwmZbpfMCc0oYUf66Y7vV/GlHC3CwebTd1QthnwxnWd gdwvD/MHuhSZ3f6PxLCEMvX4wN/WHd1XP458vXtXfBnpLGo5Fi4FDw/CksdwSfc+9YUo xrGONUw8V9e459T1Mu7l+mym6uSOv4835I1q9PLUPEFBmuMJ/3S/Q7i8dQ6sZJ7VYwWe we5LezEkjwIYhMG20FlCpegc4xzia5Yb6FZU+MLPPakitn/7YK7pzDzP1oPXuS0dtBcF 4BO+8B4DYJA7q/oJ5zdGfNGTGHq4LnrtTa1tSzV9RpSF7GXmwVF3wKEvcS4IyIMAGk8P AL2A== 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=uQdvhi1jV+gQvKP8U/k6QSpXkWBmxR7w0ndZ0C5z2WRhEe3IEMhHQ3jBpwBQjaE4Qu skLHgxz44MvY3vemKBry0DUGrt2gWY2nzEFf6NcX3nQlU4BeFBTX8fRspTEE/9gPRLOC NBjR2jflX1y8UImR1OrpJ4zAWkIFUhhWKHyP8re3b9Ulq2vfWES8M3a7DWwwgKYGHtBR 0Ho1xWb4hZE0GQR1PnM7pvy8D6Yb1zsNk/2dNyRR/u/cjqLVFM3bh4veQkRO+4UTVZG2 SvrxqZa0kyUvXZxJ5p/WKhjf6szYMTAvdxaPPsSUT0so8mXPndpOl0vgk/ucLvkMyPET E/3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=PaK8I2pk; 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 b7-20020a170902650700b001bc3948d598si405103plk.448.2023.08.02.06.32.36; Wed, 02 Aug 2023 06:32:57 -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=PaK8I2pk; 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 S234515AbjHBMMZ (ORCPT + 99 others); Wed, 2 Aug 2023 08:12:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234502AbjHBMMR (ORCPT ); Wed, 2 Aug 2023 08:12:17 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A70D12D67; Wed, 2 Aug 2023 05:11:50 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1bbc06f830aso6317755ad.0; Wed, 02 Aug 2023 05:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690978309; x=1691583109; 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=PaK8I2pkE/WPQvl+laJR/GJw/w02Y7dJDqAA5GgpevxcqOGG13yboTTT5Md2wJv3ST yUlTF6785qm0HTky1cm31dKOVmmyaC2APjqWE/34WvEn5iwWl84Ejox14uRwoXk3rRt2 bVtriVwHhLSWlbP2gpRrpvXL4Jf0pW/EwwkVGaJKanE8iE0ySp6KmC18f4rmIp41nSmx X8lk8qU34Vja2V/FTZ3tXVTr3pc8THhHVGBLOtTxsPbWYAMn+CltDI+c9lpn1Lh3hFW9 KRo1d9RaIXDsBHf7kWoSm0tq0VPVB19gUhxt+Iwl65AxQQluEOIx0brGxn9Er0rC9w0N MxqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690978309; x=1691583109; 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=FMK8hjm16VdCZQ/x752e9cwkAUOC4z3HJUyGCx3QsVmEoQUeODfCmBBM6LfmTMwcUF gvGyAu5wAr7KIU9V487n3fndFWpuXi6fjVCYUnhWIbQxayYASb9I0mIuw23hfAPEbe3v HzppD/5yOvpTxZGsLONddf4VwK9oZdMLkUW1uyGZqbh6//vl3GMjSIbBQLeKZUoPWsWL SnhYXUviuZa/QGWVFywo+M3xJRGPkTNqDkGOgZzLBgkJ2yKvccYQgZRCuqP6kt+ujfUv oejRYQgrTZ0coCYiiLjNTEyXFQxXYXUkmzFZhOWcFWW3vtv8ri7dcN3rkBzWao+nafbQ tO7w== X-Gm-Message-State: ABy/qLbU2GpVcHAEjtnP8cO4BIhbtl8jhnDEkwz2LFqcW3RTZ6IkQe/I VYk2EcpnPRRXJ++t8Nxg0EI= X-Received: by 2002:a17:902:d511:b0:1b8:76cb:c6a4 with SMTP id b17-20020a170902d51100b001b876cbc6a4mr20219434plg.21.1690978309236; Wed, 02 Aug 2023 05:11:49 -0700 (PDT) Received: from localhost.localdomain ([43.132.98.115]) by smtp.googlemail.com with ESMTPSA id kx14-20020a170902f94e00b001b890009634sm12293173plb.139.2023.08.02.05.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:11:48 -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] perf sched: prefer to use prev_state_char introduced in sched_switch Date: Wed, 2 Aug 2023 08:10:01 -0400 Message-ID: <20230802121116.324604-7-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802121116.324604-1-zegao@tencent.com> References: <20230802121116.324604-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: 1773124375598004737 X-GMAIL-MSGID: 1773124375598004737 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; From patchwork Wed Aug 2 12:10:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 129826 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp449405vqx; Wed, 2 Aug 2023 06:16:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlHqOJb5apaqyq5WNe/rN44zKCxBFGY+/Sdp840dXzl/NbIMI0NEC6JsJnkRlPle4no4qwf6 X-Received: by 2002:a05:6a00:1c9f:b0:687:1300:22ff with SMTP id y31-20020a056a001c9f00b00687130022ffmr17917231pfw.1.1690982185688; Wed, 02 Aug 2023 06:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690982185; cv=none; d=google.com; s=arc-20160816; b=Sng9vj+UCILOLg3F7aCaTJ/hGHS5unvY/IO7FTlyiU4HnuefFjJcOGb7bPaOWVyYl8 vW2sgDjqUz2jMUddSVl9b7HqrcoOxpr9BBNKxYToHJeueAaquGTZ9GQwZWCeHZ+qArRt dFRYQTYAN0+6HtJ1f+BRabUlHifHzjssO1HOUlssI0p4uPyQLObJenWBKf+CGgxQ/cot 1hBFzr5RxOpdTs3PLn5u5sphrANxAPlRGBQVO/CaLNOIWB/lXZGci5YSMkurz5gFKxFC sE/8TLrmf6xH32lxI8b3gEr3uHPFt0mQeka/8uhhhGBai5sWWXNy2EU3o/sYXAhct4BH xZsA== 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=l/td3nf4tHwphkvDtklizAJ9WUNfvr+0DJJyQs0vF0PsZgLconvMWRijeqQF1UW7HI G0N2T5DLWBHWUR7/1VltRM/NG8DVliv3mh/X8OL1xeIP8r85H+uzXJEcDWaHWfzDL7DH J8A/l8Ffbj8nR1rPgn+w1+0SX+UhobdKinrhG3lEecKsZ/qleXRxwYz5JZP6ADKBgdDC v29YTLsIZGiARThJTnjhFfKnsvHhaeVItvjBuUCcOV9K6zymX3tfmPtany3T5q6L8ZJN Y2iJpx7Eh+U4cRxE/pAiiyeFHsWJe6dML3pPhSlAkp+9uFk+ZHsTrf/wC1PzbsuxZ1Xd 23sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mc45Emmt; 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 h11-20020a056a00170b00b006797c2c00besi8204118pfc.144.2023.08.02.06.16.05; Wed, 02 Aug 2023 06:16: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=mc45Emmt; 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 S234491AbjHBMMi (ORCPT + 99 others); Wed, 2 Aug 2023 08:12:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233845AbjHBMMW (ORCPT ); Wed, 2 Aug 2023 08:12:22 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1B623598; Wed, 2 Aug 2023 05:11:54 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1bb775625e2so6239035ad.1; Wed, 02 Aug 2023 05:11:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690978313; x=1691583113; 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=mc45EmmtV/Q7oq8TvX7NxwbUG3N2cWSLCMYDnJhAaGMTC3hdT7RjVpSaZNs+mFSdQ9 v5bWNo26P1bPdS9OyeYlyyK+t0enQvHxYSETe/5pKPfT45ajR2+u6Gj+onzM582zPJLk LXLXdhhgzmxiO+b70ZwZAP6Jb1b45c/0XHxpCoYaPLMQMBYxHC7zLf5PG90xKEG3qZGO c2qBaWhWp6QU9wbOE0k7J1esoKTsll8myh2eOuD3SZffaOl75HFZPCeVSSb9QlkfYxTK LF37kESuUQtd6tX6mJWDSeSw+u4bNdFmZPJylzbxjmuQK6t3+KXwfLpvFqVtb5MXxylT WHFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690978313; x=1691583113; 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=KDt6hlyH24pe5ZhMuirPmSSwrw/gKrY1s+11BGNlzOev1cey9OODeZKyrAC0DKhXP3 UuH9v9w2SpTKwd6DECSuYK02yRay8jK1Qy3oYvvz5NUZDFwUJBNpaQ7+xDhFrDiZDQ3w jGupCixohev/J+BXVLGuDV6219rfLSCg9fhdUIIAMP6AXDYA8HSG73RH9FxIj+TMbaFP 5xYFEiu9Kiv7rZkXIft9UEsC5IXxDb10Kp7HpVHjJZZxE0pCOWqHgL25e1Qr+x0NvyLd 5v2xN31pO9mPB83eAV21DrGkOVtt3zENCfqYqsK0ciP52WcekcXxokDRQlHxYwvpVhOh +pDw== X-Gm-Message-State: ABy/qLbSxlOCP8NAZ7JqiBYupPYeRxI0+Pcs1ZZHbaCgAhV4/K6CspXl 4JnlGkYZ2/MdXLMqfcZuJXlSPa3zMQLR6g== X-Received: by 2002:a17:902:e745:b0:1b8:af5e:853c with SMTP id p5-20020a170902e74500b001b8af5e853cmr20084789plf.26.1690978313225; Wed, 02 Aug 2023 05:11:53 -0700 (PDT) Received: from localhost.localdomain ([43.132.98.115]) by smtp.googlemail.com with ESMTPSA id kx14-20020a170902f94e00b001b890009634sm12293173plb.139.2023.08.02.05.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:11:52 -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 7/7] libtraceevent: prefer to use prev_state_char introduced in sched_switch Date: Wed, 2 Aug 2023 08:10:02 -0400 Message-ID: <20230802121116.324604-8-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802121116.324604-1-zegao@tencent.com> References: <20230802121116.324604-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: 1773123336420378307 X-GMAIL-MSGID: 1773123336420378307 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, " ==> ");