Message ID | 20240115072306.303993-1-zegao@tencent.com |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-25676-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1547736dyc; Sun, 14 Jan 2024 23:23:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEt+XUYmHTIbfzXszNRcGF5azTvgsg+/T8+weXfgm6OEqkzOD0CXfYeZP1xeOYEAKK4uYrS X-Received: by 2002:a25:c54c:0:b0:dbd:53b8:887f with SMTP id v73-20020a25c54c000000b00dbd53b8887fmr2252927ybe.70.1705303418224; Sun, 14 Jan 2024 23:23:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705303418; cv=none; d=google.com; s=arc-20160816; b=PAnqsi2m3KNQIV4VOahS8RHnXGy2dm6KZokWMOOlrKqoUMdpU5qT0tgQudvXY7KiSF xA0CanVi4re3yglzHS7R06Y6W8W86iYAJzkFRvpYinTOgHWuS4c/C87wIiGt1jvhy5LX U55Wx8bwO7JuSZnf0B2YtZa/bINRQ2qMXbV+5+9uE6qjMGxOz5wU08hd4fn22dKT+2Dk fVX+erOWw+Qs/h1bz3zlw1s8one3M+ee5XZ/XL5PkmSuopULINj5Z5OpvU7YccBjJbhz ihLsDoCeCUWWbfrZHF/B2tkRLdS+WyuZtn2MlwgYDUm95E377QSMMbcgUhjPn5ILEZzG jEVQ== ARC-Message-Signature: i=1; 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=U3zxCYUmaML8ov7vohntDD30tq3BZHVZqgdXMQmkL3E=; fh=BA7X0Fh+nH6aOBOR/HncHKQUGXeIUOSOgeWoVcIZnUI=; b=p3NycbiW4RJDfYiweEADWUzLxK6dLacK64O0y7vUSkdXZx/sRg3IkFcxzgXmpntPS4 rSeT05v+hlp+QaOVCfv06yVwbp2gerS/iRua1I2ENgsyY5WmqpUghZqd88nSNoVeRqjM bHjRT86pmU/MCpnnw3tUdQq8eWNfIJc6EsvoC8K3vzsy3qwu8xqjj/2QZnrCM4IzxGcp FUHx4PkPZkI/t3WbfPQLUxQtUZD9cBOKX9hBxfmN0nzCUbqvcdN4RuxfctpQ94D8FV4I A+pL7fpS+xTIMLDfCiMC0TA08lNnsifu9o9XSsOTARoCXPnjucMi/2Z8tHobkjGfJFZy +cIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SKggr1Zn; spf=pass (google.com: domain of linux-kernel+bounces-25676-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25676-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. [147.75.48.161]) by mx.google.com with ESMTPS id cb17-20020a056a02071100b005cdb499a98esi8848338pgb.181.2024.01.14.23.23.37 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jan 2024 23:23:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25676-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SKggr1Zn; spf=pass (google.com: domain of linux-kernel+bounces-25676-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25676-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 5A175B20DE8 for <ouuuleilei@gmail.com>; Mon, 15 Jan 2024 07:23:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEFE0613C; Mon, 15 Jan 2024 07:23:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SKggr1Zn" Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (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 0DB583D62; Mon, 15 Jan 2024 07:23:14 +0000 (UTC) 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-f175.google.com with SMTP id 41be03b00d2f7-5cda3e35b26so2916559a12.1; Sun, 14 Jan 2024 23:23:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705303394; x=1705908194; 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=U3zxCYUmaML8ov7vohntDD30tq3BZHVZqgdXMQmkL3E=; b=SKggr1ZnwUygXw5Kbu/Tw0lWbicsNwsRjb+cgNK+jAhgPDec+brrzIisTeoE9YOPXH njkdyFvOe2t4FNobaLIyZjB7+XrQOonPNTcm+LqVPAixyE6SqR+XUslosdkJXKf0SeEC xaCbenkiUNQyFVOXPVRs0YzYRwil0yiMfmiKPsX1GDABNR2qsUUcQapBWdGp5ByB9aWE UYPWDutZxFkWKK7nbtbiqauogHLM8d+9pg3n7XkJA4vao65P4fOw/Dyo8VxRERgx2h+y 0S33SnDIeMXXFvfK88TNsqmHD6mUwH5fRUV0Q+cldw8s/c+xjPXdcdjBNwWPKsdJ0G/a GoLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705303394; x=1705908194; 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=U3zxCYUmaML8ov7vohntDD30tq3BZHVZqgdXMQmkL3E=; b=u6dfTutwj52hTKioskZDVEaj9fs/EAoOc4l0DzuFwKwTs+3KUGoY6KLqlp2oUtow2R W6RMtbphmdS9UCdOCHry3eijza3w6gp3Vk3Le/uSwCmvF3lK+2J9BnPaEtNvFScFQ7xV AF642LKegupsVj+b/AmxunT78JkupHfuxVwSw2RYXuWWMg9v3/c5DT/VbHVdFLVjuPtx W9hbuvwRMK2cJvgPqeDdNFg+jksTIW33kuqnAYu2835xRJ/w36M8ovzh/xQDYcMfyoPc eUWkfYHQhK4qx/1OmZHrrxy6Xdqd8QdVilJ+P1LKwp1+owG7PPPgSjQkFTTvroK3zQWX AVbA== X-Gm-Message-State: AOJu0YxnayXrfwq9zdQTYpcI3q6C92csTECGsigf8uvoc9hyALfstPbm c9rWJ6RlZLTAZ1H3CDTJ2h6AnA2eve8Ff/R+ X-Received: by 2002:a17:90b:1986:b0:28b:2a79:dcd with SMTP id mv6-20020a17090b198600b0028b2a790dcdmr2461709pjb.67.1705303394200; Sun, 14 Jan 2024 23:23:14 -0800 (PST) Received: from localhost.localdomain ([203.205.141.87]) by smtp.googlemail.com with ESMTPSA id mp13-20020a170902fd0d00b001d4ac8ac969sm6990545plb.275.2024.01.14.23.23.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jan 2024 23:23:13 -0800 (PST) From: Ze Gao <zegao2021@gmail.com> X-Google-Original-From: Ze Gao <zegao@tencent.com> To: Adrian Hunter <adrian.hunter@intel.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Ian Rogers <irogers@google.com>, Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Namhyung Kim <namhyung@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Steven Rostedt <rostedt@goodmis.org> Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Ze Gao <zegao@tencent.com> Subject: [PATCH 0/4] perf sched: Fix task state report Date: Mon, 15 Jan 2024 02:23:02 -0500 Message-ID: <20240115072306.303993-1-zegao@tencent.com> X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788140236866262613 X-GMAIL-MSGID: 1788140236866262613 |
Series |
perf sched: Fix task state report
|
|
Message
Ze Gao
Jan. 15, 2024, 7:23 a.m. UTC
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(-)
Comments
Hello, On Sun, Jan 14, 2024 at 11:23 PM Ze Gao <zegao2021@gmail.com> wrote: > > 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. Thanks for your work. But perf links libtraceevent conditionally so you need to make sure if it works without that too. I think all libtraceevent related stuff should be in the util/trace-event.c which is included only if the library is available. Maybe util/trace-event-parse.c is a better place but then you need to tweak the python-ext-sources and Makefile.perf for the case it's not available. Thanks, Namhyung > > 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(-) > > -- > 2.41.0 >
On Wed, Jan 17, 2024 at 9:35 AM Namhyung Kim <namhyung@kernel.org> wrote: > > Hello, > > On Sun, Jan 14, 2024 at 11:23 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > 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. > > Thanks for your work. But perf links libtraceevent > conditionally so you need to make sure if it works without > that too. Yes, I've tested with NO_LIBTRACEEVENT=1, and it turns out perf removes perf sched subcmd without libtraceevent, which explains why the compiler does not complain no evsel__intval() defined when !HAVE_LIBTRACEEVENT given the fact so many references of evsel__intval() in builtin-sched.c. Here evsel__taskstate() uses the exact assumption as evsel__intval(), so I put it next to it for clarity and it works without a doubt. > I think all libtraceevent related stuff should be in the > util/trace-event.c which is included only if the library is > available. Maybe util/trace-event-parse.c is a better > place but then you need to tweak the python-ext-sources > and Makefile.perf for the case it's not available. Thanks for pointing this out. I will do the hack if you insist on this move :D. But I think the current version is clear enough, otherwise we need to move all the parts guarded by #ifdef HAVE_LIBTRACEEVENT out for complete decoupling. What do you think of it? Thanks, -- Ze > Thanks, > Namhyung > > > > > 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(-) > > > > -- > > 2.41.0 > >
On Thu, Jan 18, 2024 at 11:00 AM Ze Gao <zegao2021@gmail.com> wrote: > > On Wed, Jan 17, 2024 at 9:35 AM Namhyung Kim <namhyung@kernel.org> wrote: > > > > Hello, > > > > On Sun, Jan 14, 2024 at 11:23 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > 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. > > > > Thanks for your work. But perf links libtraceevent > > conditionally so you need to make sure if it works without > > that too. > > Yes, I've tested with NO_LIBTRACEEVENT=1, and it turns > out perf removes perf sched subcmd without libtraceevent, FWIW, commit 378ef0f5d9d7f4 ("perf build: Use libtraceevent from the system") has proved this as well. Regards, -- Ze > which explains why the compiler does not complain no > evsel__intval() defined when !HAVE_LIBTRACEEVENT > given the fact so many references of evsel__intval() in > builtin-sched.c. > Here evsel__taskstate() uses the exact assumption as > evsel__intval(), so I put it next to it for clarity and it works > without a doubt. > > > I think all libtraceevent related stuff should be in the > > util/trace-event.c which is included only if the library is > > available. Maybe util/trace-event-parse.c is a better > > place but then you need to tweak the python-ext-sources > > and Makefile.perf for the case it's not available. > > Thanks for pointing this out. I will do the hack if you insist > on this move :D. But I think the current version is clear > enough, otherwise we need to move all the parts guarded > by #ifdef HAVE_LIBTRACEEVENT out for complete decoupling. > What do you think of it? > > Thanks, > -- Ze > > > Thanks, > > Namhyung > > > > > > > > Regards, > > > > > > -- Ze > > > > > > [1]: https://lore.kernel.org/lkml/20230803083352.1585-1-zegao@tencentcom/ > > > [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(-) > > > > > > -- > > > 2.41.0 > > >
On Wed, Jan 17, 2024 at 7:15 PM Ze Gao <zegao2021@gmail.com> wrote: > > On Thu, Jan 18, 2024 at 11:00 AM Ze Gao <zegao2021@gmail.com> wrote: > > > > On Wed, Jan 17, 2024 at 9:35 AM Namhyung Kim <namhyung@kernel.org> wrote: > > > > > > Hello, > > > > > > On Sun, Jan 14, 2024 at 11:23 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > > > 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. > > > > > > Thanks for your work. But perf links libtraceevent > > > conditionally so you need to make sure if it works without > > > that too. > > > > Yes, I've tested with NO_LIBTRACEEVENT=1, and it turns > > out perf removes perf sched subcmd without libtraceevent, > > FWIW, commit 378ef0f5d9d7f4 ("perf build: Use libtraceevent > from the system") has proved this as well. Right, but I think we can enable perf sched without libtraceevent for minimal features like record only. But that doesn't belong to this change set. > > > which explains why the compiler does not complain no > > evsel__intval() defined when !HAVE_LIBTRACEEVENT > > given the fact so many references of evsel__intval() in > > builtin-sched.c. > > Here evsel__taskstate() uses the exact assumption as > > evsel__intval(), so I put it next to it for clarity and it works > > without a doubt. > > > > > I think all libtraceevent related stuff should be in the > > > util/trace-event.c which is included only if the library is > > > available. Maybe util/trace-event-parse.c is a better > > > place but then you need to tweak the python-ext-sources > > > and Makefile.perf for the case it's not available. > > > > Thanks for pointing this out. I will do the hack if you insist > > on this move :D. But I think the current version is clear > > enough, otherwise we need to move all the parts guarded > > by #ifdef HAVE_LIBTRACEEVENT out for complete decoupling. > > What do you think of it? Oh, I realized that all the affected codes are under the #ifdef properly then maybe it's ok for now. But I prefer moving the code if you're ok. Maybe I can accept this code as is and you can work on the refactoring later. Does that work for you? Thanks, Namhyung
On Fri, Jan 19, 2024 at 7:53 AM Namhyung Kim <namhyung@kernel.org> wrote: > > On Wed, Jan 17, 2024 at 7:15 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > On Thu, Jan 18, 2024 at 11:00 AM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > On Wed, Jan 17, 2024 at 9:35 AM Namhyung Kim <namhyung@kernelorg> wrote: > > > > > > > > Hello, > > > > > > > > On Sun, Jan 14, 2024 at 11:23 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > > > > > 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. > > > > > > > > Thanks for your work. But perf links libtraceevent > > > > conditionally so you need to make sure if it works without > > > > that too. > > > > > > Yes, I've tested with NO_LIBTRACEEVENT=1, and it turns > > > out perf removes perf sched subcmd without libtraceevent, > > > > FWIW, commit 378ef0f5d9d7f4 ("perf build: Use libtraceevent > > from the system") has proved this as well. > > Right, but I think we can enable perf sched without libtraceevent > for minimal features like record only. But that doesn't belong to > this change set. > > > > > > which explains why the compiler does not complain no > > > evsel__intval() defined when !HAVE_LIBTRACEEVENT > > > given the fact so many references of evsel__intval() in > > > builtin-sched.c. > > > Here evsel__taskstate() uses the exact assumption as > > > evsel__intval(), so I put it next to it for clarity and it works > > > without a doubt. > > > > > > > I think all libtraceevent related stuff should be in the > > > > util/trace-event.c which is included only if the library is > > > > available. Maybe util/trace-event-parse.c is a better > > > > place but then you need to tweak the python-ext-sources > > > > and Makefile.perf for the case it's not available. > > > > > > Thanks for pointing this out. I will do the hack if you insist > > > on this move :D. But I think the current version is clear > > > enough, otherwise we need to move all the parts guarded > > > by #ifdef HAVE_LIBTRACEEVENT out for complete decoupling. > > > What do you think of it? > > Oh, I realized that all the affected codes are under the #ifdef > properly then maybe it's ok for now. But I prefer moving the > code if you're ok. Maybe I can accept this code as is and you Sounds great! > can work on the refactoring later. Does that work for you? Absolutely! Will send the following refactoring patches soon. :D Cheers, -- Ze > Thanks, > Namhyung
On Thu, Jan 18, 2024 at 5:54 PM Ze Gao <zegao2021@gmail.com> wrote: > > On Fri, Jan 19, 2024 at 7:53 AM Namhyung Kim <namhyung@kernel.org> wrote: > > > > On Wed, Jan 17, 2024 at 7:15 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > On Thu, Jan 18, 2024 at 11:00 AM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > > > On Wed, Jan 17, 2024 at 9:35 AM Namhyung Kim <namhyung@kernel.org> wrote: > > > > > > > > > > Hello, > > > > > > > > > > On Sun, Jan 14, 2024 at 11:23 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > > > > > > > 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. > > > > > > > > > > Thanks for your work. But perf links libtraceevent > > > > > conditionally so you need to make sure if it works without > > > > > that too. > > > > > > > > Yes, I've tested with NO_LIBTRACEEVENT=1, and it turns > > > > out perf removes perf sched subcmd without libtraceevent, > > > > > > FWIW, commit 378ef0f5d9d7f4 ("perf build: Use libtraceevent > > > from the system") has proved this as well. > > > > Right, but I think we can enable perf sched without libtraceevent > > for minimal features like record only. But that doesn't belong to > > this change set. > > > > > > > > > which explains why the compiler does not complain no > > > > evsel__intval() defined when !HAVE_LIBTRACEEVENT > > > > given the fact so many references of evsel__intval() in > > > > builtin-sched.c. > > > > Here evsel__taskstate() uses the exact assumption as > > > > evsel__intval(), so I put it next to it for clarity and it works > > > > without a doubt. > > > > > > > > > I think all libtraceevent related stuff should be in the > > > > > util/trace-event.c which is included only if the library is > > > > > available. Maybe util/trace-event-parse.c is a better > > > > > place but then you need to tweak the python-ext-sources > > > > > and Makefile.perf for the case it's not available. > > > > > > > > Thanks for pointing this out. I will do the hack if you insist > > > > on this move :D. But I think the current version is clear > > > > enough, otherwise we need to move all the parts guarded > > > > by #ifdef HAVE_LIBTRACEEVENT out for complete decoupling. > > > > What do you think of it? > > > > Oh, I realized that all the affected codes are under the #ifdef > > properly then maybe it's ok for now. But I prefer moving the > > code if you're ok. Maybe I can accept this code as is and you > > Sounds great! > > > can work on the refactoring later. Does that work for you? > > Absolutely! Will send the following refactoring patches soon. :D Thanks, but your patches don't apply cleanly. Could you please rebase it onto the current perf-tools-next tree? Thanks, Namhyung
On Sat, Jan 20, 2024 at 6:45 AM Namhyung Kim <namhyung@kernel.org> wrote: > > On Thu, Jan 18, 2024 at 5:54 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > On Fri, Jan 19, 2024 at 7:53 AM Namhyung Kim <namhyung@kernel.org> wrote: > > > > > > On Wed, Jan 17, 2024 at 7:15 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > > > On Thu, Jan 18, 2024 at 11:00 AM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > > > > > On Wed, Jan 17, 2024 at 9:35 AM Namhyung Kim <namhyung@kernel.org> wrote: > > > > > > > > > > > > Hello, > > > > > > > > > > > > On Sun, Jan 14, 2024 at 11:23 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > > > > > > > > > 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. > > > > > > > > > > > > Thanks for your work. But perf links libtraceevent > > > > > > conditionally so you need to make sure if it works without > > > > > > that too. > > > > > > > > > > Yes, I've tested with NO_LIBTRACEEVENT=1, and it turns > > > > > out perf removes perf sched subcmd without libtraceevent, > > > > > > > > FWIW, commit 378ef0f5d9d7f4 ("perf build: Use libtraceevent > > > > from the system") has proved this as well. > > > > > > Right, but I think we can enable perf sched without libtraceevent > > > for minimal features like record only. But that doesn't belong to > > > this change set. > > > > > > > > > > > > which explains why the compiler does not complain no > > > > > evsel__intval() defined when !HAVE_LIBTRACEEVENT > > > > > given the fact so many references of evsel__intval() in > > > > > builtin-sched.c. > > > > > Here evsel__taskstate() uses the exact assumption as > > > > > evsel__intval(), so I put it next to it for clarity and it works > > > > > without a doubt. > > > > > > > > > > > I think all libtraceevent related stuff should be in the > > > > > > util/trace-event.c which is included only if the library is > > > > > > available. Maybe util/trace-event-parse.c is a better > > > > > > place but then you need to tweak the python-ext-sources > > > > > > and Makefile.perf for the case it's not available. > > > > > > > > > > Thanks for pointing this out. I will do the hack if you insist > > > > > on this move :D. But I think the current version is clear > > > > > enough, otherwise we need to move all the parts guarded > > > > > by #ifdef HAVE_LIBTRACEEVENT out for complete decoupling. > > > > > What do you think of it? > > > > > > Oh, I realized that all the affected codes are under the #ifdef > > > properly then maybe it's ok for now. But I prefer moving the > > > code if you're ok. Maybe I can accept this code as is and you > > > > Sounds great! > > > > > can work on the refactoring later. Does that work for you? > > > > Absolutely! Will send the following refactoring patches soon. :D > > Thanks, but your patches don't apply cleanly. Could you please > rebase it onto the current perf-tools-next tree? Oops, that is kinda weird. I've tested and managed to cherry-picked all 4 patches onto branch perf-tools-next in [1], with no conflicts being hit. Maybe I used the wrong branch tip? FWIW: the tip I rebase onto is d988c9f511af (perf/perf-tools-next) MAINTAINERS: Add Namhyung as tools/perf/ co-maintainer [1]: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/ Regards, -- Ze > Thanks, > Namhyung
On Mon, Jan 22, 2024 at 11:08 AM Ze Gao <zegao2021@gmail.com> wrote: > > On Sat, Jan 20, 2024 at 6:45 AM Namhyung Kim <namhyung@kernel.org> wrote: > > > > On Thu, Jan 18, 2024 at 5:54 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > On Fri, Jan 19, 2024 at 7:53 AM Namhyung Kim <namhyung@kernelorg> wrote: > > > > > > > > On Wed, Jan 17, 2024 at 7:15 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > > > > > On Thu, Jan 18, 2024 at 11:00 AM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > > > > > > > On Wed, Jan 17, 2024 at 9:35 AM Namhyung Kim <namhyung@kernel.org> wrote: > > > > > > > > > > > > > > Hello, > > > > > > > > > > > > > > On Sun, Jan 14, 2024 at 11:23 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > > > > > > > > > > > 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. > > > > > > > > > > > > > > Thanks for your work. But perf links libtraceevent > > > > > > > conditionally so you need to make sure if it works without > > > > > > > that too. > > > > > > > > > > > > Yes, I've tested with NO_LIBTRACEEVENT=1, and it turns > > > > > > out perf removes perf sched subcmd without libtraceevent, > > > > > > > > > > FWIW, commit 378ef0f5d9d7f4 ("perf build: Use libtraceevent > > > > > from the system") has proved this as well. > > > > > > > > Right, but I think we can enable perf sched without libtraceevent > > > > for minimal features like record only. But that doesn't belong to > > > > this change set. > > > > > > > > > > > > > > > which explains why the compiler does not complain no > > > > > > evsel__intval() defined when !HAVE_LIBTRACEEVENT > > > > > > given the fact so many references of evsel__intval() in > > > > > > builtin-sched.c. > > > > > > Here evsel__taskstate() uses the exact assumption as > > > > > > evsel__intval(), so I put it next to it for clarity and it works > > > > > > without a doubt. > > > > > > > > > > > > > I think all libtraceevent related stuff should be in the > > > > > > > util/trace-event.c which is included only if the library is > > > > > > > available. Maybe util/trace-event-parse.c is a better > > > > > > > place but then you need to tweak the python-ext-sources > > > > > > > and Makefile.perf for the case it's not available. > > > > > > > > > > > > Thanks for pointing this out. I will do the hack if you insist > > > > > > on this move :D. But I think the current version is clear > > > > > > enough, otherwise we need to move all the parts guarded > > > > > > by #ifdef HAVE_LIBTRACEEVENT out for complete decoupling. > > > > > > What do you think of it? > > > > > > > > Oh, I realized that all the affected codes are under the #ifdef > > > > properly then maybe it's ok for now. But I prefer moving the > > > > code if you're ok. Maybe I can accept this code as is and you > > > > > > Sounds great! > > > > > > > can work on the refactoring later. Does that work for you? > > > > > > Absolutely! Will send the following refactoring patches soon. :D > > > > Thanks, but your patches don't apply cleanly. Could you please > > rebase it onto the current perf-tools-next tree? > > Oops, that is kinda weird. I've tested and managed to cherry-picked all 4 > patches onto branch perf-tools-next in [1], with no conflicts being > hit. Maybe I used the wrong branch tip? For reference, it ends up like: https://github.com/zegao96/linux/commits/perf-tools-next/ > FWIW: the tip I rebase onto is > > d988c9f511af (perf/perf-tools-next) MAINTAINERS: Add Namhyung as > tools/perf/ co-maintainer > > [1]: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/ > > Regards, > -- Ze > > > Thanks, > > Namhyung
On Mon, Jan 22, 2024 at 11:08 AM Ze Gao <zegao2021@gmail.com> wrote: > > On Sat, Jan 20, 2024 at 6:45 AM Namhyung Kim <namhyung@kernel.org> wrote: > > > > On Thu, Jan 18, 2024 at 5:54 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > On Fri, Jan 19, 2024 at 7:53 AM Namhyung Kim <namhyung@kernelorg> wrote: > > > > > > > > On Wed, Jan 17, 2024 at 7:15 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > > > > > On Thu, Jan 18, 2024 at 11:00 AM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > > > > > > > On Wed, Jan 17, 2024 at 9:35 AM Namhyung Kim <namhyung@kernel.org> wrote: > > > > > > > > > > > > > > Hello, > > > > > > > > > > > > > > On Sun, Jan 14, 2024 at 11:23 PM Ze Gao <zegao2021@gmail.com> wrote: > > > > > > > > > > > > > > > > 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. > > > > > > > > > > > > > > Thanks for your work. But perf links libtraceevent > > > > > > > conditionally so you need to make sure if it works without > > > > > > > that too. > > > > > > > > > > > > Yes, I've tested with NO_LIBTRACEEVENT=1, and it turns > > > > > > out perf removes perf sched subcmd without libtraceevent, > > > > > > > > > > FWIW, commit 378ef0f5d9d7f4 ("perf build: Use libtraceevent > > > > > from the system") has proved this as well. > > > > > > > > Right, but I think we can enable perf sched without libtraceevent > > > > for minimal features like record only. But that doesn't belong to > > > > this change set. > > > > > > > > > > > > > > > which explains why the compiler does not complain no > > > > > > evsel__intval() defined when !HAVE_LIBTRACEEVENT > > > > > > given the fact so many references of evsel__intval() in > > > > > > builtin-sched.c. > > > > > > Here evsel__taskstate() uses the exact assumption as > > > > > > evsel__intval(), so I put it next to it for clarity and it works > > > > > > without a doubt. > > > > > > > > > > > > > I think all libtraceevent related stuff should be in the > > > > > > > util/trace-event.c which is included only if the library is > > > > > > > available. Maybe util/trace-event-parse.c is a better > > > > > > > place but then you need to tweak the python-ext-sources > > > > > > > and Makefile.perf for the case it's not available. > > > > > > > > > > > > Thanks for pointing this out. I will do the hack if you insist > > > > > > on this move :D. But I think the current version is clear > > > > > > enough, otherwise we need to move all the parts guarded > > > > > > by #ifdef HAVE_LIBTRACEEVENT out for complete decoupling. > > > > > > What do you think of it? > > > > > > > > Oh, I realized that all the affected codes are under the #ifdef > > > > properly then maybe it's ok for now. But I prefer moving the > > > > code if you're ok. Maybe I can accept this code as is and you > > > > > > Sounds great! > > > > > > > can work on the refactoring later. Does that work for you? > > > > > > Absolutely! Will send the following refactoring patches soon. :D > > > > Thanks, but your patches don't apply cleanly. Could you please > > rebase it onto the current perf-tools-next tree? > > Oops, that is kinda weird. I've tested and managed to cherry-picked all 4 > patches onto branch perf-tools-next in [1], with no conflicts being Please forget about this. Looks like git-cherry-pick is smarter to figure out where to apply when in the same repo ( or than git-am ?). Anyway I've resent a v2 series: https://lore.kernel.org/all/20240122070859.1394479-2-zegao@tencent.com/ Tested and verified. Hope this time i don't mess it up :) Thanks, -- Ze > hit. Maybe I used the wrong branch tip? > > FWIW: the tip I rebase onto is > > d988c9f511af (perf/perf-tools-next) MAINTAINERS: Add Namhyung as > tools/perf/ co-maintainer > > [1]: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/ > > Regards, > -- Ze > > > Thanks, > > Namhyung