Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49719C05027 for ; Thu, 9 Feb 2023 02:29:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231171AbjBIC3R (ORCPT ); Wed, 8 Feb 2023 21:29:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231936AbjBIC3G (ORCPT ); Wed, 8 Feb 2023 21:29:06 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E72635AC; Wed, 8 Feb 2023 18:29:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 117B4B81F78; Thu, 9 Feb 2023 02:29:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB0EBC433EF; Thu, 9 Feb 2023 02:28:59 +0000 (UTC) Date: Wed, 8 Feb 2023 21:28:58 -0500 From: Steven Rostedt To: John Stultz Cc: Alexei Starovoitov , Yafang Shao , Andrew Morton , Network Development , bpf , "linux-perf-use." , Linux-Fsdevel , linux-mm , LKML , kernel test robot , kbuild test robot , Andrii Nakryiko , David Hildenbrand , Mathieu Desnoyers , Arnaldo Carvalho de Melo , Andrii Nakryiko , Michal Miroslaw , Peter Zijlstra , Matthew Wilcox , Al Viro , Kees Cook , Petr Mladek , Kajetan Puchalski , Lukasz Luba , Qais Yousef , Daniele Di Proietto , Linus Torvalds Subject: Re: [PATCH v2 7/7] tools/testing/selftests/bpf: replace open-coded 16 with TASK_COMM_LEN Message-ID: <20230208212858.477cd05e@gandalf.local.home> In-Reply-To: References: <20211120112738.45980-1-laoar.shao@gmail.com> <20211120112738.45980-8-laoar.shao@gmail.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 8 Feb 2023 16:54:03 -0800 John Stultz wrote: > > Let me understand what you're saying... > > > > The commit 3087c61ed2c4 did > > > > -/* Task command name length: */ > > -#define TASK_COMM_LEN 16 > > +/* > > + * Define the task command name length as enum, then it can be visible to > > + * BPF programs. > > + */ > > +enum { > > + TASK_COMM_LEN = 16, > > +}; > > > > > > and that caused: > > > > cat /sys/kernel/debug/tracing/events/task/task_newtask/format > > > > to print > > field:char comm[TASK_COMM_LEN]; offset:12; size:16; signed:0; Yes because there's no easy way to automatically convert an enum to a number. And this has been a macro for a very long time (so it works, because macros convert to numbers). And this breaks much more than android. It will break trace-cmd, rasdaemon and perf (if it's not using BTF). This change very much "Breaks userspace!" And requires a kernel workaround, not a user space one. > > instead of > > field:char comm[16]; offset:12; size:16; signed:0; > > > > so the ftrace parsing android tracing tool had to do: > > > > - if (Match(type_and_name.c_str(), R"(char [a-zA-Z_]+\[[0-9]+\])")) { > > + if (Match(type_and_name.c_str(), > > + R"(char [a-zA-Z_][a-zA-Z_0-9]*\[[a-zA-Z_0-9]+\])")) { > > > > to workaround this change. > > Right? > > I believe so. > > > And what are you proposing? > > I'm not proposing anything. I was just wanting to understand more > context around this, as it outwardly appears to be a user-breaking > change, and that is usually not done, so I figured it was an issue > worth raising. > > If the debug/tracing/*/format output is in the murky not-really-abi > space, that's fine, but I wanted to know if this was understood as > something that may require userland updates or if this was a > unexpected side-effect. Linus has already said that /sys/kernel/tracing/* is an ABI (fyi, getting to the tracing directory via debugfs is obsolete). Usually, when a trace event uses an enum, it can do: TRACE_DEFINE_ENUM(TASK_COMM_LEN); But that's a very common define. It would require it updated for every trace event, or the change needs to be reverted. Not sure why BTF needs it like this, because it hasn't changed in years. Can't it just hard code it? For ftrace to change it, it requires reading the format files at boot up and replacing the enums with the numbers, which does impact start up. -- Steve