Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp676452rdb; Thu, 18 Jan 2024 15:54:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJ7mtuKvD3EK6cxa+OyEfdfmdMED5rqUuaC0T4hbQCIUwDAv2OUwq56+LIluidjCQuIJUT X-Received: by 2002:a05:6808:143:b0:3bd:9a58:c6e3 with SMTP id h3-20020a056808014300b003bd9a58c6e3mr1776949oie.52.1705622039894; Thu, 18 Jan 2024 15:53:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705622039; cv=pass; d=google.com; s=arc-20160816; b=cSw4DfW3z6MJKQa2Nu2SmcZcQNKi3oc6WS3M69ibdkVFb9+NN2B92ERykrmAaB0pnL jFuh/RjrQIQgXijzcFD8fX3lFNflndQ1NKzPAoDQMLgBs3TC/OMT1DOVtcKfX8hld9YU bybEWC7VA95p2l7Q6gIcPpDIV6417FCgWUORIs6RjwWDXkt13FyLdt+UMDmXs4VLqMDx g9flXScvYXIsPpcufIo0GtbjbaJHDOb9IiDy7jMev4knZDdhwra4bETlkw1zLpcu9LOm dd+0oz5SRTz9S8kkwPmvpeZXXIa/x86rr5eihnFoYK+yqMkXze+LOIsZ8KTefNxAbEsL 6EZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=6TigLBHq4V1Dou2wp+gkiDBZsxhJ6NyZ5H+xB6Pl9Xk=; fh=kIKAnLjE3efRdy1mS4BWHLjeVHYvpYf0NY9zPSpKGv8=; b=JI+Dupn6yoCxWEFPY3d/Yel1RcGv8dqVhSjUvt2Tm3UFCDi7j7JQ8k6d4BXuVenJjR uu6FpNph4jhV4UrOOAF6h0prN2Rui7GzDG6qyROS4WPoeHZoLIqgAVjhizI0YoSKygi8 Fjj4oF7EQnIbb0k8uDiPYLJAFJwWTbx/YUAvM6AzruvK1C0RpZJeq1qHMaf7TVQGcM1A fVAj17FM/86FVPLQcFrdoybfRm+si0kaEjk+pPXvyggrzIAuWdzByKwZdluGSgqBmgLU 3hW4WUVvUe9tfHRBOAYznS5/IGR8ZdEK5y9EUWBrgAV8dEWQieEptUppq4LVloIhil3d lFZA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-30643-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30643-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id fd38-20020a056a002ea600b006dab362a565si4512333pfb.117.2024.01.18.15.53.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 15:53:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30643-linux.lists.archive=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; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-30643-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30643-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 04557B2317F for ; Thu, 18 Jan 2024 23:53:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A79BB20333; Thu, 18 Jan 2024 23:53:47 +0000 (UTC) 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 CCEA51E526; Thu, 18 Jan 2024 23:53:45 +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=1705622027; cv=none; b=rJIDKUjPPvFutK79ZFPA5hzg8DaouUZYgbsHZFsVZwJqTF5isw3fvfJQIYaXVSpvrYR1DwUDrEeZjKRsFbm9PxTK4uzp02iah40zq2QRSSfpJTCaJFoUtGYjdQ02BgYRAXfdgqnC1ye/hUlA70q6amwW+Nq3Cs888jhaoQ+8xos= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705622027; c=relaxed/simple; bh=dH+2l6OwauixQhf/uwUFeKx76qVVyik+j5oHs1cwawU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=jc8QTd9CGSBcI+6IybCjHqOUwNqfo9FbGAMbuI5y1rV0VCaDW0ZdHAiG1uvtMe9+HDBN6oQ+RtFKky/+0dRrOpIpyUYjzUTUFUdZoKQ6U99hQpmj/rScnFOmQB6nFERtQxBaG96ZfM2og5Z8VRfoGOWayIACtHx8+0KU5ePu5z4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.215.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-5cddc5455aeso191795a12.1; Thu, 18 Jan 2024 15:53:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705622025; x=1706226825; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6TigLBHq4V1Dou2wp+gkiDBZsxhJ6NyZ5H+xB6Pl9Xk=; b=WavdqrMHWZ/yBXBZ/r7uiDm/hhSmUscPIB8tcjwXQLPuE7AVi9mn+vjFCkBWmSVvV2 4i6NcFG2IBG9qz9nyBMj6BICZGLHDObUsXy1kBk+au1hkJ5+RpIny/3+mxZdDXOqQjwV Pb0G7x7FF+l9btU1KLCL/KCj4GfeBVtunArSPy7sYeHCwSgpucvz6DllaRX1zdiKwgUB JT50Q/nWEcnIGwyXe7/KwNjRPWe8REyayK7+V/bGj0rElbeyK/bXflE/XEi9qc6reEH9 +ZNPnf/XvFJwwp82+9CoN+ZihLrPzGSijoXafcrFQiwX5fYoenWBX3I4RCqphF2T1P45 jVQw== X-Gm-Message-State: AOJu0YxYocYxRdv/krEUdo6UvR0KYnesYagtOelCoEiN/iSSyS5GVoZQ vvkXW4IKyWkWDy9vS04JawBY6q9Mq0mIAn9O4DKHanIHJ5QsiIbKrrEoRNm4ODwCPoZY0J0kVGq +1w9XwTIu/8ooqm3QANrQ7t55A5c= X-Received: by 2002:a17:90a:16d0:b0:28c:bb53:aa83 with SMTP id y16-20020a17090a16d000b0028cbb53aa83mr1485461pje.15.1705622025092; Thu, 18 Jan 2024 15:53:45 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240115072306.303993-1-zegao@tencent.com> In-Reply-To: From: Namhyung Kim Date: Thu, 18 Jan 2024 15:53:34 -0800 Message-ID: Subject: Re: [PATCH 0/4] perf sched: Fix task state report To: Ze Gao Cc: Adrian Hunter , Alexander Shishkin , Arnaldo Carvalho de Melo , Ian Rogers , Ingo Molnar , Jiri Olsa , Mark Rutland , Peter Zijlstra , Steven Rostedt , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Ze Gao Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 17, 2024 at 7:15=E2=80=AFPM Ze Gao wrote: > > On Thu, Jan 18, 2024 at 11:00=E2=80=AFAM Ze Gao wro= te: > > > > On Wed, Jan 17, 2024 at 9:35=E2=80=AFAM Namhyung Kim wrote: > > > > > > Hello, > > > > > > On Sun, Jan 14, 2024 at 11:23=E2=80=AFPM Ze Gao = 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=3D1, 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