Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1704658rwo; Wed, 2 Aug 2023 20:24:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgEAwD4S49uFV5TxKXxyDxkURC9Uv80xm7aKDhJ8MZurXfQXo6F933TWEe0NRj8xYcZ7Nk X-Received: by 2002:a17:907:7791:b0:99c:7301:4d69 with SMTP id ky17-20020a170907779100b0099c73014d69mr54871ejc.20.1691033096987; Wed, 02 Aug 2023 20:24:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691033096; cv=none; d=google.com; s=arc-20160816; b=Jep/tHp4WJaBt3mZXRVyvhiyn8hNTqoVvMkKr/7ynekuj+PJ3Rl8JMVRVzmxQWMigQ qE4EwHMgaKh8UFX6gcpayvYeluuE9lWrPJ48hqp32TKbguU+9mejvTm53hqUJvGSMPfc 6eOvY7oa6MSSoAFlOJKVRONoq8LtO3mjfNfWuqfQrnsv+yCj3OF0lilYg+9zq4/xaFGU UMWJY7ZfMFdAO/YdtuD9CK/rMCVUbUmao2PwK7JfHMBE3V+XwOazVLnl7LCxlkIsp5FT mMKfe0hQj3haxU521snhBVEZNQX/XTLT4yCnL0OjUJLJS89ywHVIsg1v8HW53EvfF02U AdJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=EecucEpTbRj2GJZv+DMCHZrsVlsYJQ4FsHycdTutpDs=; fh=Oht4GR3B1b7NI21IyLQZIButLBGV9Tz7mVypv5Sb+0Q=; b=zr+HaJfvl8xzmDl+2MfrTUpJ8g4VGjbaiQHvCoVqxqNmjuy/6Nh/FAJNUELvm+IJRf 7j6+t7Mk5Hx9LYJUlBg65ebPJkbQKtault0zSQZx+hq1l9Ux5oS3N03I/5dTwvbKWZum zJc+0ZuDAuchEX9fIfQvMcefbaAgoNL5JoUQjU7b5wuBfb2ePDF3k/uR8/Znjb2iIvAK 9hLttaqDUNz6NQwAwebCANOeR9VCrkULZOmUqf7iLXsfZZla/sv323Lui9AeTiv4wZ1q aoy/pN4pD28xQa0G1YY+86bMWIkt7r86Qtzn+mlzp4cULCGvrpkI8G6UhtDS2sbnH9de WgLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=lPmF+jU2; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga6-20020a170906b84600b0099bcd1f229asi9479686ejb.370.2023.08.02.20.24.32; Wed, 02 Aug 2023 20:24:56 -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=lPmF+jU2; 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 S231996AbjHCCjU (ORCPT + 99 others); Wed, 2 Aug 2023 22:39:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232326AbjHCCjE (ORCPT ); Wed, 2 Aug 2023 22:39:04 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB31A1713; Wed, 2 Aug 2023 19:38:56 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-522dd6b6438so488531a12.0; Wed, 02 Aug 2023 19:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691030335; x=1691635135; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=EecucEpTbRj2GJZv+DMCHZrsVlsYJQ4FsHycdTutpDs=; b=lPmF+jU2LgznkDHkXkayXi69tSumH9HaA2MThdZ6EJHhBKvdu2qhANzGAV419vfrZG KlsPmzDvyx6Bo57VzKrFryyNXskwe1elulW3hiEiujvZB8VPL7QpFq93q61jeGV2QCtp H5RFmq8lXaSXSh/SlydEhp8/xvylhoNGb9UUHl9FEG/UeMgtWKb58p2BH17Dez1OauEX BU/F6cglQbNej8AfqFnWFdh2yPrgYwmQhuYkx2l/mYd5N8h0FA3H9/GJvMvcFkHG3Ayh v9rteHxfuwJ098myD10NlOeygr3xWUrl5wcZbaLIZvLiBfYcg2R1si+Lh+017k+YqPqD nzhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691030335; x=1691635135; 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=EecucEpTbRj2GJZv+DMCHZrsVlsYJQ4FsHycdTutpDs=; b=TZSbf8s1IE6onSdeKocjElQlbn41/8W9oC2c7V1K+5E8GmhSUCxXV7AuUleAq1Jd1k qly7MTS9uwISeHUnHt9lSs/UIdKYR5NX1gxhhwdgAwVEO5OV0v2ZcLbObxdetWb8dKup LpRqfRivMW7NVPhmReN6Tyi4DMb3PXt9/yRfWtGG2iW84iYTr8uyP5pd0va+d5HpTzQ5 sM/7vlZCVIVfJ9x5cFzdTuvTh6RS8wuVFvCx0d6HBtMfN+L7ax2/O9ff4v8m1onpgF86 x/DDdrzOX3F6/B4dlLNaLZp/aqDfALImeN5a40mRqBwLcyeiggAApF0ypxbozed66v8O ndxA== X-Gm-Message-State: ABy/qLYw9GX6l4yzPmZfGRvtmguIs+r6Xa51sflP6UxT8QoL0NTRTk0e qlWaCdOW1k6ltAIeFYvX/AFR3fnMfuAekmEa5tM= X-Received: by 2002:a05:6402:8:b0:51d:87c6:bf28 with SMTP id d8-20020a056402000800b0051d87c6bf28mr6368292edu.3.1691030335039; Wed, 02 Aug 2023 19:38:55 -0700 (PDT) MIME-Version: 1.0 References: <20230802121116.324604-1-zegao@tencent.com> <20230802121116.324604-6-zegao@tencent.com> <20230802110701.5227346d@gandalf.local.home> In-Reply-To: <20230802110701.5227346d@gandalf.local.home> From: Ze Gao Date: Thu, 3 Aug 2023 10:38:43 +0800 Message-ID: Subject: Re: [RFC PATCH v4 5/7] sched, tracing: add to report task state in symbolic chars To: Steven Rostedt Cc: Adrian Hunter , Alexander Shishkin , Arnaldo Carvalho de Melo , Ian Rogers , Ingo Molnar , Jiri Olsa , Mark Rutland , Masami Hiramatsu , Namhyung Kim , Peter Zijlstra , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Wed, Aug 2, 2023 at 11:07=E2=80=AFPM Steven Rostedt wrote: > > On Wed, 2 Aug 2023 08:10:00 -0400 > Ze Gao wrote: > > > 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_stat= e, > > + struct task_struct *p) > > +{ > > + long state; > > + > > +#ifdef CONFIG_SCHED_DEBUG > > + BUG_ON(p !=3D current); > > BUG? Why not WARN_ON()? I directly copied it from __trace_sched_switch_state since they are very similar. I had doubt on this too but decided to keep it in case people want to be 100% sure that the current task is exactly the one that is being switched, otherwise it's a fatal problem for scheduler at the point where trace_sched_switch is called. If you think WARN_ON_ONCE is more appropriate, I can fix both in v6. Thoughts? Regards, Ze