From patchwork Wed Aug 2 12:09:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 12998 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp421498vqx; Wed, 2 Aug 2023 05:33:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlFff+Y67km5JViAwtq9Ry845HK0kmTwxOmoFPKX1sRTknq+Nk2Zk4GTRIpNZ57758NoB4wQ X-Received: by 2002:a05:6870:fba3:b0:1be:f7d9:c0e6 with SMTP id kv35-20020a056870fba300b001bef7d9c0e6mr8077206oab.25.1690979586283; Wed, 02 Aug 2023 05:33:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690979586; cv=none; d=google.com; s=arc-20160816; b=J3tbUPkWSqg8R8qbfyVvCkPH2oXax8sb8VnMapQg8B391pho0jj8bOf36VsjASYUBh RcL38TWfhUo36hlGFnwc8HTTvPVxmtEjBxis1sDn9V+cPDyar+m+BdEJkRXOpVKgjgKP JaGRw4iPzMPRVWQeXwop47iRXKL5eWFc+1JCSu9BJ0HH15SQjg07SOeMFAyCEGHt4N5j Id8UL6mWj7qeaxci6Hx1b/HAWB5yb7/Po5DLRFQrqnmeR4hsNqUkAonUPXgZ6CDIEdog 83DaVwWElhhZGp2GcYtfWJAccQzhOgpxGtx9KDXmBhY+YCdD+ZMXdpj/Y3IMTAYOLSdh tU+g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=R1tN7he8thFjPHDIsaNU+iObtY2VDwRBXwAdPdmLAVU=; fh=4S4dukURCUlSsjzSa0Ofy3qHSrrdu/uT1HnGBPj5BK4=; b=rEegCeRzEOxQ8UoehYgSBVHegjDGAFjnyf4pkBHyvMJWJxV6WGzpQtzuUmbg2ouPYl dqOX0UOhBzR5gNdv4GT/pA5TWT0MYSua/IJRJtYouroYt3itfvf4Zw3bQ2QXvrMrg9u5 z609h8lsDlaLeRmdSkUq7FqMrn3f/Lnm2UGOVCWXyymLIoLEi4+G04TA+8wGDr1CPBAv cxqX9V0V49ITHh8p0R7D+9FFBHi36GYOv0yb7E+Vgr3wRlmrGyUlRSsKKxcJB6V1dcHW TsbJnyHu4E3ioaVl9gpfQxiFabQMy+47GaFdWVtAJ796RTKMD9YgxZl/I5+K3iYV72wv mbRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=PHkgSovX; 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 t184-20020a6381c1000000b00563e2144201si8789438pgd.211.2023.08.02.05.32.43; Wed, 02 Aug 2023 05:33:06 -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=PHkgSovX; 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 S234336AbjHBML2 (ORCPT + 99 others); Wed, 2 Aug 2023 08:11:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231171AbjHBML0 (ORCPT ); Wed, 2 Aug 2023 08:11:26 -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 6CEA71BFD; Wed, 2 Aug 2023 05:11:25 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1bb8a89b975so40498115ad.1; Wed, 02 Aug 2023 05:11:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690978285; x=1691583085; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=R1tN7he8thFjPHDIsaNU+iObtY2VDwRBXwAdPdmLAVU=; b=PHkgSovXZglHHONXfGhOp6oeZzI+8ofMxRwHgOEl7N07Izh8MQUEfQIHdYclZV0tHG ZIs5DxgO6P3Usy5iStDU0lJFCP62I6pQ54EQnDTungm5++OEr/3M8fCDL8gQxuS/GmjD uYm1ZttXi2/7nCNlmzi5I2dv3KvRZ9aqKwMhNiwOXB99/FGzfwO+6BjKWIOwTAepMsFe 54OcwfWQaqERT5mRnhRWIuHlugZaatapUF8+MAS19w4pHNVuFDZnKadi19pCov4v8hyr TryOm0MlfaV1+kKoxa4sf4Eehq9P8TN6hnNxEncjdD0WhYw+cGP1uIheevVH35jpYIT6 TJRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690978285; x=1691583085; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=R1tN7he8thFjPHDIsaNU+iObtY2VDwRBXwAdPdmLAVU=; b=btXKOUmfiPcTG3kD3YN0q4IY+cSZ0ZngE7RIw5Pfm9BqYUYDa45rGUWt6g9I+Df0ru rktF/qizlm2H1NfIFnlLUMLSdNY48t/mcHGnDQYam1M7M+T7RFOAnHBJRkSyfdUHNBkZ oAkd4K/kGd3VedeGaJZxIEuzpdWj8omzqZi8bQr1RtIY//NOxPwWDmGFTw/9wCHz5XLo 4VLjMdpRClSZBgNbPdYT9CAtyzBWDKfHboe1YnP/dqfzejcrS7MSWwd1dt9czgoU/DoG loAUQWKX/4mqJmYsVgK9P88rIwuugbRgQevANC/z8iT3DfzXLJkWREorWv2ijdNHMPW0 Usjw== X-Gm-Message-State: AOJu0Yx4Q5kPbBImdKU8z5zrrk4A/vUuHMK56a0eMM2G40RBmqPrshAn rfFZRAG94t+uXFjDjrGKsBw= X-Received: by 2002:a17:902:b28b:b0:1bc:32f2:812a with SMTP id u11-20020a170902b28b00b001bc32f2812amr1623828plr.27.1690978284689; Wed, 02 Aug 2023 05:11:24 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 05:11:24 -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 0/7] fix task state report from sched tracepoint Date: Wed, 2 Aug 2023 08:09:55 -0400 Message-ID: <20230802121116.324604-1-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 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: 1773120610869150497 X-GMAIL-MSGID: 1773120610869150497 This is the 4th attempt to fix the report task state issue in sched tracepint, you can check out previous discussions here: v1: https://lore.kernel.org/linux-trace-kernel/20230725072254.32045-1-zegao@tencent.com v2: https://lore.kernel.org/linux-trace-kernel/20230726121618.19198-1-zegao@tencent.com v3: https://lore.kernel.org/linux-trace-kernel/20230801090124.8050-1-zegao@tencent.com Against v3, reorganize commits so that they can be cherry-picked individually if people indeed have strong opinion over this change. Note PATCH 1-4 are the normal fixes and cleanup whereas PATCH 5-7 introduce new changes. --- FYI, this series are designed not to break anything now and still do the 1-1 correspondence int-char mapping for each distinct task state we want to report, and thus will not lose any details intended for debug purposes. Of course, this might be compromised because of bugs introduced due to my stupidity. So your sage comments are very important and appreciated! -- In the status quo, we should see three different outcomes of the reported sched-out task state from perf-script, perf-sched-timehist, and Tp_printk of tracepoint sched_switch. And it's not hard to figure out that the former two are built upon the third one, and the reason why we see this inconsistency is that the former two does not catch up with the internal change of reported task state definitions as the kernel evolves. IMHO, exporting internal representations of task state in the tracepoint sched_switch is not a good practice and not encouraged at all, which can easily break userspace tools that relies on it. Especially when tracepoints are massively used in many observability tools nowadays due to its stable nature, which makes them no longer used for debug only purpose and we should be careful to decide what ought to be reported to userspace and what ought not. Therefore, to fix the issues mentioned above for good, I proposed to add a new variable to report task state in sched_switch with a symbolic char along with the old hardcoded value, and save the further processing of userspace tools and spare them from knowing implementation details in the kernel. After this patch seires, we report 'RSDTtXZPI' the same as in procfs, plus a 'p' which denotes PREEMP_ACTIVE and is used for sched_switch tracepoint only. Reviews welcome! Regards, Ze -- Ze Gao (5): perf sched: sync state char array with the kernel perf sched: reorganize sched-out task state report code sched, tracing: reorganize fields of switch event struct sched, tracing: add to report task state in symbolic chars perf sched: prefer to use prev_state_char introduced in sched_switch include/trace/events/sched.h | 68 +++++++++++++++++------------- tools/perf/builtin-sched.c | 82 ++++++++++++++++-------------------- 2 files changed, 76 insertions(+), 74 deletions(-) Ze Gao (2): libtraceevent: sync state char array with the kernel libtraceevent: prefer to use prev_state_char introduced in sched_switch plugins/plugin_sched_switch.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)