From patchwork Mon Jan 22 07:08:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 19228 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2411050dyb; Sun, 21 Jan 2024 23:19:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2UiP0oFSY9W4/APEzhycTW2ZQs25tRr4GowaUZYWBjin90caTUXeoPNIzkyNSBz8gd5YW X-Received: by 2002:a05:6358:5907:b0:176:54b3:c7a with SMTP id g7-20020a056358590700b0017654b30c7amr1165567rwf.8.1705907969969; Sun, 21 Jan 2024 23:19:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705907969; cv=pass; d=google.com; s=arc-20160816; b=GdAxiDk9xc4mjlPf+HI4Qx0eSdTElD8C/hUoo9z8IgW1/PFDpMRe5XpRIOFHb4rity 3n9GQCtWZhiXORP0G8wmOZh44bfENLNX0dMZlFKdbHSno2YhnqWKvSUrS07Vzu5mlIVM /BDICu8ukwxO/uPKvTdqxKb3vxhFpeXmHS90ASgzZf6UDBG4odQM8lLjj318i1+2+97C +bexvqkI9tAwl5rbAEBgVVKR2yHt9FnfFKvmyjg207UMQ9E36+YpPWYtRMEJPwLTrVVI ccIg7nHsYuRcP5nmjk3apWr5IpKxkKPfYMnJTIl3Cq3wlQNKiveio8doCwJFDnCezjV+ 6vKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=hRxQwZAfT0nFVIiBEP7efXSgrXaSHC5qjp535Z9j6as=; fh=BA7X0Fh+nH6aOBOR/HncHKQUGXeIUOSOgeWoVcIZnUI=; b=ZTHn10/+Y5DvHUuTx2y0tVS4CinvWp4kHsasxV6tLTISUFCJYHTDS73t8WYy6wsfbk c8qLSAcoX3BP4W8msa5S8CqNl4Oo1sD0dtlyR5kxSGjF0SaW8eTYFOs0jQuirlgp/bl3 2OMvwx0S6yfoIwfN3IKUgt03/N8iRXiaiPcrmwmfNq2hOwaOceZtgcc1fKteFYyKTzkW 4VkKEyQO9IKY3EPgKeaB5dZhlQ4TYEMNmDigPSH6AJ7Lz/XrDhvX2InG0wREEEzo/f02 8kC9zry7iEwUMzH771i/lTTzKrQ8p35xsfhVKkm/aI66bFZnkZMWOCzM0BurBqWxmRAp QEpg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aiKg55Si; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-32408-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32408-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p5-20020a17090ad30500b002906893a326si3808214pju.127.2024.01.21.23.19.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 23:19:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32408-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aiKg55Si; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-32408-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32408-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A4A21B256B1 for ; Mon, 22 Jan 2024 07:11:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC0E3F9F4; Mon, 22 Jan 2024 07:10:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aiKg55Si" Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21361DF70; Mon, 22 Jan 2024 07:10:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705907450; cv=none; b=KtInvkGu8gh26b+etXWsjqTSOADvd16OFa345WA6GSluvxBH+pJDRcZ31XddEqHCGTw8GKtJKHUPrg6xSn1NO6PgGKuzyy4PrLUIT6TWLRBVSzz2I13ETFv3iUrX2/5MdfrBSQtvsc3yEzVQp5RxQ7v7A/pzN2JGGJjJZx15wng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705907450; c=relaxed/simple; bh=tLmjOeut6pg+SKiv228NoATv90nxAzKxJkKMBxMz6ac=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=eosqtUbi4yIONrfjx8QwH0b8M3k7jD687/kQ9q+vei3+rBs4nmbb35IEOUulJ7/jgeBzH1KEMdis6/gY1nU8LqaeBZcSZ48C3S+LyRghHwxhM7hx+sbk+f1qjvhWTD8ZbGWHq+fP3IR1BGdcPuXEDRd6kaZHohBqLMFU46QuPr8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aiKg55Si; arc=none smtp.client-ip=209.85.215.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-5cda3e35b26so1039488a12.1; Sun, 21 Jan 2024 23:10:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705907448; x=1706512248; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hRxQwZAfT0nFVIiBEP7efXSgrXaSHC5qjp535Z9j6as=; b=aiKg55SiJ/g3M7D1qDR46KFedCbOiyYcVF90B0My+jdAKIJb/XAV0xxTkpTy+NNhW/ GTcXdjdGhyNndWxv0tCcm6hL4apaJRbCQNlWgoFCVzmEmKMBB5z1/3ajt4tkwDuKGP+U AP4dLNuIU56kJuAQKGXYbnUnP3mDkn6dICZTa0oEkXTGxQoOFVSFX76jIiKnKwa98wlI +LRIOmJ6OcjwWmot0o3HhrGAsBYth1Zf6JxWnqOkVrTKhqBNl5ejlZXCB4a0lDFIhwim KHjDM3b1KayDioauDfY718qB3lxycpeuBUVeD1lw9fRmTLaL7FYWvSB05zihZyQ0NgYn Sx4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705907448; x=1706512248; 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=hRxQwZAfT0nFVIiBEP7efXSgrXaSHC5qjp535Z9j6as=; b=qASxdNwgCsIkUIbpNR6vk10RmlhNXgYcRcx5rnFxSOt7ke7aSJIZG8e+Hrt8jKGm7V z+N3kanhrgD02waq0ht1yhhNuI9iweUNa6NWrdIypc859WAr632QqgoA6vMAaFvzM+eS 68ZN2wTDdT/GyosuIWjKzoWGx1LfpPxrN1QT9J/xSugGLhaev/f3J4p+AndtUW+bItx3 6q98AmU0oFNElbkPUvUth9K5SVxDhKgvBHbZj3tFVqKMaAfADA3+bej7Mgv70yroYGbP z5ayaYTUQAIZSG35ik3P06RyZav6L1amxCtPWS/sYURP4/CY6A/vFhakUDV9HeRvI1iQ dBvw== X-Gm-Message-State: AOJu0YzJJuAi2vb1rzesNhHQJYVmQU2BF6zUcmOo0KeUjU7NiToxDOBx w6VERavWBE0uvpIz3QhHUVuUjJDrEozuNpWjUhstPfsnm1gQ7OaZ X-Received: by 2002:a17:90a:db87:b0:290:78b7:64e with SMTP id h7-20020a17090adb8700b0029078b7064emr463511pjv.15.1705907448055; Sun, 21 Jan 2024 23:10:48 -0800 (PST) Received: from localhost.localdomain ([43.132.98.45]) by smtp.googlemail.com with ESMTPSA id t10-20020a170902d28a00b001d72b3b0ee6sm3463365plc.248.2024.01.21.23.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 23:10:47 -0800 (PST) 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 , Namhyung Kim , Peter Zijlstra , Steven Rostedt Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Ze Gao Subject: [PATCH v2 0/4] perf sched: Fix task state report Date: Mon, 22 Jan 2024 02:08:55 -0500 Message-ID: <20240122070859.1394479-2-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788140236866262613 X-GMAIL-MSGID: 1788774155290068626 No functional changes introduced in v2, just got v1 rebased onto the tip of perf-tools-next for a clean apply. --- Hi, The problems of task state report in both libtraceevent and perf sched has been reported in [1]. In short, they parsed the wrong state due to relying on the outdated hardcoded state string to interpret the raw bitmask from the record, which left the messes to maintain the backward compatibilities for both tools. [1] has not managed to make itself into the kernel, the problems and the solutions are well studied though. Luckily, as suggested by Steven, perf/libtraceevent records the print format, especially the __print_flags() part of the in-kernel tracepoint sched_switch in its metadata, and we have a chance to build the state str on the fly by parsing it. Now that libtraceevent has landed this solution in [2], we now apply the same idea to perf as well. Regards, -- Ze [1]: https://lore.kernel.org/lkml/20230803083352.1585-1-zegao@tencent.com/ [2]: https://lore.kernel.org/linux-trace-devel/20231224140732.7d41698d@rorschach.local.home/ Ze Gao (4): perf sched: Sync state char array with the kernel perf util: Add helpers to parse task state string from libtraceevent perf util: Add evsel__taskstate() to parse the task state info instead perf sched: Commit to evsel__taskstate() to parse task state info tools/perf/builtin-sched.c | 57 +++------------ tools/perf/util/evsel.c | 146 +++++++++++++++++++++++++++++++++++++ tools/perf/util/evsel.h | 1 + 3 files changed, 157 insertions(+), 47 deletions(-)