Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2409455rwo; Thu, 3 Aug 2023 09:00:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlG7NYPLKOH2Vb5PxhB4IZZZ4yh4EZyp5C0qWvvuPgsZ9+QDkncK5E1tfSl6ujxYn+2N7dpd X-Received: by 2002:a17:907:6daa:b0:99b:af5a:fc2c with SMTP id sb42-20020a1709076daa00b0099baf5afc2cmr11149066ejc.26.1691078416710; Thu, 03 Aug 2023 09:00:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691078416; cv=none; d=google.com; s=arc-20160816; b=sdhB1mwx2EQMC3kCqDrGbkDm9mUWrTsMkrQAIMLA7qjbdZzkPZ8/HJVaSqPZp+F0Y2 HPlnV/WsFWGEKHfvw6kILpDfspw42kNgY2wsb2FkY+n8Z/Nc4H6azmUUDmt/USkF+MD3 4nhfa0XdM5QOLOlxk/toQTt98g6d+a7t/2bjxxZ9u001LbushTFXkNUHhpGJvpsQ3ukL AaBpusKrPeAn0voTFlKXE3cyBn6vtXOPPKGZoBR4rmbnBfGRw4TAK8R3tAsRejTUcTGF 6az80AFn+5E/yd/Gyt/oMVOH4p993NauphQBVZ2iCXlQII/CuPrfJbHacm74H7YV5BW5 ITsQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=XcVM7xtMe18/Moy2yRlVNaPp/oYaxy0xf0VAAn9/SLI=; fh=UpFtFCzii5ykkGoXq8QCM+IXKNgpf9xKHjNRjBS9wMU=; b=lFccyo5zescgwNWkiIyVf1Vm+Gsmg1NoW+2qFTe+GXObof5RZ/3EbkPXRKf9Q4I+Tc 5tXymTbffOwWRLr5NTffZxRuhB0OKTHJJOlWxnZpzeVbfFfKt4DRSoYzDD4rGyUT6TKU G9aeFKYru1uVwboLla4LkzCxwPuwopK3xLG4cKFOSbXXFE1pBc5hlNTpQzAkgRh7qTAI 3xq8WVt4vMKN4LahBPOv5QOMDwuc3a//nndJC/N8FXI1Zr4vSTKzcnc6RV2ZuS3npNT+ DKqfUH5cX1cdC377TQKSONvMr+tICp5LtdaHOsN2vPDsm/6IuMltYavkuh/PXnSLf47u ti1w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m3-20020a170906720300b0099364d9f0easi7644ejk.479.2023.08.03.08.59.50; Thu, 03 Aug 2023 09:00:16 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236942AbjHCPKw (ORCPT + 99 others); Thu, 3 Aug 2023 11:10:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236909AbjHCPKh (ORCPT ); Thu, 3 Aug 2023 11:10:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFFD330EA; Thu, 3 Aug 2023 08:10:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0806361DF1; Thu, 3 Aug 2023 15:10:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC8F2C433C8; Thu, 3 Aug 2023 15:10:32 +0000 (UTC) Date: Thu, 3 Aug 2023 11:10:31 -0400 From: Steven Rostedt To: Ze Gao 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, Ze Gao Subject: Re: [RFC PATCH v6 1/5] perf sched: sync state char array with the kernel Message-ID: <20230803111031.056b3446@gandalf.local.home> In-Reply-To: <20230803083352.1585-2-zegao@tencent.com> References: <20230803083352.1585-1-zegao@tencent.com> <20230803083352.1585-2-zegao@tencent.com> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,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 Thu, 3 Aug 2023 04:33:48 -0400 Ze Gao wrote: > Update state char array and then remove unused and stale > macros, which are kernel internal representations and not > encouraged to use anymore. > > Signed-off-by: Ze Gao > --- > tools/perf/builtin-sched.c | 13 +------------ > 1 file changed, 1 insertion(+), 12 deletions(-) > > diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c > index 9ab300b6f131..8dc8f071721c 100644 > --- a/tools/perf/builtin-sched.c > +++ b/tools/perf/builtin-sched.c > @@ -92,23 +92,12 @@ struct sched_atom { > struct task_desc *wakee; > }; > > -#define TASK_STATE_TO_CHAR_STR "RSDTtZXxKWP" > +#define TASK_STATE_TO_CHAR_STR "RSDTtXZPI" Thinking about this more, this will always be wrong. Changing it just works for the kernel you made the change for, but if it is run on another kernel, it's broken again. I actually wrote code once that basically just did a: struct trace_seq s; trace_seq_init(&s); tep_print_event(tep, &s, record, "%s", TEP_PRINT_INFO); then searched s.buffer for "prev_state=%s ", to find the state character. That's because the kernel should always be up to date (and why I said I needed that string in the print_fmt). As perf has a tep handle, this could be a helper function to extract the state if needed, and get rind of relying on the above character array. -- Steve > > /* task state bitmask, copied from include/linux/sched.h */ > #define TASK_RUNNING 0 > #define TASK_INTERRUPTIBLE 1 > #define TASK_UNINTERRUPTIBLE 2 > -#define __TASK_STOPPED 4 > -#define __TASK_TRACED 8 > -/* in tsk->exit_state */ > -#define EXIT_DEAD 16 > -#define EXIT_ZOMBIE 32 > -#define EXIT_TRACE (EXIT_ZOMBIE | EXIT_DEAD) > -/* in tsk->state again */ > -#define TASK_DEAD 64 > -#define TASK_WAKEKILL 128 > -#define TASK_WAKING 256 > -#define TASK_PARKED 512 > > enum thread_state { > THREAD_SLEEPING = 0,